diff options
author | David Goulet <dgoulet@ev0ke.net> | 2015-01-30 15:18:40 -0500 |
---|---|---|
committer | David Goulet <dgoulet@ev0ke.net> | 2015-01-30 15:18:40 -0500 |
commit | 2c41f120481b7b14fcf0ef3aaf78d84f47178cb7 (patch) | |
tree | 31eaadd66cd2860429a466a369281f537d93681f /src/common/compat_threads.c | |
parent | 51f793e37e55b29700f76ca9cdb3199e636bb51d (diff) | |
download | tor-2c41f120481b7b14fcf0ef3aaf78d84f47178cb7.tar.gz tor-2c41f120481b7b14fcf0ef3aaf78d84f47178cb7.zip |
Fix: check r < 0 before checking errno
Signed-off-by: David Goulet <dgoulet@ev0ke.net>
Diffstat (limited to 'src/common/compat_threads.c')
-rw-r--r-- | src/common/compat_threads.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/common/compat_threads.c b/src/common/compat_threads.c index ff8dc1ca61..15648d2851 100644 --- a/src/common/compat_threads.c +++ b/src/common/compat_threads.c @@ -174,7 +174,7 @@ pipe_drain(int fd) do { r = read_ni(fd, buf, sizeof(buf)); } while (r > 0); - if (errno != EAGAIN) + if (r < 0 && errno != EAGAIN) return -1; /* A value of r = 0 means EOF on the fd so successfully drained. */ return 0; @@ -198,7 +198,7 @@ sock_drain(tor_socket_t fd) do { r = recv_ni(fd, buf, sizeof(buf), 0); } while (r > 0); - if (!ERRNO_IS_EAGAIN(tor_socket_errno(fd))) + if (r < 0 && !ERRNO_IS_EAGAIN(tor_socket_errno(fd))) return -1; /* A value of r = 0 means EOF on the fd so successfully drained. */ return 0; |