summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-04-10 15:21:06 -0700
committerGarrett D'Amore <garrett@damore.org>2018-04-10 15:40:07 -0700
commitffcdd17d15ed7ca1ad4346f81bc96f8584ed3c9c (patch)
tree8a07b607db4138e445d506f1796aa23f9e5a6370 /src
parent3fb40d4792ba2f7b681d636957cf76d721084a0e (diff)
downloadnng-ffcdd17d15ed7ca1ad4346f81bc96f8584ed3c9c.tar.gz
nng-ffcdd17d15ed7ca1ad4346f81bc96f8584ed3c9c.tar.bz2
nng-ffcdd17d15ed7ca1ad4346f81bc96f8584ed3c9c.zip
fixes #338 possible SIGPIPE on Linux
Diffstat (limited to 'src')
-rw-r--r--src/platform/posix/posix_pipedesc.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/platform/posix/posix_pipedesc.c b/src/platform/posix/posix_pipedesc.c
index d3c46f2d..aebea4b8 100644
--- a/src/platform/posix/posix_pipedesc.c
+++ b/src/platform/posix/posix_pipedesc.c
@@ -67,17 +67,20 @@ nni_posix_pipedesc_dowrite(nni_posix_pipedesc *pd)
nni_aio *aio;
while ((aio = nni_list_first(&pd->writeq)) != NULL) {
- unsigned i;
- int n;
- int niov;
- unsigned naiov;
- nni_iov *aiov;
+ unsigned i;
+ int n;
+ int niov;
+ unsigned naiov;
+ nni_iov * aiov;
+ struct msghdr hdr;
#ifdef NNG_HAVE_ALLOCA
struct iovec *iovec;
#else
struct iovec iovec[16];
#endif
+ memset(&hdr, 0, sizeof(hdr));
+
nni_aio_get_iov(aio, &naiov, &aiov);
#ifdef NNG_HAVE_ALLOCA
@@ -101,7 +104,14 @@ nni_posix_pipedesc_dowrite(nni_posix_pipedesc *pd)
}
}
- n = writev(pd->node.fd, iovec, niov);
+#ifndef MSG_NOSIGNAL
+#define MSG_NOSIGNAL 0
+#endif
+
+ hdr.msg_iovlen = niov;
+ hdr.msg_iov = iovec;
+
+ n = sendmsg(pd->node.fd, &hdr, MSG_NOSIGNAL);
if (n < 0) {
if ((errno == EAGAIN) || (errno == EINTR)) {
// Can't write more right now. We're done