libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 7bbbcd63f987b5451a29d3e084e045fc2ba1d14a
parent bb2e08b619778e30e5ce409c95d2923e23a9c5ef
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Thu, 18 Feb 2021 12:43:00 +0300

SIGPIPE macros minor refactoring

Diffstat:
Msrc/microhttpd/connection.c | 6++++--
Msrc/microhttpd/daemon.c | 14+++++++++-----
Msrc/microhttpd/mhd_send.c | 11++++++-----
Msrc/microhttpd/mhd_sockets.h | 13+++++++++----
4 files changed, 28 insertions(+), 16 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c @@ -3977,9 +3977,11 @@ MHD_queue_response (struct MHD_Connection *connection, if ( (response->fd == -1) || (response->is_pipe) || (0 != (connection->daemon->options & MHD_USE_TLS)) -#if ! defined(MHD_WINSOCK_SOCKETS) && defined(HAVE_SEND_SIGPIPE_SUPPRESS) +#if defined(MHD_SEND_SPIPE_SUPPRESS_NEEDED) && \ + defined(MHD_SEND_SPIPE_SUPPRESS_POSSIBLE) || (! daemon->sigpipe_blocked && ! connection->sk_spipe_suppress) -#endif /* ! MHD_WINSOCK_SOCKETS && ! HAVE_SEND_SIGPIPE_SUPPRESS */ +#endif /* MHD_SEND_SPIPE_SUPPRESS_NEEDED && + MHD_SEND_SPIPE_SUPPRESS_POSSIBLE */ ) connection->resp_sender = MHD_resp_sender_std; else diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c @@ -2243,7 +2243,9 @@ static void MHD_cleanup_connections (struct MHD_Daemon *daemon); #if defined(HTTPS_SUPPORT) -#if ! defined(MHD_WINSOCK_SOCKETS) && ! defined(MHD_socket_nosignal_) && \ +#if defined(MHD_SEND_SPIPE_SUPPRESS_NEEDED) && \ + defined(MHD_SEND_SPIPE_SUPPRESS_POSSIBLE) && \ + ! defined(MHD_socket_nosignal_) && \ (GNUTLS_VERSION_NUMBER + 0 < 0x030402) && defined(MSG_NOSIGNAL) /** * Older version of GnuTLS do not support suppressing of SIGPIPE signal. @@ -2251,8 +2253,10 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon); * and if possible. */ #define MHD_TLSLIB_NEED_PUSH_FUNC 1 -#endif \ - /* !MHD_WINSOCK_SOCKETS && !MHD_socket_nosignal_ && (GNUTLS_VERSION_NUMBER+0 < 0x030402) */ +#endif /* MHD_SEND_SPIPE_SUPPRESS_NEEDED && + MHD_SEND_SPIPE_SUPPRESS_POSSIBLE && + ! MHD_socket_nosignal_ && (GNUTLS_VERSION_NUMBER+0 < 0x030402) && + MSG_NOSIGNAL */ #ifdef MHD_TLSLIB_NEED_PUSH_FUNC /** @@ -7740,8 +7744,8 @@ MHD_is_feature_supported (enum MHD_FEATURE feature) return MHD_NO; #endif case MHD_FEATURE_AUTOSUPPRESS_SIGPIPE: -#if defined(MHD_WINSOCK_SOCKETS) || defined(MHD_socket_nosignal_) || \ - defined (MSG_NOSIGNAL) +#if defined(MHD_SEND_SPIPE_SUPPRESS_POSSIBLE) && \ + defined(MHD_SEND_SPIPE_SUPPRESS_NEEDED) return MHD_YES; #else return MHD_NO; diff --git 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, #ifdef HTTPS_SUPPORT no_vec = no_vec || (connection->daemon->options & MHD_USE_TLS); #endif /* HTTPS_SUPPORT */ -#if ! defined(MHD_WINSOCK_SOCKETS) && \ - (! defined(HAVE_SENDMSG) || ! defined(MSG_NOSIGNAL)) && \ - defined(HAVE_SEND_SIGPIPE_SUPPRESS) +#if (! defined(HAVE_SENDMSG) || ! defined(MSG_NOSIGNAL) ) && \ + defined(MHD_SEND_SPIPE_SEND_SUPPRESS_POSSIBLE) && \ + defined(MHD_SEND_SPIPE_SUPPRESS_NEEDED) no_vec = no_vec || (! connection->daemon->sigpipe_blocked && ! connection->sk_spipe_suppress); -#endif /* !MHD_WINSOCK_SOCKETS && (!HAVE_SENDMSG || ! MSG_NOSIGNAL) - && !HAVE_SEND_SIGPIPE_SUPPRESS */ +#endif /* (!HAVE_SENDMSG || ! MSG_NOSIGNAL) && + MHD_SEND_SPIPE_SEND_SUPPRESS_POSSIBLE && + MHD_SEND_SPIPE_SUPPRESS_NEEDED */ #endif /* _MHD_USE_SEND_VEC */ mhd_assert ( (NULL != body) || (0 == body_size) ); diff --git a/src/microhttpd/mhd_sockets.h b/src/microhttpd/mhd_sockets.h @@ -934,17 +934,22 @@ static const int _MHD_socket_int_one = 1; #endif /* SOL_SOCKET && SO_NOSIGPIPE */ -#if defined(MHD_WINSOCK_SOCKETS) || defined(MHD_socket_nosignal_) || \ - defined(MSG_NOSIGNAL) +#if defined(MHD_socket_nosignal_) || defined(MSG_NOSIGNAL) /** - * Indicate that SIGPIPE can be suppressed for normal send() by flags + * Indicate that SIGPIPE can be suppressed by MHD for normal send() by flags * or socket options. * If this macro is undefined, MHD cannot suppress SIGPIPE for normal * processing so sendfile() or writev() calls is not avoided. */ -#define HAVE_SEND_SIGPIPE_SUPPRESS 1 +#define MHD_SEND_SPIPE_SUPPRESS_POSSIBLE 1 #endif /* MHD_WINSOCK_SOCKETS || MHD_socket_nosignal_ || MSG_NOSIGNAL */ +#if ! defined(MHD_WINSOCK_SOCKETS) +/** + * Indicate that suppression of SIGPIPE is required. + */ +#define MHD_SEND_SPIPE_SUPPRESS_NEEDED 1 +#endif /** * Create a listen socket, with noninheritable flag if possible.