Skip to content

Commit

Permalink
reactor: replace epoll_lt and epoll_et \w epoll
Browse files Browse the repository at this point in the history
Remove the epoll_lt and epoll_et keyworkds and make available only
epoll, which behaves as epoll lt (Level Triggered)
  • Loading branch information
razvancrainea committed Dec 19, 2017
1 parent 9f54480 commit 1b9532c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 63 deletions.
20 changes: 6 additions & 14 deletions io_wait.c
Expand Up @@ -56,7 +56,7 @@

char* poll_support="poll"
#ifdef HAVE_EPOLL
", epoll_lt, epoll_et"
", epoll"
#endif
#ifdef HAVE_SIGIO_RT
", sigio_rt"
Expand All @@ -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"
};

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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);
Expand Down
42 changes: 2 additions & 40 deletions io_wait.h
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion poll_types.h
Expand Up @@ -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};

Expand Down
8 changes: 1 addition & 7 deletions reactor.h
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion reactor_defs.h
Expand Up @@ -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

0 comments on commit 1b9532c

Please sign in to comment.