diff options
author | Alexander Færøy <ahf@torproject.org> | 2018-12-12 18:48:45 +0100 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-12-17 16:39:28 -0500 |
commit | 0d796cce17bdda605f5e768971935d7f876e33fa (patch) | |
tree | be9dfc5191216cde72f6d22d7581bac99070a0ba /src/lib/net | |
parent | cacdd290872420d51f880d75466f6d6e22430466 (diff) | |
download | tor-0d796cce17bdda605f5e768971935d7f876e33fa.tar.gz tor-0d796cce17bdda605f5e768971935d7f876e33fa.zip |
Use errno directly if we are not reading/writing from/to a socket.
See: https://bugs.torproject.org/28179
Diffstat (limited to 'src/lib/net')
-rw-r--r-- | src/lib/net/buffers_net.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/lib/net/buffers_net.c b/src/lib/net/buffers_net.c index da7043d5cb..9430a6b8c4 100644 --- a/src/lib/net/buffers_net.c +++ b/src/lib/net/buffers_net.c @@ -51,7 +51,8 @@ read_to_chunk(buf_t *buf, chunk_t *chunk, tor_socket_t fd, size_t at_most, read_result = read(fd, CHUNK_WRITE_PTR(chunk), at_most); if (read_result < 0) { - int e = tor_socket_errno(fd); + int e = is_socket ? tor_socket_errno(fd) : errno; + if (!ERRNO_IS_EAGAIN(e)) { /* it's a real error */ #ifdef _WIN32 if (e == WSAENOBUFS) @@ -152,7 +153,8 @@ flush_chunk(tor_socket_t fd, buf_t *buf, chunk_t *chunk, size_t sz, write_result = write(fd, chunk->data, sz); if (write_result < 0) { - int e = tor_socket_errno(fd); + int e = is_socket ? tor_socket_errno(fd) : errno; + if (!ERRNO_IS_EAGAIN(e)) { /* it's a real error */ #ifdef _WIN32 if (e == WSAENOBUFS) |