aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/setup.h25
-rw-r--r--lib/transfer.c4
2 files changed, 19 insertions, 10 deletions
diff --git a/lib/setup.h b/lib/setup.h
index ada3bfb88..a2d039268 100644
--- a/lib/setup.h
+++ b/lib/setup.h
@@ -116,6 +116,15 @@ defined(HAVE_LIBSSL) && defined(HAVE_LIBCRYPTO)
#endif
#endif
+#ifdef HAVE_MSG_NOSIGNAL
+/* If we have the MSG_NOSIGNAL define, we make sure to use that in the forth
+ argument to send() and recv() */
+#define SEND_4TH_ARG MSG_NOSIGNAL
+#else
+#define SEND_4TH_ARG 0
+#endif
+
+
/* Below we define four functions. They should
1. close a socket
2. read from a socket
@@ -139,14 +148,14 @@ defined(HAVE_LIBSSL) && defined(HAVE_LIBCRYPTO)
#if !defined(__GNUC__) || defined(__MINGW32__)
#define sclose(x) closesocket(x)
-#define sread(x,y,z) recv(x,y,z,0)
-#define swrite(x,y,z) (size_t)send(x,y,z,0)
+#define sread(x,y,z) recv(x,y,z, SEND_4TH_ARG)
+#define swrite(x,y,z) (size_t)send(x,y,z, SEND_4TH_ARG)
#undef HAVE_ALARM
#else
/* gcc-for-win is still good :) */
#define sclose(x) close(x)
-#define sread(x,y,z) recv(x,y,z,0)
-#define swrite(x,y,z) send(x,y,z,0)
+#define sread(x,y,z) recv(x,y,z, SEND_4TH_ARG)
+#define swrite(x,y,z) send(x,y,z, SEND_4TH_ARG)
#define HAVE_ALARM
#endif
@@ -171,12 +180,12 @@ defined(HAVE_LIBSSL) && defined(HAVE_LIBCRYPTO)
#ifdef __BEOS__
#define sclose(x) closesocket(x)
-#define sread(x,y,z) (ssize_t)recv(x,y,z,0)
-#define swrite(x,y,z) (ssize_t)send(x,y,z,0)
+#define sread(x,y,z) (ssize_t)recv(x,y,z, SEND_4TH_ARG)
+#define swrite(x,y,z) (ssize_t)send(x,y,z, SEND_4TH_ARG)
#else
#define sclose(x) close(x)
-#define sread(x,y,z) recv(x,y,z,0)
-#define swrite(x,y,z) send(x,y,z,0)
+#define sread(x,y,z) recv(x,y,z, SEND_4TH_ARG)
+#define swrite(x,y,z) send(x,y,z, SEND_4TH_ARG)
#endif
#define HAVE_ALARM
diff --git a/lib/transfer.c b/lib/transfer.c
index 81a52a590..15c74c951 100644
--- a/lib/transfer.c
+++ b/lib/transfer.c
@@ -1457,7 +1457,7 @@ CURLcode Curl_pretransfer(struct SessionHandle *data)
* different ports! */
data->state.allow_port = TRUE;
-#if defined(HAVE_SIGNAL) && defined(SIGPIPE)
+#if defined(HAVE_SIGNAL) && defined(SIGPIPE) && !defined(HAVE_MSG_NOSIGNAL)
/*************************************************************
* Tell signal handler to ignore SIGPIPE
*************************************************************/
@@ -1473,7 +1473,7 @@ CURLcode Curl_pretransfer(struct SessionHandle *data)
CURLcode Curl_posttransfer(struct SessionHandle *data)
{
-#if defined(HAVE_SIGNAL) && defined(SIGPIPE)
+#if defined(HAVE_SIGNAL) && defined(SIGPIPE) && !defined(HAVE_MSG_NOSIGNAL)
/* restore the signal handler for SIGPIPE before we get back */
if(!data->set.no_signal)
signal(SIGPIPE, data->state.prev_signal);