libmicrohttpd

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

commit eda21a5c2a9a3d08fdfdaef3d6a66fe6ad4ed265
parent 902e3774f5098f90fb9ec0125b3814ce2d0ba088
Author: Christian Grothoff <christian@grothoff.org>
Date:   Fri, 14 Feb 2020 15:40:18 +0100

clean up #define mess a bit

Diffstat:
Msrc/microhttpd/mhd_sockets.c | 16++++------------
Msrc/microhttpd/mhd_sockets.h | 10++++++++--
2 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/src/microhttpd/mhd_sockets.c b/src/microhttpd/mhd_sockets.c @@ -17,18 +17,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - /** * @file microhttpd/mhd_sockets.c * @brief Implementation for sockets functions * @author Karlson2k (Evgeny Grin) */ - #include "mhd_sockets.h" -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif /* HAVE_UNISTD_H */ -#include <fcntl.h> #ifdef MHD_WINSOCK_SOCKETS @@ -613,12 +607,10 @@ MHD_socket_create_listen_ (int pf) if (MHD_INVALID_SOCKET == fd) return MHD_INVALID_SOCKET; -#if defined(SOCK_NOSIGPIPE) || defined(MHD_socket_nosignal_) +#if defined(MHD_socket_nosignal_) if ( ( (! nosigpipe_set) -#ifdef MHD_socket_nosignal_ - || (! MHD_socket_nosignal_ (fd)) -#endif /* MHD_socket_nosignal_ */ - ) && (0 == MAYBE_MSG_NOSIGNAL) ) + || (! MHD_socket_nosignal_ (fd)) ) && + (0 == MAYBE_MSG_NOSIGNAL) ) { /* SIGPIPE disable is possible on this platform * (so application expect that it will be disabled), @@ -629,7 +621,7 @@ MHD_socket_create_listen_ (int pf) MHD_socket_fset_error_ (err); return MHD_INVALID_SOCKET; } -#endif /* SOCK_NOSIGPIPE || MHD_socket_nosignal_ */ +#endif /* defined(MHD_socket_nosignal_) */ if (! cloexec_set) (void) MHD_socket_noninheritable_ (fd); diff --git a/src/microhttpd/mhd_sockets.h b/src/microhttpd/mhd_sockets.h @@ -36,6 +36,10 @@ #include <errno.h> #include <stdbool.h> +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif /* HAVE_UNISTD_H */ +#include <fcntl.h> #if ! defined(MHD_POSIX_SOCKETS) && ! defined(MHD_WINSOCK_SOCKETS) # if ! defined(_WIN32) || defined(__CYGWIN__) @@ -854,10 +858,12 @@ static const int _MHD_socket_int_one = 1; * @param sock socket to manipulate * @return non-zero if succeeded, zero otherwise */ -# define MHD_socket_nosignal_(sock) \ +#define MHD_socket_nosignal_(sock) \ (! setsockopt ((sock),SOL_SOCKET,SO_NOSIGPIPE,&_MHD_socket_int_one, \ sizeof(_MHD_socket_int_one))) -#endif /* SOL_SOCKET && SO_NOSIGPIPE */ +#elif defined(MHD_POSIX_SOCKETS) && defined(SOCK_NOSIGPIPE) && \ + defined(SOCK_CLOEXEC) +#endif /** * Create a listen socket, with noninheritable flag if possible.