diff options
Diffstat (limited to 'src/microhttpd/daemon.c')
-rw-r--r-- | src/microhttpd/daemon.c | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index f9bebd35..794acfbd 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c | |||
@@ -52,7 +52,7 @@ | |||
52 | #endif /* MHD_HTTPS_REQUIRE_GRYPT */ | 52 | #endif /* MHD_HTTPS_REQUIRE_GRYPT */ |
53 | #endif /* HTTPS_SUPPORT */ | 53 | #endif /* HTTPS_SUPPORT */ |
54 | 54 | ||
55 | #ifdef _WIN32 | 55 | #if defined(_WIN32) && ! defined(__CYGWIN__) |
56 | #ifndef WIN32_LEAN_AND_MEAN | 56 | #ifndef WIN32_LEAN_AND_MEAN |
57 | #define WIN32_LEAN_AND_MEAN 1 | 57 | #define WIN32_LEAN_AND_MEAN 1 |
58 | #endif /* !WIN32_LEAN_AND_MEAN */ | 58 | #endif /* !WIN32_LEAN_AND_MEAN */ |
@@ -152,7 +152,7 @@ MHD_PanicCallback mhd_panic; | |||
152 | */ | 152 | */ |
153 | void *mhd_panic_cls; | 153 | void *mhd_panic_cls; |
154 | 154 | ||
155 | #ifdef _WIN32 | 155 | #if defined(_WIN32) && ! defined(__CYGWIN__) |
156 | /** | 156 | /** |
157 | * Track initialization of winsock | 157 | * Track initialization of winsock |
158 | */ | 158 | */ |
@@ -1822,14 +1822,14 @@ thread_main_handle_connection (void *data) | |||
1822 | else | 1822 | else |
1823 | { | 1823 | { |
1824 | const time_t seconds_left = timeout - (now - con->last_activity); | 1824 | const time_t seconds_left = timeout - (now - con->last_activity); |
1825 | #ifndef _WIN32 | 1825 | #if !defined(_WIN32) || defined(__CYGWIN__) |
1826 | tv.tv_sec = seconds_left; | 1826 | tv.tv_sec = seconds_left; |
1827 | #else /* _WIN32 */ | 1827 | #else /* _WIN32 && !__CYGWIN__ */ |
1828 | if (seconds_left > TIMEVAL_TV_SEC_MAX) | 1828 | if (seconds_left > TIMEVAL_TV_SEC_MAX) |
1829 | tv.tv_sec = TIMEVAL_TV_SEC_MAX; | 1829 | tv.tv_sec = TIMEVAL_TV_SEC_MAX; |
1830 | else | 1830 | else |
1831 | tv.tv_sec = (_MHD_TIMEVAL_TV_SEC_TYPE) seconds_left; | 1831 | tv.tv_sec = (_MHD_TIMEVAL_TV_SEC_TYPE) seconds_left; |
1832 | #endif /* _WIN32 */ | 1832 | #endif /* _WIN32 && ! __CYGWIN__ */ |
1833 | } | 1833 | } |
1834 | tv.tv_usec = 0; | 1834 | tv.tv_usec = 0; |
1835 | tvp = &tv; | 1835 | tvp = &tv; |
@@ -2073,7 +2073,7 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon); | |||
2073 | * and if possible. | 2073 | * and if possible. |
2074 | */ | 2074 | */ |
2075 | #define MHD_TLSLIB_NEED_PUSH_FUNC 1 | 2075 | #define MHD_TLSLIB_NEED_PUSH_FUNC 1 |
2076 | #endif /* !_WIN32 && !MHD_socket_nosignal_ && (GNUTLS_VERSION_NUMBER+0 < 0x030402) */ | 2076 | #endif /* !MHD_WINSOCK_SOCKETS && !MHD_socket_nosignal_ && (GNUTLS_VERSION_NUMBER+0 < 0x030402) */ |
2077 | 2077 | ||
2078 | #ifdef MHD_TLSLIB_NEED_PUSH_FUNC | 2078 | #ifdef MHD_TLSLIB_NEED_PUSH_FUNC |
2079 | /** | 2079 | /** |
@@ -5489,7 +5489,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
5489 | /* Apply the socket options according to listening_address_reuse. */ | 5489 | /* Apply the socket options according to listening_address_reuse. */ |
5490 | if (0 == daemon->listening_address_reuse) | 5490 | if (0 == daemon->listening_address_reuse) |
5491 | { | 5491 | { |
5492 | #ifndef _WIN32 | 5492 | #ifdef MHD_WINSOCK_SOCKETS |
5493 | /* No user requirement, use "traditional" default SO_REUSEADDR | 5493 | /* No user requirement, use "traditional" default SO_REUSEADDR |
5494 | * on non-W32 platforms, and do not fail if it doesn't work. | 5494 | * on non-W32 platforms, and do not fail if it doesn't work. |
5495 | * Don't use it on W32, because on W32 it will allow multiple | 5495 | * Don't use it on W32, because on W32 it will allow multiple |
@@ -5505,12 +5505,12 @@ MHD_start_daemon_va (unsigned int flags, | |||
5505 | MHD_socket_last_strerr_ ()); | 5505 | MHD_socket_last_strerr_ ()); |
5506 | #endif | 5506 | #endif |
5507 | } | 5507 | } |
5508 | #endif /* ! _WIN32 */ | 5508 | #endif /* ! MHD_WINSOCK_SOCKETS */ |
5509 | } | 5509 | } |
5510 | else if (daemon->listening_address_reuse > 0) | 5510 | else if (daemon->listening_address_reuse > 0) |
5511 | { | 5511 | { |
5512 | /* User requested to allow reusing listening address:port. */ | 5512 | /* User requested to allow reusing listening address:port. */ |
5513 | #ifndef _WIN32 | 5513 | #ifndef MHD_WINSOCK_SOCKETS |
5514 | /* Use SO_REUSEADDR on non-W32 platforms, and do not fail if | 5514 | /* Use SO_REUSEADDR on non-W32 platforms, and do not fail if |
5515 | * it doesn't work. */ | 5515 | * it doesn't work. */ |
5516 | if (0 > setsockopt (listen_fd, | 5516 | if (0 > setsockopt (listen_fd, |
@@ -5524,20 +5524,20 @@ MHD_start_daemon_va (unsigned int flags, | |||
5524 | MHD_socket_last_strerr_ ()); | 5524 | MHD_socket_last_strerr_ ()); |
5525 | #endif | 5525 | #endif |
5526 | } | 5526 | } |
5527 | #endif /* ! _WIN32 */ | 5527 | #endif /* ! MHD_WINSOCK_SOCKETS */ |
5528 | /* Use SO_REUSEADDR on Windows and SO_REUSEPORT on most platforms. | 5528 | /* Use SO_REUSEADDR on Windows and SO_REUSEPORT on most platforms. |
5529 | * Fail if SO_REUSEPORT is not defined or setsockopt fails. | 5529 | * Fail if SO_REUSEPORT is not defined or setsockopt fails. |
5530 | */ | 5530 | */ |
5531 | /* SO_REUSEADDR on W32 has the same semantics | 5531 | /* SO_REUSEADDR on W32 has the same semantics |
5532 | as SO_REUSEPORT on BSD/Linux */ | 5532 | as SO_REUSEPORT on BSD/Linux */ |
5533 | #if defined(_WIN32) || defined(SO_REUSEPORT) | 5533 | #if defined(MHD_WINSOCK_SOCKETS) || defined(SO_REUSEPORT) |
5534 | if (0 > setsockopt (listen_fd, | 5534 | if (0 > setsockopt (listen_fd, |
5535 | SOL_SOCKET, | 5535 | SOL_SOCKET, |
5536 | #ifndef _WIN32 | 5536 | #ifndef MHD_WINSOCK_SOCKETS |
5537 | SO_REUSEPORT, | 5537 | SO_REUSEPORT, |
5538 | #else /* _WIN32 */ | 5538 | #else /* MHD_WINSOCK_SOCKETS */ |
5539 | SO_REUSEADDR, | 5539 | SO_REUSEADDR, |
5540 | #endif /* _WIN32 */ | 5540 | #endif /* MHD_WINSOCK_SOCKETS */ |
5541 | (void *) &on, | 5541 | (void *) &on, |
5542 | sizeof (on))) | 5542 | sizeof (on))) |
5543 | { | 5543 | { |
@@ -5548,7 +5548,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
5548 | #endif | 5548 | #endif |
5549 | goto free_and_fail; | 5549 | goto free_and_fail; |
5550 | } | 5550 | } |
5551 | #else /* !_WIN32 && !SO_REUSEPORT */ | 5551 | #else /* !MHD_WINSOCK_SOCKETS && !SO_REUSEPORT */ |
5552 | /* we're supposed to allow address:port re-use, but | 5552 | /* we're supposed to allow address:port re-use, but |
5553 | on this platform we cannot; fail hard */ | 5553 | on this platform we cannot; fail hard */ |
5554 | #ifdef HAVE_MESSAGES | 5554 | #ifdef HAVE_MESSAGES |
@@ -5556,7 +5556,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
5556 | _("Cannot allow listening address reuse: SO_REUSEPORT not defined\n")); | 5556 | _("Cannot allow listening address reuse: SO_REUSEPORT not defined\n")); |
5557 | #endif | 5557 | #endif |
5558 | goto free_and_fail; | 5558 | goto free_and_fail; |
5559 | #endif /* !_WIN32 && !SO_REUSEPORT */ | 5559 | #endif /* !MHD_WINSOCK_SOCKETS && !SO_REUSEPORT */ |
5560 | } | 5560 | } |
5561 | else /* if (daemon->listening_address_reuse < 0) */ | 5561 | else /* if (daemon->listening_address_reuse < 0) */ |
5562 | { | 5562 | { |
@@ -5566,7 +5566,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
5566 | * Fail if MHD was compiled for W32 without SO_EXCLUSIVEADDRUSE | 5566 | * Fail if MHD was compiled for W32 without SO_EXCLUSIVEADDRUSE |
5567 | * or setsockopt fails. | 5567 | * or setsockopt fails. |
5568 | */ | 5568 | */ |
5569 | #if (defined(_WIN32) && defined(SO_EXCLUSIVEADDRUSE)) || \ | 5569 | #if (defined(MHD_WINSOCK_SOCKETS) && defined(SO_EXCLUSIVEADDRUSE)) || \ |
5570 | (defined(__sun) && defined(SO_EXCLBIND)) | 5570 | (defined(__sun) && defined(SO_EXCLBIND)) |
5571 | if (0 > setsockopt (listen_fd, | 5571 | if (0 > setsockopt (listen_fd, |
5572 | SOL_SOCKET, | 5572 | SOL_SOCKET, |
@@ -5585,13 +5585,13 @@ MHD_start_daemon_va (unsigned int flags, | |||
5585 | #endif | 5585 | #endif |
5586 | goto free_and_fail; | 5586 | goto free_and_fail; |
5587 | } | 5587 | } |
5588 | #elif defined(_WIN32) /* SO_EXCLUSIVEADDRUSE not defined on W32? */ | 5588 | #elif defined(MHD_WINSOCK_SOCKETS) /* SO_EXCLUSIVEADDRUSE not defined on W32? */ |
5589 | #ifdef HAVE_MESSAGES | 5589 | #ifdef HAVE_MESSAGES |
5590 | MHD_DLOG (daemon, | 5590 | MHD_DLOG (daemon, |
5591 | _("Cannot disallow listening address reuse: SO_EXCLUSIVEADDRUSE not defined\n")); | 5591 | _("Cannot disallow listening address reuse: SO_EXCLUSIVEADDRUSE not defined\n")); |
5592 | #endif | 5592 | #endif |
5593 | goto free_and_fail; | 5593 | goto free_and_fail; |
5594 | #endif /* _WIN32 */ | 5594 | #endif /* MHD_WINSOCK_SOCKETS */ |
5595 | } | 5595 | } |
5596 | 5596 | ||
5597 | /* check for user supplied sockaddr */ | 5597 | /* check for user supplied sockaddr */ |
@@ -6698,13 +6698,13 @@ static struct gcry_thread_cbs gcry_threads_w32 = { | |||
6698 | void | 6698 | void |
6699 | MHD_init(void) | 6699 | MHD_init(void) |
6700 | { | 6700 | { |
6701 | #ifdef _WIN32 | 6701 | #if defined(_WIN32) && ! defined(__CYGWIN__) |
6702 | WSADATA wsd; | 6702 | WSADATA wsd; |
6703 | #endif /* _WIN32 */ | 6703 | #endif /* _WIN32 && ! __CYGWIN__ */ |
6704 | mhd_panic = &mhd_panic_std; | 6704 | mhd_panic = &mhd_panic_std; |
6705 | mhd_panic_cls = NULL; | 6705 | mhd_panic_cls = NULL; |
6706 | 6706 | ||
6707 | #ifdef _WIN32 | 6707 | #if defined(_WIN32) && ! defined(__CYGWIN__) |
6708 | if (0 != WSAStartup(MAKEWORD(2, 2), &wsd)) | 6708 | if (0 != WSAStartup(MAKEWORD(2, 2), &wsd)) |
6709 | MHD_PANIC (_("Failed to initialize winsock\n")); | 6709 | MHD_PANIC (_("Failed to initialize winsock\n")); |
6710 | mhd_winsock_inited_ = 1; | 6710 | mhd_winsock_inited_ = 1; |
@@ -6744,7 +6744,7 @@ MHD_fini(void) | |||
6744 | #ifdef HTTPS_SUPPORT | 6744 | #ifdef HTTPS_SUPPORT |
6745 | gnutls_global_deinit (); | 6745 | gnutls_global_deinit (); |
6746 | #endif /* HTTPS_SUPPORT */ | 6746 | #endif /* HTTPS_SUPPORT */ |
6747 | #ifdef _WIN32 | 6747 | #if defined(_WIN32) && ! defined(__CYGWIN__) |
6748 | if (mhd_winsock_inited_) | 6748 | if (mhd_winsock_inited_) |
6749 | WSACleanup(); | 6749 | WSACleanup(); |
6750 | #endif | 6750 | #endif |