diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2015-11-21 19:43:06 +0000 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2015-11-21 19:43:06 +0000 |
commit | 6e4a434cfc0d5eac721b0adafbdda3829d68102b (patch) | |
tree | 8ff50ef0d3659fbabf06853f819e536079199177 /src/microhttpd | |
parent | 50a6102ff3d2d437c256d179c72c3e9fb16040f3 (diff) | |
download | libmicrohttpd-6e4a434cfc0d5eac721b0adafbdda3829d68102b.tar.gz libmicrohttpd-6e4a434cfc0d5eac721b0adafbdda3829d68102b.zip |
Add and use _MHD_SOCKOPT_BOOL_TYPE for simplify usage of setsockopt() on W32/POSIX sockets.
Diffstat (limited to 'src/microhttpd')
-rw-r--r-- | src/microhttpd/connection.c | 4 | ||||
-rw-r--r-- | src/microhttpd/daemon.c | 14 |
2 files changed, 5 insertions, 13 deletions
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c index a7d949c0..20300580 100644 --- a/src/microhttpd/connection.c +++ b/src/microhttpd/connection.c | |||
@@ -2425,7 +2425,7 @@ MHD_connection_handle_idle (struct MHD_Connection *connection) | |||
2425 | #if HAVE_DECL_TCP_CORK | 2425 | #if HAVE_DECL_TCP_CORK |
2426 | /* starting header send, set TCP cork */ | 2426 | /* starting header send, set TCP cork */ |
2427 | { | 2427 | { |
2428 | const int val = 1; | 2428 | const _MHD_SOCKOPT_BOOL_TYPE val = 1; |
2429 | setsockopt (connection->socket_fd, IPPROTO_TCP, TCP_CORK, &val, | 2429 | setsockopt (connection->socket_fd, IPPROTO_TCP, TCP_CORK, &val, |
2430 | sizeof (val)); | 2430 | sizeof (val)); |
2431 | } | 2431 | } |
@@ -2509,7 +2509,7 @@ MHD_connection_handle_idle (struct MHD_Connection *connection) | |||
2509 | #if HAVE_DECL_TCP_CORK | 2509 | #if HAVE_DECL_TCP_CORK |
2510 | /* done sending, uncork */ | 2510 | /* done sending, uncork */ |
2511 | { | 2511 | { |
2512 | const int val = 0; | 2512 | const _MHD_SOCKOPT_BOOL_TYPE = 0; |
2513 | setsockopt (connection->socket_fd, IPPROTO_TCP, TCP_CORK, &val, | 2513 | setsockopt (connection->socket_fd, IPPROTO_TCP, TCP_CORK, &val, |
2514 | sizeof (val)); | 2514 | sizeof (val)); |
2515 | } | 2515 | } |
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index 37257db5..bb9765f6 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c | |||
@@ -3619,11 +3619,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
3619 | MHD_AccessHandlerCallback dh, void *dh_cls, | 3619 | MHD_AccessHandlerCallback dh, void *dh_cls, |
3620 | va_list ap) | 3620 | va_list ap) |
3621 | { | 3621 | { |
3622 | #if defined(MHD_POSIX_SOCKETS) | 3622 | const _MHD_SOCKOPT_BOOL_TYPE on = 1; |
3623 | const int on = 1; | ||
3624 | #elif defined(MHD_WINSOCK_SOCKETS) | ||
3625 | const uint32_t on = 1; | ||
3626 | #endif /* MHD_WINSOCK_SOCKETS */ | ||
3627 | struct MHD_Daemon *daemon; | 3623 | struct MHD_Daemon *daemon; |
3628 | MHD_socket socket_fd; | 3624 | MHD_socket socket_fd; |
3629 | struct sockaddr_in servaddr4; | 3625 | struct sockaddr_in servaddr4; |
@@ -3995,12 +3991,8 @@ MHD_start_daemon_va (unsigned int flags, | |||
3995 | (http://msdn.microsoft.com/en-us/library/ms738574%28v=VS.85%29.aspx); | 3991 | (http://msdn.microsoft.com/en-us/library/ms738574%28v=VS.85%29.aspx); |
3996 | and may also be missing on older POSIX systems; good luck if you have any of those, | 3992 | and may also be missing on older POSIX systems; good luck if you have any of those, |
3997 | your IPv6 socket may then also bind against IPv4 anyway... */ | 3993 | your IPv6 socket may then also bind against IPv4 anyway... */ |
3998 | #ifndef MHD_WINSOCK_SOCKETS | 3994 | const _MHD_SOCKOPT_BOOL_TYPE v6_only = |
3999 | const int | 3995 | (MHD_USE_DUAL_STACK != (flags & MHD_USE_DUAL_STACK)); |
4000 | #else | ||
4001 | const uint32_t | ||
4002 | #endif | ||
4003 | v6_only = (MHD_USE_DUAL_STACK != (flags & MHD_USE_DUAL_STACK)); | ||
4004 | if (0 > setsockopt (socket_fd, | 3996 | if (0 > setsockopt (socket_fd, |
4005 | IPPROTO_IPV6, IPV6_V6ONLY, | 3997 | IPPROTO_IPV6, IPV6_V6ONLY, |
4006 | (const void*)&v6_only, sizeof (v6_only))) | 3998 | (const void*)&v6_only, sizeof (v6_only))) |