From 6274371ccf29da046efbb18055cde9ae60a1384c Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Wed, 4 Feb 2015 23:10:59 +1100 Subject: [PATCH] Microoptimise epoll_wait call --- src/connector.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/connector.c b/src/connector.c index c002dba9..8176b0ab 100644 --- a/src/connector.c +++ b/src/connector.c @@ -413,12 +413,14 @@ void *receiver(void *arg) while (unlikely(!cdata->accept)) cksleep_ms(100); ret = epoll_wait(epfd, &event, 1, 1000); - if (unlikely(ret == -1)) { - LOGEMERG("FATAL: Failed to epoll_wait in receiver"); - break; - } - if (unlikely(!ret)) + if (unlikely(ret < 1)) { + if (unlikely(ret == -1)) { + LOGEMERG("FATAL: Failed to epoll_wait in receiver"); + break; + } + /* Nothing to service, still very unlikely */ continue; + } if (event.data.u64 < (uint64_t)serverfds) { ret = accept_client(cdata, epfd, event.data.u64); if (unlikely(ret < 0)) {