]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Fix ESL infinite loop on handle_recv() when errno is already set
authorMoises Silva <moy@sangoma.com>
Wed, 29 Jan 2014 00:07:34 +0000 (19:07 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Fri, 31 Jan 2014 20:40:45 +0000 (01:40 +0500)
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

index cdfdc5ef37310e2ef9d3c10c0731930f696eba6f..e4fb79ba6c8fee4d8ec399506623435129c9cc48 100644 (file)
@@ -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;
                                }
                        }