From bfb90fa632a863d67f03144bf260609383c216ef Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Fri, 2 May 2014 08:25:56 +1000 Subject: [PATCH] Handle all poll revents with a recv and invalidate clients that don't respond --- src/connector.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/connector.c b/src/connector.c index e8ebdbad..78964861 100644 --- a/src/connector.c +++ b/src/connector.c @@ -162,9 +162,12 @@ retry: ret = recv(client->fd, client->buf + client->bufofs, buflen, flags); if (ret < 1) { /* Nothing else ready to be read */ - if (!ret) + if (!ret && flags) 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", client->fd); invalidate_client(ckp, ci, client); return; @@ -260,7 +263,7 @@ repoll: for (i = 0; i < nfds; i++) { int fd; - if (!(fds[i].revents & POLLIN)) + if (!fds[i].revents) continue; client = NULL;