From bcf8b27f0003a39651f62ce45009a3e176c0a73f Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 6 Aug 2016 03:06:15 +0200 Subject: Use MSG_NOSIGNAL when sending MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/communication.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') 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; -- cgit v1.2.3-70-g09d2