From: Willy Tarreau Date: Mon, 20 Jan 2014 20:21:30 +0000 (+0100) Subject: MEDIUM: listener: fix polling management in the accept loop X-Git-Tag: v1.5-dev22~62 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a593ec5bf4ac58e7489535eb256f4763ac8027ff;p=thirdparty%2Fhaproxy.git MEDIUM: listener: fix polling management in the accept loop The accept loop used to force fd_poll_recv() even in places where it was not completely appropriate (eg: unexpected errors). It does not yet cause trouble but will do with the upcoming polling changes. Let's use it only where relevant now. EINTR/ECONNABORTED do not result in poll() anymore but the failed connection is simply skipped (this code dates from 1.1.32 when error codes were first considered). --- diff --git a/src/listener.c b/src/listener.c index e5e723f457..c9418178ff 100644 --- a/src/listener.c +++ b/src/listener.c @@ -324,10 +324,11 @@ void listener_accept(int fd) if (unlikely(cfd == -1)) { switch (errno) { case EAGAIN: - case EINTR: - case ECONNABORTED: fd_poll_recv(fd); return; /* nothing more to accept */ + case EINTR: + case ECONNABORTED: + continue; case ENFILE: if (p) send_log(p, LOG_EMERG, @@ -354,8 +355,7 @@ void listener_accept(int fd) task_schedule(global_listener_queue_task, tick_add(now_ms, 100)); /* try again in 100 ms */ return; default: - /* unexpected result, let's go back to poll */ - fd_poll_recv(fd); + /* unexpected result, let's give up and let other tasks run */ return; } }