From 328a85c1fe9f82bd06f2599dd18d927597353ddc Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Sat, 26 Apr 2014 09:13:26 +1000 Subject: [PATCH] Only assume clients have disconnected on an error from recv --- src/connector.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/connector.c b/src/connector.c index 07b75566..545c9777 100644 --- a/src/connector.c +++ b/src/connector.c @@ -110,11 +110,8 @@ retry: buflen = PAGESIZE - client->bufofs; ret = recv(client->fd, client->buf + client->bufofs, buflen, MSG_DONTWAIT); if (ret < 1) { - /* If we're reading on the first pass, there is supposed to be - * data waiting for us according to poll() so no data implies - * a lost connection. On repeat reads may have just read all - * the data */ - if (moredata) + /* Nothing else ready to be read */ + if (!ret) return; LOGINFO("Client fd %d disconnected", client->fd);