aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-02-14 15:40:18 +0100
committerChristian Grothoff <christian@grothoff.org>2020-02-14 15:40:18 +0100
commiteda21a5c2a9a3d08fdfdaef3d6a66fe6ad4ed265 (patch)
tree1f0eef15fdc89919aa842baf9afe56a033996675
parent902e3774f5098f90fb9ec0125b3814ce2d0ba088 (diff)
downloadlibmicrohttpd-eda21a5c2a9a3d08fdfdaef3d6a66fe6ad4ed265.tar.gz
libmicrohttpd-eda21a5c2a9a3d08fdfdaef3d6a66fe6ad4ed265.zip
clean up #define mess a bit
-rw-r--r--src/microhttpd/mhd_sockets.c16
-rw-r--r--src/microhttpd/mhd_sockets.h10
2 files changed, 12 insertions, 14 deletions
diff --git a/src/microhttpd/mhd_sockets.c b/src/microhttpd/mhd_sockets.c
index cda00fdd..1448341a 100644
--- a/src/microhttpd/mhd_sockets.c
+++ b/src/microhttpd/mhd_sockets.c
@@ -17,18 +17,12 @@
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 18
19*/ 19*/
20
21/** 20/**
22 * @file microhttpd/mhd_sockets.c 21 * @file microhttpd/mhd_sockets.c
23 * @brief Implementation for sockets functions 22 * @brief Implementation for sockets functions
24 * @author Karlson2k (Evgeny Grin) 23 * @author Karlson2k (Evgeny Grin)
25 */ 24 */
26
27#include "mhd_sockets.h" 25#include "mhd_sockets.h"
28#ifdef HAVE_UNISTD_H
29#include <unistd.h>
30#endif /* HAVE_UNISTD_H */
31#include <fcntl.h>
32 26
33#ifdef MHD_WINSOCK_SOCKETS 27#ifdef MHD_WINSOCK_SOCKETS
34 28
@@ -613,12 +607,10 @@ MHD_socket_create_listen_ (int pf)
613 if (MHD_INVALID_SOCKET == fd) 607 if (MHD_INVALID_SOCKET == fd)
614 return MHD_INVALID_SOCKET; 608 return MHD_INVALID_SOCKET;
615 609
616#if defined(SOCK_NOSIGPIPE) || defined(MHD_socket_nosignal_) 610#if defined(MHD_socket_nosignal_)
617 if ( ( (! nosigpipe_set) 611 if ( ( (! nosigpipe_set)
618#ifdef MHD_socket_nosignal_ 612 || (! MHD_socket_nosignal_ (fd)) ) &&
619 || (! MHD_socket_nosignal_ (fd)) 613 (0 == MAYBE_MSG_NOSIGNAL) )
620#endif /* MHD_socket_nosignal_ */
621 ) && (0 == MAYBE_MSG_NOSIGNAL) )
622 { 614 {
623 /* SIGPIPE disable is possible on this platform 615 /* SIGPIPE disable is possible on this platform
624 * (so application expect that it will be disabled), 616 * (so application expect that it will be disabled),
@@ -629,7 +621,7 @@ MHD_socket_create_listen_ (int pf)
629 MHD_socket_fset_error_ (err); 621 MHD_socket_fset_error_ (err);
630 return MHD_INVALID_SOCKET; 622 return MHD_INVALID_SOCKET;
631 } 623 }
632#endif /* SOCK_NOSIGPIPE || MHD_socket_nosignal_ */ 624#endif /* defined(MHD_socket_nosignal_) */
633 if (! cloexec_set) 625 if (! cloexec_set)
634 (void) MHD_socket_noninheritable_ (fd); 626 (void) MHD_socket_noninheritable_ (fd);
635 627
diff --git a/src/microhttpd/mhd_sockets.h b/src/microhttpd/mhd_sockets.h
index aaf58e4a..0241ef28 100644
--- a/src/microhttpd/mhd_sockets.h
+++ b/src/microhttpd/mhd_sockets.h
@@ -36,6 +36,10 @@
36 36
37#include <errno.h> 37#include <errno.h>
38#include <stdbool.h> 38#include <stdbool.h>
39#ifdef HAVE_UNISTD_H
40#include <unistd.h>
41#endif /* HAVE_UNISTD_H */
42#include <fcntl.h>
39 43
40#if ! defined(MHD_POSIX_SOCKETS) && ! defined(MHD_WINSOCK_SOCKETS) 44#if ! defined(MHD_POSIX_SOCKETS) && ! defined(MHD_WINSOCK_SOCKETS)
41# if ! defined(_WIN32) || defined(__CYGWIN__) 45# if ! defined(_WIN32) || defined(__CYGWIN__)
@@ -854,10 +858,12 @@ static const int _MHD_socket_int_one = 1;
854 * @param sock socket to manipulate 858 * @param sock socket to manipulate
855 * @return non-zero if succeeded, zero otherwise 859 * @return non-zero if succeeded, zero otherwise
856 */ 860 */
857# define MHD_socket_nosignal_(sock) \ 861#define MHD_socket_nosignal_(sock) \
858 (! setsockopt ((sock),SOL_SOCKET,SO_NOSIGPIPE,&_MHD_socket_int_one, \ 862 (! setsockopt ((sock),SOL_SOCKET,SO_NOSIGPIPE,&_MHD_socket_int_one, \
859 sizeof(_MHD_socket_int_one))) 863 sizeof(_MHD_socket_int_one)))
860#endif /* SOL_SOCKET && SO_NOSIGPIPE */ 864#elif defined(MHD_POSIX_SOCKETS) && defined(SOCK_NOSIGPIPE) && \
865 defined(SOCK_CLOEXEC)
866#endif
861 867
862/** 868/**
863 * Create a listen socket, with noninheritable flag if possible. 869 * Create a listen socket, with noninheritable flag if possible.