From 1b9532cb8b757e0d430523190c65d17cf33a9b99 Mon Sep 17 00:00:00 2001 From: Razvan Crainea Date: Tue, 19 Dec 2017 12:27:14 +0200 Subject: [PATCH] reactor: replace epoll_lt and epoll_et \w epoll Remove the epoll_lt and epoll_et keyworkds and make available only epoll, which behaves as epoll lt (Level Triggered) --- io_wait.c | 20 ++++++-------------- io_wait.h | 42 ++---------------------------------------- poll_types.h | 2 +- reactor.h | 8 +------- reactor_defs.h | 2 +- 5 files changed, 11 insertions(+), 63 deletions(-) diff --git a/io_wait.c b/io_wait.c index d4c25843918..713c2e043ce 100644 --- a/io_wait.c +++ b/io_wait.c @@ -56,7 +56,7 @@ char* poll_support="poll" #ifdef HAVE_EPOLL -", epoll_lt, epoll_et" +", epoll" #endif #ifdef HAVE_SIGIO_RT ", sigio_rt" @@ -73,7 +73,7 @@ char* poll_support="poll" ; /*! supported poll methods */ -char* poll_method_str[POLL_END]={ "none", "poll", "epoll_lt", "epoll_et", +char* poll_method_str[POLL_END]={ "none", "poll", "epoll", "sigio_rt", "select", "kqueue", "/dev/poll" }; @@ -377,8 +377,7 @@ char* check_poll_method(enum poll_types poll_method) ret="select not supported, try re-compiling with -DHAVE_SELECT"; #endif break; - case POLL_EPOLL_LT: - case POLL_EPOLL_ET: + case POLL_EPOLL: #ifndef HAVE_EPOLL ret="epoll not supported, try re-compiling with -DHAVE_EPOLL"; #else @@ -448,7 +447,7 @@ enum poll_types choose_poll_method(void) poll_method=0; #ifdef HAVE_EPOLL if (os_ver>=0x020542) /* if ver >= 2.5.66 */ - poll_method=POLL_EPOLL_LT; /* or POLL_EPOLL_ET */ + poll_method=POLL_EPOLL; #endif #ifdef HAVE_KQUEUE @@ -511,11 +510,6 @@ enum poll_types get_poll_type(char* s) if ((strlen(poll_method_str[r])==l) && (strncasecmp(poll_method_str[r], s, l)==0)) break; - if (r == POLL_EPOLL_ET) { - LM_WARN("epoll_et method is deprecated and will be completely removed " - "in future versions! Using epoll_lt instead of epoll_et!\n"); - r = POLL_EPOLL_LT; - } return r; } @@ -623,8 +617,7 @@ int init_io_wait(io_wait_h* h, char *name, int max_fd, break; #endif #ifdef HAVE_EPOLL - case POLL_EPOLL_LT: - case POLL_EPOLL_ET: + case POLL_EPOLL: h->ep_array=local_malloc(sizeof(*(h->ep_array))*h->max_fd_no); if (h->ep_array==0){ LM_CRIT("could not alloc epoll array\n"); @@ -681,8 +674,7 @@ void destroy_io_wait(io_wait_h* h) { switch(h->poll_method){ #ifdef HAVE_EPOLL - case POLL_EPOLL_LT: - case POLL_EPOLL_ET: + case POLL_EPOLL: destroy_epoll(h); if (h->ep_array){ local_free(h->ep_array); diff --git a/io_wait.h b/io_wait.h index f573b0b008b..bb71d13639b 100644 --- a/io_wait.h +++ b/io_wait.h @@ -486,7 +486,7 @@ inline static int io_watch_add( io_wait_h* h, break; #endif #ifdef HAVE_EPOLL - case POLL_EPOLL_LT: + case POLL_EPOLL: ep_event.data.ptr=e; ep_event.events=0; if (e->flags & IO_WATCH_READ) @@ -524,43 +524,6 @@ inline static int io_watch_add( io_wait_h* h, } } break; - case POLL_EPOLL_ET: - set_fd_flags(O_NONBLOCK); - ep_event.events=EPOLLET; - ep_event.data.ptr=e; - if (e->flags & IO_WATCH_READ) - ep_event.events|=EPOLLIN; - if (e->flags & IO_WATCH_WRITE) - ep_event.events|=EPOLLOUT; -again2: - if (!already) { -#if 0 -/* disabled due to the same reason explained above */ -#if (defined __OS_linux) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 24) - if (e->flags & IO_WATCH_READ) - ep_event.events|=EPOLLEXCLUSIVE; -#endif -#endif - n=epoll_ctl(h->epfd, EPOLL_CTL_ADD, fd, &ep_event); - if (n==-1){ - if (errno==EAGAIN) goto again2; - LM_ERR("[%s] epoll_ctl failed: %s [%d]\n", - h->name,strerror(errno), errno); - goto error; - } - //check_io=1; FIXME - } else { -again22: - n=epoll_ctl(h->epfd, EPOLL_CTL_MOD, fd, &ep_event); - if (n==-1){ - if (errno==EAGAIN) goto again22; - LM_ERR("[%s] epoll_ctl failed: %s [%d]\n", - h->name,strerror(errno), errno); - goto error; - } - } - //idx=-1; FIXME - break; #endif #ifdef HAVE_KQUEUE case POLL_KQUEUE: @@ -754,8 +717,7 @@ inline static int io_watch_del(io_wait_h* h, int fd, int idx, break; #endif #ifdef HAVE_EPOLL - case POLL_EPOLL_LT: - case POLL_EPOLL_ET: + case POLL_EPOLL: /* epoll doesn't seem to automatically remove sockets, * if the socket is a dupplicate/moved and the original * is still open. The fd is removed from the epoll set diff --git a/poll_types.h b/poll_types.h index 4f7067d088e..12b930a295a 100644 --- a/poll_types.h +++ b/poll_types.h @@ -28,7 +28,7 @@ #ifndef _poll_types_h #define _poll_types_h -enum poll_types { POLL_NONE, POLL_POLL, POLL_EPOLL_LT, POLL_EPOLL_ET, +enum poll_types { POLL_NONE, POLL_POLL, POLL_EPOLL, POLL_SIGIO_RT, POLL_SELECT, POLL_KQUEUE, POLL_DEVPOLL, POLL_END}; diff --git a/reactor.h b/reactor.h index bd67f0df06f..d459595718a 100644 --- a/reactor.h +++ b/reactor.h @@ -69,17 +69,11 @@ #ifdef HAVE_EPOLL #define reactor_EPOLL_CASE(_timeout,_loop_extra) \ - case POLL_EPOLL_LT: \ + case POLL_EPOLL: \ while(1){ \ io_wait_loop_epoll(&_worker_io, _timeout, 0); \ _loop_extra;\ } \ - break; \ - case POLL_EPOLL_ET: \ - while(1){ \ - io_wait_loop_epoll(&_worker_io, _timeout, 1); \ - _loop_extra;\ - } \ break; #else #define reactor_EPOLL_CASE(_timeout,_loop_extra) diff --git a/reactor_defs.h b/reactor_defs.h index c913b38cab9..b361a7cd32c 100644 --- a/reactor_defs.h +++ b/reactor_defs.h @@ -96,7 +96,7 @@ int init_reactor_size(void); destroy_io_wait(&_worker_io) #define reactor_has_async() \ - (io_poll_method==POLL_POLL || io_poll_method==POLL_EPOLL_LT || io_poll_method==POLL_EPOLL_ET) + (io_poll_method==POLL_POLL || io_poll_method==POLL_EPOLL) #endif