summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2012-04-13 13:34:22 +0200
committerMartin Sustrik <sustrik@250bpm.com>2012-04-14 05:01:51 +0200
commit43965a1080197fcdb69eb48645f01c393171a5fb (patch)
tree20b0238988f38f53502d863c0631a7aeaf049b92
parent06329e07437f56260c2c74ba9e272bc6d484cc81 (diff)
If available, use MSG_NOSIGNAL for send()
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
-rw-r--r--src/signaler.cpp4
-rw-r--r--src/stream_engine.cpp4
2 files changed, 8 insertions, 0 deletions
diff --git a/src/signaler.cpp b/src/signaler.cpp
index 1dbd9bb..78a13b2 100644
--- a/src/signaler.cpp
+++ b/src/signaler.cpp
@@ -131,7 +131,11 @@ void xs::signaler_t::send ()
#else
unsigned char dummy = 0;
while (true) {
+#if defined MSG_NOSIGNAL
+ ssize_t nbytes = ::send (w, &dummy, sizeof (dummy), MSG_NOSIGNAL);
+#else
ssize_t nbytes = ::send (w, &dummy, sizeof (dummy), 0);
+#endif
if (unlikely (nbytes == -1 && errno == EINTR))
continue;
xs_assert (nbytes == sizeof (dummy));
diff --git a/src/stream_engine.cpp b/src/stream_engine.cpp
index ed03f59..a4df7f3 100644
--- a/src/stream_engine.cpp
+++ b/src/stream_engine.cpp
@@ -305,7 +305,11 @@ int xs::stream_engine_t::write (const void *data_, size_t size_)
#else
+#if defined MSG_NOSIGNAL
+ ssize_t nbytes = send (s, data_, size_, MSG_NOSIGNAL);
+#else
ssize_t nbytes = send (s, data_, size_, 0);
+#endif
// Several errors are OK. When speculative write is being done we may not
// be able to write a single byte from the socket. Also, SIGSTOP issued