summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2015-09-28 19:33:09 +0200
committerantirez <antirez@gmail.com>2015-09-30 16:29:42 +0200
commit063ecbd5e59d536d2db661c2953eaef016a60ee7 (patch)
treefe033e2a86906bbe708846dcf8555c1341cf6a93
parentb741a90ce9a7e0ff4e98523a49947a9ec545a62f (diff)
downloadredis-063ecbd5e59d536d2db661c2953eaef016a60ee7.tar.gz
writeToClient(): don't remove write handler if not needed.
-rw-r--r--src/networking.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/networking.c b/src/networking.c
index d37663641..9d4c94d28 100644
--- a/src/networking.c
+++ b/src/networking.c
@@ -818,7 +818,7 @@ void freeClientsInAsyncFreeQueue(void) {
/* Write data in output buffers to client. Return C_OK if the client
* is still valid after the call, C_ERR if it was freed. */
-int writeToClient(int fd, client *c) {
+int writeToClient(int fd, client *c, int handler_installed) {
ssize_t nwritten = 0, totwritten = 0;
size_t objlen;
size_t objmem;
@@ -892,7 +892,7 @@ int writeToClient(int fd, client *c) {
}
if (c->bufpos == 0 && listLength(c->reply) == 0) {
c->sentlen = 0;
- aeDeleteFileEvent(server.el,c->fd,AE_WRITABLE);
+ if (handler_installed) aeDeleteFileEvent(server.el,c->fd,AE_WRITABLE);
/* Close connection after entire reply has been sent. */
if (c->flags & CLIENT_CLOSE_AFTER_REPLY) {
@@ -907,7 +907,7 @@ int writeToClient(int fd, client *c) {
void sendReplyToClient(aeEventLoop *el, int fd, void *privdata, int mask) {
UNUSED(el);
UNUSED(mask);
- writeToClient(fd,privdata);
+ writeToClient(fd,privdata,1);
}
/* This function is called just before entering the event loop, in the hope
@@ -925,7 +925,7 @@ void handleClientsWithPendingWrites(void) {
listDelNode(server.clients_pending_write,ln);
/* Try to write buffers to the client socket. */
- if (writeToClient(c->fd,c) == C_ERR) continue;
+ if (writeToClient(c->fd,c,0) == C_ERR) continue;
/* If there is nothing left, do nothing. Otherwise install
* the write handler. */