diff options
author | Mattias Andrée <maandree@kth.se> | 2016-08-06 03:06:15 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2016-08-06 03:06:15 +0200 |
commit | bcf8b27f0003a39651f62ce45009a3e176c0a73f (patch) | |
tree | 97b2aeaed62c30271c25af28d900a59c18fb9c96 | |
parent | Fix disconnect bug (diff) | |
download | coopgammad-bcf8b27f0003a39651f62ce45009a3e176c0a73f.tar.gz coopgammad-bcf8b27f0003a39651f62ce45009a3e176c0a73f.tar.bz2 coopgammad-bcf8b27f0003a39651f62ce45009a3e176c0a73f.tar.xz |
Use MSG_NOSIGNAL when sending
Signed-off-by: Mattias Andrée <maandree@kth.se>
-rw-r--r-- | src/communication.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/communication.c b/src/communication.c index fc11ab8..9ede401 100644 --- a/src/communication.c +++ b/src/communication.c @@ -54,9 +54,11 @@ int send_message(size_t conn, char* restrict buf, size_t n) while (old_ptr < n) { sendsize = old_n - old_ptr < chunksize ? old_n - old_ptr : chunksize; - sent = send(fd, old_buf + old_ptr, sendsize, 0); + sent = send(fd, old_buf + old_ptr, sendsize, MSG_NOSIGNAL); if (sent < 0) { + if (errno == EPIPE) + errno = ECONNRESET; if (errno != EMSGSIZE) goto fail; chunksize >>= 1; @@ -72,9 +74,11 @@ int send_message(size_t conn, char* restrict buf, size_t n) while (ptr < n) { sendsize = n - ptr < chunksize ? n - ptr : chunksize; - sent = send(fd, buf + ptr, sendsize, 0); + sent = send(fd, buf + ptr, sendsize, MSG_NOSIGNAL); if (sent < 0) { + if (errno == EPIPE) + errno = ECONNRESET; if (errno != EMSGSIZE) goto fail; chunksize >>= 1; |