From bf72ebbee6f0fe9767bcce50d50cda2ab8853046 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Wed, 22 Apr 2015 19:56:24 +1000 Subject: [PATCH] Reinstate checking for zero as a return from recv for cleanly disconnected clients --- src/connector.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/connector.c b/src/connector.c index 221b808f..e2a66f36 100644 --- a/src/connector.c +++ b/src/connector.c @@ -335,8 +335,9 @@ retry: buflen = PAGESIZE - client->bufofs; ret = recv(client->fd, client->buf + client->bufofs, buflen, 0); if (ret < 1) { - if (!ret) - return; + /* We should have something to read if called since poll set + * this fd's revents status so if there's nothing it means the + * client has disconnected. */ LOGINFO("Client fd %d disconnected - recv fail with bufofs %d ret %d errno %d %s", client->fd, client->bufofs, ret, errno, ret && errno ? strerror(errno) : ""); invalidate_client(ckp, cdata, client);