summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2015-09-30 17:23:34 +0200
committerantirez <antirez@gmail.com>2015-09-30 17:23:44 +0200
commit01c08b508927adfb9ca6857db076c849f945e1be (patch)
tree63c6ab0662ef2efd98d4e44944f53655fcfe870b
parent1e7153831dc4b03bf6e116430aa55a87707658a7 (diff)
downloadredis-01c08b508927adfb9ca6857db076c849f945e1be.tar.gz
Fix processEventsWhileBlocked() to handle PENDING_WRITE clients.
After the introduction of the list with clients with pending writes, to process clients incrementally outside of the event loop we also need to process the pending writes list.
-rw-r--r--src/networking.c8
-rw-r--r--src/server.h2
2 files changed, 7 insertions, 3 deletions
diff --git a/src/networking.c b/src/networking.c
index 6dc4864bf..7ec956765 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 b5a248292..4c4017f7c 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);