This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Triton Repository". The branch, master has been updated via 08b6cf4292576bf0fbeaa91f7a88f38c3a164a31 (commit) from 3df48677eef229b7b3d9d34edcaea6966af5b95f (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 08b6cf4292576bf0fbeaa91f7a88f38c3a164a31 Author: Philip Carns <[email protected]> Date: Thu Jul 21 15:10:09 2011 -0500 avoid repetitive add/delete of sockets from epoll - this is just experimental code in the epoll version of aesocket, not worth implementing cleanly right now - use "oneshot" epoll events to make sure that events don't trigger unless we have corresponding ops posted in the resource ----------------------------------------------------------------------- Summary of changes: code/src/common/resources/aesocket/aesocket.c | 28 ++++++++++++++++--------- 1 files changed, 18 insertions(+), 10 deletions(-) Diff of changes: diff --git a/code/src/common/resources/aesocket/aesocket.c b/code/src/common/resources/aesocket/aesocket.c index f83360f..b504fdf 100644 --- a/code/src/common/resources/aesocket/aesocket.c +++ b/code/src/common/resources/aesocket/aesocket.c @@ -15,7 +15,9 @@ #include <sys/epoll.h> #endif - +/* TODO: this is a hack for testing */ +#define MAX_FDS 1024 +char known_fds[MAX_FDS] = {0}; #define AESOCKET_DEFAULT_SIZE 1024 @@ -61,15 +63,14 @@ static void* thread_fn(void* foo) for(i=0; i<count; i++) { - /* TODO: adding and removing sockets constantly from the epoll set isn't - * great; it would be better if we could keep them in there persistently - * and just modify the event type - */ op = (struct ae_op*)events[i].data.ptr; socket_op = ae_op_entry(op, struct aesocket_op, op); +/* NOTE: this isn't necessary now because we are using one shot events */ +#if 0 ret = epoll_ctl(epfd, EPOLL_CTL_DEL, socket_op->fd, NULL); /* TODO: error handling */ assert(count >= 0); +#endif ae_opcache_complete_op(aesocket_opcache, op, triton_ret_t, TRITON_SUCCESS); } } @@ -169,13 +170,20 @@ ae_define_post(triton_ret_t, triton_aesocket_ready, int fd, #else event.data.ptr = op; event.events = socket_op->flags; + event.events |= EPOLLONESHOT; - /* TODO: adding and removing sockets constantly from the epoll set isn't - * great; it would be better if we could keep them in there persistently - * and just modify the event type - */ /* TODO: think about races and how to prevent them if any */ - ret = epoll_ctl(epfd, EPOLL_CTL_ADD, fd, &event); + /* TODO: this is a hack method to track which fds have been added to the set already, just for testing */ + assert(fd < MAX_FDS); + if(!known_fds[fd]) + { + ret = epoll_ctl(epfd, EPOLL_CTL_ADD, fd, &event); + known_fds[fd] = 1; + } + else + { + ret = epoll_ctl(epfd, EPOLL_CTL_MOD, fd, &event); + } if(ret < 0) { return(TRITON_ERR_EPOLL); hooks/post-receive -- Triton Repository