diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2021-02-18 12:43:00 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2021-02-24 19:46:30 +0300 |
commit | 7bbbcd63f987b5451a29d3e084e045fc2ba1d14a (patch) | |
tree | 74757c1b21f6e5569adebd7afe36a4baceddba43 | |
parent | bb2e08b619778e30e5ce409c95d2923e23a9c5ef (diff) | |
download | libmicrohttpd-7bbbcd63f987b5451a29d3e084e045fc2ba1d14a.tar.gz libmicrohttpd-7bbbcd63f987b5451a29d3e084e045fc2ba1d14a.zip |
SIGPIPE macros minor refactoring
-rw-r--r-- | src/microhttpd/connection.c | 6 | ||||
-rw-r--r-- | src/microhttpd/daemon.c | 14 | ||||
-rw-r--r-- | src/microhttpd/mhd_send.c | 11 | ||||
-rw-r--r-- | src/microhttpd/mhd_sockets.h | 13 |
4 files changed, 28 insertions, 16 deletions
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c index f7d25962..25788414 100644 --- a/src/microhttpd/connection.c +++ b/src/microhttpd/connection.c | |||
@@ -3977,9 +3977,11 @@ MHD_queue_response (struct MHD_Connection *connection, | |||
3977 | if ( (response->fd == -1) || | 3977 | if ( (response->fd == -1) || |
3978 | (response->is_pipe) || | 3978 | (response->is_pipe) || |
3979 | (0 != (connection->daemon->options & MHD_USE_TLS)) | 3979 | (0 != (connection->daemon->options & MHD_USE_TLS)) |
3980 | #if ! defined(MHD_WINSOCK_SOCKETS) && defined(HAVE_SEND_SIGPIPE_SUPPRESS) | 3980 | #if defined(MHD_SEND_SPIPE_SUPPRESS_NEEDED) && \ |
3981 | defined(MHD_SEND_SPIPE_SUPPRESS_POSSIBLE) | ||
3981 | || (! daemon->sigpipe_blocked && ! connection->sk_spipe_suppress) | 3982 | || (! daemon->sigpipe_blocked && ! connection->sk_spipe_suppress) |
3982 | #endif /* ! MHD_WINSOCK_SOCKETS && ! HAVE_SEND_SIGPIPE_SUPPRESS */ | 3983 | #endif /* MHD_SEND_SPIPE_SUPPRESS_NEEDED && |
3984 | MHD_SEND_SPIPE_SUPPRESS_POSSIBLE */ | ||
3983 | ) | 3985 | ) |
3984 | connection->resp_sender = MHD_resp_sender_std; | 3986 | connection->resp_sender = MHD_resp_sender_std; |
3985 | else | 3987 | else |
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index cae031bd..bcf1a014 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c | |||
@@ -2243,7 +2243,9 @@ static void | |||
2243 | MHD_cleanup_connections (struct MHD_Daemon *daemon); | 2243 | MHD_cleanup_connections (struct MHD_Daemon *daemon); |
2244 | 2244 | ||
2245 | #if defined(HTTPS_SUPPORT) | 2245 | #if defined(HTTPS_SUPPORT) |
2246 | #if ! defined(MHD_WINSOCK_SOCKETS) && ! defined(MHD_socket_nosignal_) && \ | 2246 | #if defined(MHD_SEND_SPIPE_SUPPRESS_NEEDED) && \ |
2247 | defined(MHD_SEND_SPIPE_SUPPRESS_POSSIBLE) && \ | ||
2248 | ! defined(MHD_socket_nosignal_) && \ | ||
2247 | (GNUTLS_VERSION_NUMBER + 0 < 0x030402) && defined(MSG_NOSIGNAL) | 2249 | (GNUTLS_VERSION_NUMBER + 0 < 0x030402) && defined(MSG_NOSIGNAL) |
2248 | /** | 2250 | /** |
2249 | * Older version of GnuTLS do not support suppressing of SIGPIPE signal. | 2251 | * Older version of GnuTLS do not support suppressing of SIGPIPE signal. |
@@ -2251,8 +2253,10 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon); | |||
2251 | * and if possible. | 2253 | * and if possible. |
2252 | */ | 2254 | */ |
2253 | #define MHD_TLSLIB_NEED_PUSH_FUNC 1 | 2255 | #define MHD_TLSLIB_NEED_PUSH_FUNC 1 |
2254 | #endif \ | 2256 | #endif /* MHD_SEND_SPIPE_SUPPRESS_NEEDED && |
2255 | /* !MHD_WINSOCK_SOCKETS && !MHD_socket_nosignal_ && (GNUTLS_VERSION_NUMBER+0 < 0x030402) */ | 2257 | MHD_SEND_SPIPE_SUPPRESS_POSSIBLE && |
2258 | ! MHD_socket_nosignal_ && (GNUTLS_VERSION_NUMBER+0 < 0x030402) && | ||
2259 | MSG_NOSIGNAL */ | ||
2256 | 2260 | ||
2257 | #ifdef MHD_TLSLIB_NEED_PUSH_FUNC | 2261 | #ifdef MHD_TLSLIB_NEED_PUSH_FUNC |
2258 | /** | 2262 | /** |
@@ -7740,8 +7744,8 @@ MHD_is_feature_supported (enum MHD_FEATURE feature) | |||
7740 | return MHD_NO; | 7744 | return MHD_NO; |
7741 | #endif | 7745 | #endif |
7742 | case MHD_FEATURE_AUTOSUPPRESS_SIGPIPE: | 7746 | case MHD_FEATURE_AUTOSUPPRESS_SIGPIPE: |
7743 | #if defined(MHD_WINSOCK_SOCKETS) || defined(MHD_socket_nosignal_) || \ | 7747 | #if defined(MHD_SEND_SPIPE_SUPPRESS_POSSIBLE) && \ |
7744 | defined (MSG_NOSIGNAL) | 7748 | defined(MHD_SEND_SPIPE_SUPPRESS_NEEDED) |
7745 | return MHD_YES; | 7749 | return MHD_YES; |
7746 | #else | 7750 | #else |
7747 | return MHD_NO; | 7751 | return MHD_NO; |
diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c index ac11b693..0d979c0a 100644 --- a/src/microhttpd/mhd_send.c +++ b/src/microhttpd/mhd_send.c | |||
@@ -812,13 +812,14 @@ MHD_send_hdr_and_body_ (struct MHD_Connection *connection, | |||
812 | #ifdef HTTPS_SUPPORT | 812 | #ifdef HTTPS_SUPPORT |
813 | no_vec = no_vec || (connection->daemon->options & MHD_USE_TLS); | 813 | no_vec = no_vec || (connection->daemon->options & MHD_USE_TLS); |
814 | #endif /* HTTPS_SUPPORT */ | 814 | #endif /* HTTPS_SUPPORT */ |
815 | #if ! defined(MHD_WINSOCK_SOCKETS) && \ | 815 | #if (! defined(HAVE_SENDMSG) || ! defined(MSG_NOSIGNAL) ) && \ |
816 | (! defined(HAVE_SENDMSG) || ! defined(MSG_NOSIGNAL)) && \ | 816 | defined(MHD_SEND_SPIPE_SEND_SUPPRESS_POSSIBLE) && \ |
817 | defined(HAVE_SEND_SIGPIPE_SUPPRESS) | 817 | defined(MHD_SEND_SPIPE_SUPPRESS_NEEDED) |
818 | no_vec = no_vec || (! connection->daemon->sigpipe_blocked && | 818 | no_vec = no_vec || (! connection->daemon->sigpipe_blocked && |
819 | ! connection->sk_spipe_suppress); | 819 | ! connection->sk_spipe_suppress); |
820 | #endif /* !MHD_WINSOCK_SOCKETS && (!HAVE_SENDMSG || ! MSG_NOSIGNAL) | 820 | #endif /* (!HAVE_SENDMSG || ! MSG_NOSIGNAL) && |
821 | && !HAVE_SEND_SIGPIPE_SUPPRESS */ | 821 | MHD_SEND_SPIPE_SEND_SUPPRESS_POSSIBLE && |
822 | MHD_SEND_SPIPE_SUPPRESS_NEEDED */ | ||
822 | #endif /* _MHD_USE_SEND_VEC */ | 823 | #endif /* _MHD_USE_SEND_VEC */ |
823 | 824 | ||
824 | mhd_assert ( (NULL != body) || (0 == body_size) ); | 825 | mhd_assert ( (NULL != body) || (0 == body_size) ); |
diff --git a/src/microhttpd/mhd_sockets.h b/src/microhttpd/mhd_sockets.h index d4f21690..c22a1b12 100644 --- a/src/microhttpd/mhd_sockets.h +++ b/src/microhttpd/mhd_sockets.h | |||
@@ -934,17 +934,22 @@ static const int _MHD_socket_int_one = 1; | |||
934 | #endif /* SOL_SOCKET && SO_NOSIGPIPE */ | 934 | #endif /* SOL_SOCKET && SO_NOSIGPIPE */ |
935 | 935 | ||
936 | 936 | ||
937 | #if defined(MHD_WINSOCK_SOCKETS) || defined(MHD_socket_nosignal_) || \ | 937 | #if defined(MHD_socket_nosignal_) || defined(MSG_NOSIGNAL) |
938 | defined(MSG_NOSIGNAL) | ||
939 | /** | 938 | /** |
940 | * Indicate that SIGPIPE can be suppressed for normal send() by flags | 939 | * Indicate that SIGPIPE can be suppressed by MHD for normal send() by flags |
941 | * or socket options. | 940 | * or socket options. |
942 | * If this macro is undefined, MHD cannot suppress SIGPIPE for normal | 941 | * If this macro is undefined, MHD cannot suppress SIGPIPE for normal |
943 | * processing so sendfile() or writev() calls is not avoided. | 942 | * processing so sendfile() or writev() calls is not avoided. |
944 | */ | 943 | */ |
945 | #define HAVE_SEND_SIGPIPE_SUPPRESS 1 | 944 | #define MHD_SEND_SPIPE_SUPPRESS_POSSIBLE 1 |
946 | #endif /* MHD_WINSOCK_SOCKETS || MHD_socket_nosignal_ || MSG_NOSIGNAL */ | 945 | #endif /* MHD_WINSOCK_SOCKETS || MHD_socket_nosignal_ || MSG_NOSIGNAL */ |
947 | 946 | ||
947 | #if ! defined(MHD_WINSOCK_SOCKETS) | ||
948 | /** | ||
949 | * Indicate that suppression of SIGPIPE is required. | ||
950 | */ | ||
951 | #define MHD_SEND_SPIPE_SUPPRESS_NEEDED 1 | ||
952 | #endif | ||
948 | 953 | ||
949 | /** | 954 | /** |
950 | * Create a listen socket, with noninheritable flag if possible. | 955 | * Create a listen socket, with noninheritable flag if possible. |