aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2016-10-23 22:23:34 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2016-10-24 15:51:29 +0300
commit08c81c49061149a4d47787058c5be84f52c60af0 (patch)
treedb1e763c1101a13d4c2e33ddd0932076d6e1c42d
parenta41dc5dce6553e422959def98e6787909a31bdc5 (diff)
downloadlibmicrohttpd-08c81c49061149a4d47787058c5be84f52c60af0.tar.gz
libmicrohttpd-08c81c49061149a4d47787058c5be84f52c60af0.zip
Upgrade: fixed SO_NOSIGPIPE on socketpair.
-rw-r--r--src/microhttpd/response.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c
index 97b131cd..9164d477 100644
--- a/src/microhttpd/response.c
+++ b/src/microhttpd/response.c
@@ -742,6 +742,10 @@ MHD_response_execute_upgrade_ (struct MHD_Response *response,
742 size_t avail; 742 size_t avail;
743 char *buf; 743 char *buf;
744 MHD_socket sv[2]; 744 MHD_socket sv[2];
745#if defined(MHD_socket_nosignal_)
746 int res1;
747 int res2;
748#endif /* MHD_socket_nosignal_ */
745 749
746#ifdef MHD_socket_pair_nblk_ 750#ifdef MHD_socket_pair_nblk_
747 if (! MHD_socket_pair_nblk_ (sv)) 751 if (! MHD_socket_pair_nblk_ (sv))
@@ -765,6 +769,27 @@ MHD_response_execute_upgrade_ (struct MHD_Response *response,
765#endif 769#endif
766 } 770 }
767#endif /* !MHD_socket_pair_nblk_ */ 771#endif /* !MHD_socket_pair_nblk_ */
772#ifdef MHD_socket_nosignal_
773 res1 = MHD_socket_nosignal_(sv[0]);
774 res2 = MHD_socket_nosignal_(sv[1]);
775 if ( (! res1) || (! res2) )
776 {
777#ifdef HAVE_MESSAGES
778 MHD_DLOG (daemon,
779 _("Failed to set SO_NOSIGPIPE on loopback sockets.\n"));
780#endif
781#ifndef MSG_NOSIGNAL
782 if (!res2)
783 {
784 /* Socketpair cannot be used. */
785 MHD_socket_close_chk_ (sv[0]);
786 MHD_socket_close_chk_ (sv[1]);
787 free (urh);
788 return MHD_NO;
789 }
790#endif /* ! MSG_NOSIGNAL */
791 }
792#endif /* MHD_socket_nosignal_ */
768 if ( (! MHD_SCKT_FD_FITS_FDSET_ (sv[1], 793 if ( (! MHD_SCKT_FD_FITS_FDSET_ (sv[1],
769 NULL)) && 794 NULL)) &&
770 (0 == (daemon->options & (MHD_USE_POLL | MHD_USE_EPOLL))) ) 795 (0 == (daemon->options & (MHD_USE_POLL | MHD_USE_EPOLL))) )