aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2021-11-28 19:41:46 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2021-11-28 19:44:26 +0300
commitff12c57202765ee6bdd27cb693070ffc49327057 (patch)
tree1e3b9fcc16c8601eb83a8c034aeef42f4a22cc67
parentdbf407c26a3d76a26c1a28fbb8f7b810bcdbf16f (diff)
downloadlibmicrohttpd-ff12c57202765ee6bdd27cb693070ffc49327057.tar.gz
libmicrohttpd-ff12c57202765ee6bdd27cb693070ffc49327057.zip
test_client_put_stop: suppress SIGPIPE on the client side
-rw-r--r--src/microhttpd/test_client_put_stop.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/microhttpd/test_client_put_stop.c b/src/microhttpd/test_client_put_stop.c
index 2c903f27..81afa6bd 100644
--- a/src/microhttpd/test_client_put_stop.c
+++ b/src/microhttpd/test_client_put_stop.c
@@ -50,6 +50,10 @@
50#include <limits.h> 50#include <limits.h>
51#endif /* HAVE_LIMITS_H */ 51#endif /* HAVE_LIMITS_H */
52 52
53#ifdef HAVE_SIGNAL_H
54#include <signal.h>
55#endif /* HAVE_SIGNAL_H */
56
53#include "mhd_sockets.h" /* only macros used */ 57#include "mhd_sockets.h" /* only macros used */
54#include "test_helpers.h" 58#include "test_helpers.h"
55#include "mhd_assert.h" 59#include "mhd_assert.h"
@@ -194,6 +198,16 @@ static int upl_chunked; /**< Use chunked encoding for request body *
194static void 198static void
195test_global_init (void) 199test_global_init (void)
196{ 200{
201 if (MHD_YES != MHD_is_feature_supported (MHD_FEATURE_AUTOSUPPRESS_SIGPIPE))
202 {
203#if defined(HAVE_SIGNAL_H) && defined(SIGPIPE)
204 if (SIG_ERR == signal (SIGPIPE, SIG_IGN))
205 externalErrorExitDesc ("Error suppressing SIGPIPE signal");
206#else /* ! HAVE_SIGNAL_H || ! SIGPIPE */
207 fprintf (stderr, "Cannot suppress SIGPIPE signal.\n");
208 /* exit (77); */
209#endif
210 }
197} 211}
198 212
199 213
@@ -319,8 +333,13 @@ _MHD_dumbClient_create (unsigned int port, const char *method, const char *url,
319 clnt->sckt = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); 333 clnt->sckt = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
320 if (MHD_INVALID_SOCKET == clnt->sckt) 334 if (MHD_INVALID_SOCKET == clnt->sckt)
321 externalErrorExitDesc ("Cannot create the client socket"); 335 externalErrorExitDesc ("Cannot create the client socket");
322 clnt->sckt_nonblock = 0;
323 336
337#ifdef MHD_socket_nosignal_
338 if (! MHD_socket_nosignal_ (clnt->sckt))
339 externalErrorExitDesc ("Cannot suppress SIGPIPE on the client socket");
340#endif /* MHD_socket_nosignal_ */
341
342 clnt->sckt_nonblock = 0;
324 if (clnt->sckt_nonblock) 343 if (clnt->sckt_nonblock)
325 make_nonblocking (clnt->sckt); 344 make_nonblocking (clnt->sckt);
326 else 345 else
@@ -537,8 +556,7 @@ _MHD_dumbClient_send_req (struct _MHD_dumbClient *clnt)
537 (clnt->single_send_size < send_size)) 556 (clnt->single_send_size < send_size))
538 send_size = clnt->single_send_size; 557 send_size = clnt->single_send_size;
539 558
540 res = send (clnt->sckt, (const void *) (clnt->send_buf + clnt->send_off), 559 res = MHD_send_ (clnt->sckt, clnt->send_buf + clnt->send_off, send_size);
541 send_size, 0);
542 560
543 if (res < 0) 561 if (res < 0)
544 { 562 {
@@ -1723,7 +1741,8 @@ main (int argc, char *const *argv)
1723#endif /* ! SO_LINGER */ 1741#endif /* ! SO_LINGER */
1724 if (1 != use_shutdown + use_close) 1742 if (1 != use_shutdown + use_close)
1725 return 99; 1743 return 99;
1726 verbose = ! has_param (argc, argv, "-q") || has_param (argc, argv, "--quiet"); 1744 verbose =
1745 ! (has_param (argc, argv, "-q") || has_param (argc, argv, "--quiet"));
1727 1746
1728 test_global_init (); 1747 test_global_init ();
1729 1748