gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libmicrohttpd] 05/05: test_client_put_stop: suppress SIGPIPE on the cli


From: gnunet
Subject: [libmicrohttpd] 05/05: test_client_put_stop: suppress SIGPIPE on the client side
Date: Sun, 28 Nov 2021 17:44:38 +0100

This is an automated email from the git hooks/post-receive script.

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

commit ff12c57202765ee6bdd27cb693070ffc49327057
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Sun Nov 28 19:41:46 2021 +0300

    test_client_put_stop: suppress SIGPIPE on the client side
---
 src/microhttpd/test_client_put_stop.c | 27 +++++++++++++++++++++++----
 1 file 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 @@
 #include <limits.h>
 #endif /* HAVE_LIMITS_H */
 
+#ifdef HAVE_SIGNAL_H
+#include <signal.h>
+#endif /* HAVE_SIGNAL_H */
+
 #include "mhd_sockets.h" /* only macros used */
 #include "test_helpers.h"
 #include "mhd_assert.h"
@@ -194,6 +198,16 @@ static int upl_chunked;             /**< Use chunked 
encoding for request body *
 static void
 test_global_init (void)
 {
+  if (MHD_YES != MHD_is_feature_supported (MHD_FEATURE_AUTOSUPPRESS_SIGPIPE))
+  {
+#if defined(HAVE_SIGNAL_H) && defined(SIGPIPE)
+    if (SIG_ERR == signal (SIGPIPE, SIG_IGN))
+      externalErrorExitDesc ("Error suppressing SIGPIPE signal");
+#else /* ! HAVE_SIGNAL_H || ! SIGPIPE */
+    fprintf (stderr, "Cannot suppress SIGPIPE signal.\n");
+    /* exit (77); */
+#endif
+  }
 }
 
 
@@ -319,8 +333,13 @@ _MHD_dumbClient_create (unsigned int port, const char 
*method, const char *url,
   clnt->sckt = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
   if (MHD_INVALID_SOCKET == clnt->sckt)
     externalErrorExitDesc ("Cannot create the client socket");
-  clnt->sckt_nonblock = 0;
 
+#ifdef MHD_socket_nosignal_
+  if (! MHD_socket_nosignal_ (clnt->sckt))
+    externalErrorExitDesc ("Cannot suppress SIGPIPE on the client socket");
+#endif /* MHD_socket_nosignal_ */
+
+  clnt->sckt_nonblock = 0;
   if (clnt->sckt_nonblock)
     make_nonblocking (clnt->sckt);
   else
@@ -537,8 +556,7 @@ _MHD_dumbClient_send_req (struct _MHD_dumbClient *clnt)
       (clnt->single_send_size < send_size))
     send_size = clnt->single_send_size;
 
-  res = send (clnt->sckt, (const void *) (clnt->send_buf + clnt->send_off),
-              send_size, 0);
+  res = MHD_send_ (clnt->sckt, clnt->send_buf + clnt->send_off, send_size);
 
   if (res < 0)
   {
@@ -1723,7 +1741,8 @@ main (int argc, char *const *argv)
 #endif /* ! SO_LINGER */
   if (1 != use_shutdown + use_close)
     return 99;
-  verbose = ! has_param (argc, argv, "-q") || has_param (argc, argv, 
"--quiet");
+  verbose =
+    ! (has_param (argc, argv, "-q") || has_param (argc, argv, "--quiet"));
 
   test_global_init ();
 

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]