diff --git a/src/networking.c b/src/networking.c index 6dc4864b..7ec95676 100644 --- a/src/networking.c +++ b/src/networking.c @@ -938,9 +938,10 @@ void sendReplyToClient(aeEventLoop *el, int fd, void *privdata, int mask) { * we can just write the replies to the client output buffer without any * need to use a syscall in order to install the writable event handler, * get it called, and so forth. */ -void handleClientsWithPendingWrites(void) { +int handleClientsWithPendingWrites(void) { listIter li; listNode *ln; + int processed = listLength(server.clients_pending_write); listRewind(server.clients_pending_write,&li); while((ln = listNext(&li))) { @@ -960,6 +961,7 @@ void handleClientsWithPendingWrites(void) { freeClientAsync(c); } } + return processed; } /* resetClient prepare the client to process the next command */ @@ -1821,7 +1823,9 @@ int processEventsWhileBlocked(void) { int iterations = 4; /* See the function top-comment. */ int count = 0; while (iterations--) { - int events = aeProcessEvents(server.el, AE_FILE_EVENTS|AE_DONT_WAIT); + int events = 0; + events += aeProcessEvents(server.el, AE_FILE_EVENTS|AE_DONT_WAIT); + events += handleClientsWithPendingWrites(); if (!events) break; count += events; } diff --git a/src/server.h b/src/server.h index b5a24829..4c4017f7 100644 --- a/src/server.h +++ b/src/server.h @@ -1110,7 +1110,7 @@ int listenToPort(int port, int *fds, int *count); void pauseClients(mstime_t duration); int clientsArePaused(void); int processEventsWhileBlocked(void); -void handleClientsWithPendingWrites(void); +int handleClientsWithPendingWrites(void); int clientHasPendingReplies(client *c); void unlinkClient(client *c);