From 3eb27f970d5d45f3c5737fdaf7b660bedaab1710 Mon Sep 17 00:00:00 2001 From: Moises Silva Date: Tue, 28 Jan 2014 19:07:34 -0500 Subject: [PATCH] Fix ESL infinite loop on handle_recv() when errno is already set system calls do not clear errno, just set it in case of failure, so we gotta make sure the recv() syscall really failed by checking the return value --- libs/esl/src/esl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/esl/src/esl.c b/libs/esl/src/esl.c index cdfdc5ef37..e4fb79ba6c 100644 --- a/libs/esl/src/esl.c +++ b/libs/esl/src/esl.c @@ -1233,7 +1233,7 @@ static esl_ssize_t handle_recv(esl_handle_t *handle, void *data, esl_size_t data } else if ((activity & ESL_POLL_READ)) { if (!(activity = recv(handle->sock, data, datalen, 0))) { activity = -1; - } else if (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK) { + } else if (activity < 0 && (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK)) { activity = 0; } }