diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2016-10-23 22:28:15 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2016-10-24 15:51:29 +0300 |
commit | aa4da2538f101e1070b35dae41323197166fb21c (patch) | |
tree | 445ba3ee09cc45b8002632a3c3f3c2973c1a9ce6 | |
parent | 08c81c49061149a4d47787058c5be84f52c60af0 (diff) | |
download | libmicrohttpd-aa4da2538f101e1070b35dae41323197166fb21c.tar.gz libmicrohttpd-aa4da2538f101e1070b35dae41323197166fb21c.zip |
Upgrade: use socketpair only in non-blocking mode
-rw-r--r-- | src/microhttpd/response.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c index 9164d477..09e73f9b 100644 --- a/src/microhttpd/response.c +++ b/src/microhttpd/response.c | |||
@@ -742,10 +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_) | 745 | #if defined(MHD_socket_nosignal_) || !defined(MHD_socket_pair_nblk_) |
746 | int res1; | 746 | int res1; |
747 | int res2; | 747 | int res2; |
748 | #endif /* MHD_socket_nosignal_ */ | 748 | #endif /* MHD_socket_nosignal_ || !MHD_socket_pair_nblk_ */ |
749 | 749 | ||
750 | #ifdef MHD_socket_pair_nblk_ | 750 | #ifdef MHD_socket_pair_nblk_ |
751 | if (! MHD_socket_pair_nblk_ (sv)) | 751 | if (! MHD_socket_pair_nblk_ (sv)) |
@@ -759,14 +759,22 @@ MHD_response_execute_upgrade_ (struct MHD_Response *response, | |||
759 | free (urh); | 759 | free (urh); |
760 | return MHD_NO; | 760 | return MHD_NO; |
761 | } | 761 | } |
762 | if ( (! MHD_socket_nonblocking_(sv[0])) || | 762 | res1 = MHD_socket_nonblocking_(sv[0]); |
763 | (! MHD_socket_nonblocking_(sv[1])) ) | 763 | res2 = MHD_socket_nonblocking_(sv[1]); |
764 | if ( (! res1) || (! res2) ) | ||
764 | { | 765 | { |
765 | #ifdef HAVE_MESSAGES | 766 | #ifdef HAVE_MESSAGES |
766 | MHD_DLOG (daemon, | 767 | MHD_DLOG (daemon, |
767 | _("Failed to make loopback sockets non-blocking: %s\n"), | 768 | _("Failed to make loopback sockets non-blocking.\n")); |
768 | MHD_socket_last_strerr_ ()); | ||
769 | #endif | 769 | #endif |
770 | if (! res2) | ||
771 | { | ||
772 | /* Socketpair cannot be used. */ | ||
773 | MHD_socket_close_chk_ (sv[0]); | ||
774 | MHD_socket_close_chk_ (sv[1]); | ||
775 | free (urh); | ||
776 | return MHD_NO; | ||
777 | } | ||
770 | } | 778 | } |
771 | #endif /* !MHD_socket_pair_nblk_ */ | 779 | #endif /* !MHD_socket_pair_nblk_ */ |
772 | #ifdef MHD_socket_nosignal_ | 780 | #ifdef MHD_socket_nosignal_ |