diff options
Diffstat (limited to 'src/microhttpd/daemon.c')
-rw-r--r-- | src/microhttpd/daemon.c | 112 |
1 files changed, 58 insertions, 54 deletions
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index f2427902..aa915af6 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c | |||
@@ -5317,31 +5317,35 @@ MHD_start_daemon_va (unsigned int flags, | |||
5317 | socklen_t addrlen; | 5317 | socklen_t addrlen; |
5318 | unsigned int i; | 5318 | unsigned int i; |
5319 | int use_itc; | 5319 | int use_itc; |
5320 | enum MHD_FLAG eflags; /* same type as in MHD_Daemon */ | ||
5321 | enum MHD_FLAG *pflags; | ||
5320 | 5322 | ||
5323 | eflags = (enum MHD_FLAG) flags; | ||
5324 | pflags = &eflags; | ||
5321 | #ifndef HAVE_INET6 | 5325 | #ifndef HAVE_INET6 |
5322 | if (0 != (flags & MHD_USE_IPv6)) | 5326 | if (0 != (*pflags & MHD_USE_IPv6)) |
5323 | return NULL; | 5327 | return NULL; |
5324 | #endif | 5328 | #endif |
5325 | #ifndef HAVE_POLL | 5329 | #ifndef HAVE_POLL |
5326 | if (0 != (flags & MHD_USE_POLL)) | 5330 | if (0 != (*pflags & MHD_USE_POLL)) |
5327 | return NULL; | 5331 | return NULL; |
5328 | #endif | 5332 | #endif |
5329 | #ifndef EPOLL_SUPPORT | 5333 | #ifndef EPOLL_SUPPORT |
5330 | if (0 != (flags & MHD_USE_EPOLL)) | 5334 | if (0 != (*pflags & MHD_USE_EPOLL)) |
5331 | return NULL; | 5335 | return NULL; |
5332 | #endif /* ! EPOLL_SUPPORT */ | 5336 | #endif /* ! EPOLL_SUPPORT */ |
5333 | #ifndef HTTPS_SUPPORT | 5337 | #ifndef HTTPS_SUPPORT |
5334 | if (0 != (flags & MHD_USE_TLS)) | 5338 | if (0 != (*pflags & MHD_USE_TLS)) |
5335 | return NULL; | 5339 | return NULL; |
5336 | #endif /* ! HTTPS_SUPPORT */ | 5340 | #endif /* ! HTTPS_SUPPORT */ |
5337 | #ifndef TCP_FASTOPEN | 5341 | #ifndef TCP_FASTOPEN |
5338 | if (0 != (flags & MHD_USE_TCP_FASTOPEN)) | 5342 | if (0 != (*pflags & MHD_USE_TCP_FASTOPEN)) |
5339 | return NULL; | 5343 | return NULL; |
5340 | #endif | 5344 | #endif |
5341 | if (0 != (flags & MHD_ALLOW_UPGRADE)) | 5345 | if (0 != (*pflags & MHD_ALLOW_UPGRADE)) |
5342 | { | 5346 | { |
5343 | #ifdef UPGRADE_SUPPORT | 5347 | #ifdef UPGRADE_SUPPORT |
5344 | flags |= MHD_ALLOW_SUSPEND_RESUME; | 5348 | *pflags |= MHD_ALLOW_SUSPEND_RESUME; |
5345 | #else /* ! UPGRADE_SUPPORT */ | 5349 | #else /* ! UPGRADE_SUPPORT */ |
5346 | return NULL; | 5350 | return NULL; |
5347 | #endif /* ! UPGRADE_SUPPORT */ | 5351 | #endif /* ! UPGRADE_SUPPORT */ |
@@ -5350,30 +5354,30 @@ MHD_start_daemon_va (unsigned int flags, | |||
5350 | return NULL; | 5354 | return NULL; |
5351 | 5355 | ||
5352 | /* Check for invalid combinations of flags. */ | 5356 | /* Check for invalid combinations of flags. */ |
5353 | if ( ((0 != (flags & MHD_USE_POLL)) && (0 != (flags & MHD_USE_EPOLL))) || | 5357 | if ( ((0 != (*pflags & MHD_USE_POLL)) && (0 != (*pflags & MHD_USE_EPOLL))) || |
5354 | ((0 != (flags & MHD_USE_EPOLL)) && (0 != (flags & MHD_USE_THREAD_PER_CONNECTION))) || | 5358 | ((0 != (*pflags & MHD_USE_EPOLL)) && (0 != (*pflags & MHD_USE_THREAD_PER_CONNECTION))) || |
5355 | ((0 != (flags & MHD_USE_POLL)) && (0 == (flags & MHD_USE_INTERNAL_POLLING_THREAD))) || | 5359 | ((0 != (*pflags & MHD_USE_POLL)) && (0 == (*pflags & MHD_USE_INTERNAL_POLLING_THREAD))) || |
5356 | ((0 != (flags & MHD_USE_AUTO)) && (0 != (flags & (MHD_USE_POLL | MHD_USE_EPOLL)))) ) | 5360 | ((0 != (*pflags & MHD_USE_AUTO)) && (0 != (*pflags & (MHD_USE_POLL | MHD_USE_EPOLL)))) ) |
5357 | return NULL; | 5361 | return NULL; |
5358 | 5362 | ||
5359 | if (0 != (flags & MHD_USE_AUTO)) | 5363 | if (0 != (*pflags & MHD_USE_AUTO)) |
5360 | { | 5364 | { |
5361 | if (0 != (flags & MHD_USE_THREAD_PER_CONNECTION)) | 5365 | if (0 != (*pflags & MHD_USE_THREAD_PER_CONNECTION)) |
5362 | { | 5366 | { |
5363 | /* Thread per connection with internal polling thread. */ | 5367 | /* Thread per connection with internal polling thread. */ |
5364 | #ifdef HAVE_POLL | 5368 | #ifdef HAVE_POLL |
5365 | flags |= MHD_USE_POLL; | 5369 | *pflags |= MHD_USE_POLL; |
5366 | #else /* ! HAVE_POLL */ | 5370 | #else /* ! HAVE_POLL */ |
5367 | /* use select() - do not modify flags */ | 5371 | /* use select() - do not modify flags */ |
5368 | #endif /* ! HAVE_POLL */ | 5372 | #endif /* ! HAVE_POLL */ |
5369 | } | 5373 | } |
5370 | else if (0 != (flags & MHD_USE_INTERNAL_POLLING_THREAD)) | 5374 | else if (0 != (*pflags & MHD_USE_INTERNAL_POLLING_THREAD)) |
5371 | { | 5375 | { |
5372 | /* Internal polling thread. */ | 5376 | /* Internal polling thread. */ |
5373 | #if defined(EPOLL_SUPPORT) | 5377 | #if defined(EPOLL_SUPPORT) |
5374 | flags |= MHD_USE_EPOLL; | 5378 | *pflags |= MHD_USE_EPOLL; |
5375 | #elif defined(HAVE_POLL) | 5379 | #elif defined(HAVE_POLL) |
5376 | flags |= MHD_USE_POLL; | 5380 | *pflags |= MHD_USE_POLL; |
5377 | #else /* !HAVE_POLL && !EPOLL_SUPPORT */ | 5381 | #else /* !HAVE_POLL && !EPOLL_SUPPORT */ |
5378 | /* use select() - do not modify flags */ | 5382 | /* use select() - do not modify flags */ |
5379 | #endif /* !HAVE_POLL && !EPOLL_SUPPORT */ | 5383 | #endif /* !HAVE_POLL && !EPOLL_SUPPORT */ |
@@ -5382,7 +5386,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
5382 | { | 5386 | { |
5383 | /* Internal threads are not used - "external" polling mode. */ | 5387 | /* Internal threads are not used - "external" polling mode. */ |
5384 | #if defined(EPOLL_SUPPORT) | 5388 | #if defined(EPOLL_SUPPORT) |
5385 | flags |= MHD_USE_EPOLL; | 5389 | *pflags |= MHD_USE_EPOLL; |
5386 | #else /* ! EPOLL_SUPPORT */ | 5390 | #else /* ! EPOLL_SUPPORT */ |
5387 | /* use select() - do not modify flags */ | 5391 | /* use select() - do not modify flags */ |
5388 | #endif /* ! EPOLL_SUPPORT */ | 5392 | #endif /* ! EPOLL_SUPPORT */ |
@@ -5399,7 +5403,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
5399 | #endif | 5403 | #endif |
5400 | /* try to open listen socket */ | 5404 | /* try to open listen socket */ |
5401 | #ifdef HTTPS_SUPPORT | 5405 | #ifdef HTTPS_SUPPORT |
5402 | if (0 != (flags & MHD_USE_TLS)) | 5406 | if (0 != (*pflags & MHD_USE_TLS)) |
5403 | { | 5407 | { |
5404 | gnutls_priority_init (&daemon->priority_cache, | 5408 | gnutls_priority_init (&daemon->priority_cache, |
5405 | "NORMAL", | 5409 | "NORMAL", |
@@ -5408,7 +5412,8 @@ MHD_start_daemon_va (unsigned int flags, | |||
5408 | #endif /* HTTPS_SUPPORT */ | 5412 | #endif /* HTTPS_SUPPORT */ |
5409 | daemon->listen_fd = MHD_INVALID_SOCKET; | 5413 | daemon->listen_fd = MHD_INVALID_SOCKET; |
5410 | daemon->listening_address_reuse = 0; | 5414 | daemon->listening_address_reuse = 0; |
5411 | daemon->options = flags; | 5415 | daemon->options = *pflags; |
5416 | pflags = &daemon->options; | ||
5412 | daemon->port = port; | 5417 | daemon->port = port; |
5413 | daemon->apc = apc; | 5418 | daemon->apc = apc; |
5414 | daemon->apc_cls = apc_cls; | 5419 | daemon->apc_cls = apc_cls; |
@@ -5430,8 +5435,8 @@ MHD_start_daemon_va (unsigned int flags, | |||
5430 | daemon->custom_error_log = (MHD_LogCallback) &vfprintf; | 5435 | daemon->custom_error_log = (MHD_LogCallback) &vfprintf; |
5431 | daemon->custom_error_log_cls = stderr; | 5436 | daemon->custom_error_log_cls = stderr; |
5432 | #endif | 5437 | #endif |
5433 | if ( (0 != (flags & MHD_USE_THREAD_PER_CONNECTION)) && | 5438 | if ( (0 != (*pflags & MHD_USE_THREAD_PER_CONNECTION)) && |
5434 | (0 == (flags & MHD_USE_INTERNAL_POLLING_THREAD)) ) | 5439 | (0 == (*pflags & MHD_USE_INTERNAL_POLLING_THREAD)) ) |
5435 | { | 5440 | { |
5436 | #ifdef HAVE_MESSAGES | 5441 | #ifdef HAVE_MESSAGES |
5437 | MHD_DLOG (daemon, | 5442 | MHD_DLOG (daemon, |
@@ -5439,15 +5444,14 @@ MHD_start_daemon_va (unsigned int flags, | |||
5439 | "MHD_USE_INTERNAL_POLLING_THREAD. Flag MHD_USE_INTERNAL_POLLING_THREAD " | 5444 | "MHD_USE_INTERNAL_POLLING_THREAD. Flag MHD_USE_INTERNAL_POLLING_THREAD " |
5440 | "was added. Consider setting MHD_USE_INTERNAL_POLLING_THREAD explicitly.\n")); | 5445 | "was added. Consider setting MHD_USE_INTERNAL_POLLING_THREAD explicitly.\n")); |
5441 | #endif | 5446 | #endif |
5442 | flags |= MHD_USE_INTERNAL_POLLING_THREAD; | 5447 | *pflags |= MHD_USE_INTERNAL_POLLING_THREAD; |
5443 | daemon->options |= MHD_USE_INTERNAL_POLLING_THREAD; | ||
5444 | } | 5448 | } |
5445 | #ifdef HAVE_LISTEN_SHUTDOWN | 5449 | #ifdef HAVE_LISTEN_SHUTDOWN |
5446 | use_itc = (0 != (daemon->options & (MHD_USE_NO_LISTEN_SOCKET | MHD_USE_ITC))); | 5450 | use_itc = (0 != (*pflags & (MHD_USE_NO_LISTEN_SOCKET | MHD_USE_ITC))); |
5447 | #else | 5451 | #else |
5448 | use_itc = 1; /* yes, must use ITC to signal thread */ | 5452 | use_itc = 1; /* yes, must use ITC to signal thread */ |
5449 | #endif | 5453 | #endif |
5450 | if (0 == (flags & MHD_USE_INTERNAL_POLLING_THREAD)) | 5454 | if (0 == (*pflags & MHD_USE_INTERNAL_POLLING_THREAD)) |
5451 | use_itc = 0; /* useless if we are using 'external' select */ | 5455 | use_itc = 0; /* useless if we are using 'external' select */ |
5452 | if (use_itc) | 5456 | if (use_itc) |
5453 | { | 5457 | { |
@@ -5462,7 +5466,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
5462 | return NULL; | 5466 | return NULL; |
5463 | } | 5467 | } |
5464 | } | 5468 | } |
5465 | if ( (0 == (flags & (MHD_USE_POLL | MHD_USE_EPOLL))) && | 5469 | if ( (0 == (*pflags & (MHD_USE_POLL | MHD_USE_EPOLL))) && |
5466 | (1 == use_itc) && | 5470 | (1 == use_itc) && |
5467 | (! MHD_SCKT_FD_FITS_FDSET_(MHD_itc_r_fd_ (daemon->itc), | 5471 | (! MHD_SCKT_FD_FITS_FDSET_(MHD_itc_r_fd_ (daemon->itc), |
5468 | NULL)) ) | 5472 | NULL)) ) |
@@ -5481,7 +5485,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
5481 | daemon->nonce_nc_size = 4; /* tiny */ | 5485 | daemon->nonce_nc_size = 4; /* tiny */ |
5482 | #endif | 5486 | #endif |
5483 | #ifdef HTTPS_SUPPORT | 5487 | #ifdef HTTPS_SUPPORT |
5484 | if (0 != (flags & MHD_USE_TLS)) | 5488 | if (0 != (*pflags & MHD_USE_TLS)) |
5485 | { | 5489 | { |
5486 | daemon->cred_type = GNUTLS_CRD_CERTIFICATE; | 5490 | daemon->cred_type = GNUTLS_CRD_CERTIFICATE; |
5487 | } | 5491 | } |
@@ -5493,7 +5497,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
5493 | ap)) | 5497 | ap)) |
5494 | { | 5498 | { |
5495 | #ifdef HTTPS_SUPPORT | 5499 | #ifdef HTTPS_SUPPORT |
5496 | if ( (0 != (flags & MHD_USE_TLS)) && | 5500 | if ( (0 != (*pflags & MHD_USE_TLS)) && |
5497 | (NULL != daemon->priority_cache) ) | 5501 | (NULL != daemon->priority_cache) ) |
5498 | gnutls_priority_deinit (daemon->priority_cache); | 5502 | gnutls_priority_deinit (daemon->priority_cache); |
5499 | #endif /* HTTPS_SUPPORT */ | 5503 | #endif /* HTTPS_SUPPORT */ |
@@ -5511,7 +5515,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
5511 | _("Specified value for NC_SIZE too large\n")); | 5515 | _("Specified value for NC_SIZE too large\n")); |
5512 | #endif | 5516 | #endif |
5513 | #ifdef HTTPS_SUPPORT | 5517 | #ifdef HTTPS_SUPPORT |
5514 | if (0 != (flags & MHD_USE_TLS)) | 5518 | if (0 != (*pflags & MHD_USE_TLS)) |
5515 | gnutls_priority_deinit (daemon->priority_cache); | 5519 | gnutls_priority_deinit (daemon->priority_cache); |
5516 | #endif /* HTTPS_SUPPORT */ | 5520 | #endif /* HTTPS_SUPPORT */ |
5517 | free (daemon); | 5521 | free (daemon); |
@@ -5526,7 +5530,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
5526 | MHD_strerror_ (errno)); | 5530 | MHD_strerror_ (errno)); |
5527 | #endif | 5531 | #endif |
5528 | #ifdef HTTPS_SUPPORT | 5532 | #ifdef HTTPS_SUPPORT |
5529 | if (0 != (flags & MHD_USE_TLS)) | 5533 | if (0 != (*pflags & MHD_USE_TLS)) |
5530 | gnutls_priority_deinit (daemon->priority_cache); | 5534 | gnutls_priority_deinit (daemon->priority_cache); |
5531 | #endif /* HTTPS_SUPPORT */ | 5535 | #endif /* HTTPS_SUPPORT */ |
5532 | free (daemon); | 5536 | free (daemon); |
@@ -5541,7 +5545,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
5541 | _("MHD failed to initialize nonce-nc mutex\n")); | 5545 | _("MHD failed to initialize nonce-nc mutex\n")); |
5542 | #endif | 5546 | #endif |
5543 | #ifdef HTTPS_SUPPORT | 5547 | #ifdef HTTPS_SUPPORT |
5544 | if (0 != (flags & MHD_USE_TLS)) | 5548 | if (0 != (*pflags & MHD_USE_TLS)) |
5545 | gnutls_priority_deinit (daemon->priority_cache); | 5549 | gnutls_priority_deinit (daemon->priority_cache); |
5546 | #endif /* HTTPS_SUPPORT */ | 5550 | #endif /* HTTPS_SUPPORT */ |
5547 | free (daemon->nnc); | 5551 | free (daemon->nnc); |
@@ -5551,7 +5555,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
5551 | #endif | 5555 | #endif |
5552 | 5556 | ||
5553 | /* Thread pooling currently works only with internal select thread model */ | 5557 | /* Thread pooling currently works only with internal select thread model */ |
5554 | if ( (0 == (flags & MHD_USE_INTERNAL_POLLING_THREAD)) && | 5558 | if ( (0 == (*pflags & MHD_USE_INTERNAL_POLLING_THREAD)) && |
5555 | (daemon->worker_pool_size > 0) ) | 5559 | (daemon->worker_pool_size > 0) ) |
5556 | { | 5560 | { |
5557 | #ifdef HAVE_MESSAGES | 5561 | #ifdef HAVE_MESSAGES |
@@ -5562,7 +5566,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
5562 | } | 5566 | } |
5563 | 5567 | ||
5564 | #ifdef __SYMBIAN32__ | 5568 | #ifdef __SYMBIAN32__ |
5565 | if (0 != (flags & (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_THREAD_PER_CONNECTION))) | 5569 | if (0 != (*pflags & (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_THREAD_PER_CONNECTION))) |
5566 | { | 5570 | { |
5567 | #ifdef HAVE_MESSAGES | 5571 | #ifdef HAVE_MESSAGES |
5568 | MHD_DLOG (daemon, | 5572 | MHD_DLOG (daemon, |
@@ -5572,10 +5576,10 @@ MHD_start_daemon_va (unsigned int flags, | |||
5572 | } | 5576 | } |
5573 | #endif | 5577 | #endif |
5574 | if ( (MHD_INVALID_SOCKET == daemon->listen_fd) && | 5578 | if ( (MHD_INVALID_SOCKET == daemon->listen_fd) && |
5575 | (0 == (daemon->options & MHD_USE_NO_LISTEN_SOCKET)) ) | 5579 | (0 == (*pflags & MHD_USE_NO_LISTEN_SOCKET)) ) |
5576 | { | 5580 | { |
5577 | /* try to open listen socket */ | 5581 | /* try to open listen socket */ |
5578 | listen_fd = MHD_socket_create_listen_(flags & MHD_USE_IPv6); | 5582 | listen_fd = MHD_socket_create_listen_(*pflags & MHD_USE_IPv6); |
5579 | if (MHD_INVALID_SOCKET == listen_fd) | 5583 | if (MHD_INVALID_SOCKET == listen_fd) |
5580 | { | 5584 | { |
5581 | #ifdef HAVE_MESSAGES | 5585 | #ifdef HAVE_MESSAGES |
@@ -5698,7 +5702,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
5698 | 5702 | ||
5699 | /* check for user supplied sockaddr */ | 5703 | /* check for user supplied sockaddr */ |
5700 | #if HAVE_INET6 | 5704 | #if HAVE_INET6 |
5701 | if (0 != (flags & MHD_USE_IPv6)) | 5705 | if (0 != (*pflags & MHD_USE_IPv6)) |
5702 | addrlen = sizeof (struct sockaddr_in6); | 5706 | addrlen = sizeof (struct sockaddr_in6); |
5703 | else | 5707 | else |
5704 | #endif | 5708 | #endif |
@@ -5706,7 +5710,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
5706 | if (NULL == servaddr) | 5710 | if (NULL == servaddr) |
5707 | { | 5711 | { |
5708 | #if HAVE_INET6 | 5712 | #if HAVE_INET6 |
5709 | if (0 != (flags & MHD_USE_IPv6)) | 5713 | if (0 != (*pflags & MHD_USE_IPv6)) |
5710 | { | 5714 | { |
5711 | memset (&servaddr6, | 5715 | memset (&servaddr6, |
5712 | 0, | 5716 | 0, |
@@ -5734,7 +5738,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
5734 | } | 5738 | } |
5735 | daemon->listen_fd = listen_fd; | 5739 | daemon->listen_fd = listen_fd; |
5736 | 5740 | ||
5737 | if (0 != (flags & MHD_USE_IPv6)) | 5741 | if (0 != (*pflags & MHD_USE_IPv6)) |
5738 | { | 5742 | { |
5739 | #ifdef IPPROTO_IPV6 | 5743 | #ifdef IPPROTO_IPV6 |
5740 | #ifdef IPV6_V6ONLY | 5744 | #ifdef IPV6_V6ONLY |
@@ -5743,7 +5747,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
5743 | and may also be missing on older POSIX systems; good luck if you have any of those, | 5747 | and may also be missing on older POSIX systems; good luck if you have any of those, |
5744 | your IPv6 socket may then also bind against IPv4 anyway... */ | 5748 | your IPv6 socket may then also bind against IPv4 anyway... */ |
5745 | const MHD_SCKT_OPT_BOOL_ v6_only = | 5749 | const MHD_SCKT_OPT_BOOL_ v6_only = |
5746 | (MHD_USE_DUAL_STACK != (flags & MHD_USE_DUAL_STACK)); | 5750 | (MHD_USE_DUAL_STACK != (*pflags & MHD_USE_DUAL_STACK)); |
5747 | if (0 > setsockopt (listen_fd, | 5751 | if (0 > setsockopt (listen_fd, |
5748 | IPPROTO_IPV6, IPV6_V6ONLY, | 5752 | IPPROTO_IPV6, IPV6_V6ONLY, |
5749 | (const void *) &v6_only, | 5753 | (const void *) &v6_only, |
@@ -5770,7 +5774,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
5770 | goto free_and_fail; | 5774 | goto free_and_fail; |
5771 | } | 5775 | } |
5772 | #ifdef TCP_FASTOPEN | 5776 | #ifdef TCP_FASTOPEN |
5773 | if (0 != (flags & MHD_USE_TCP_FASTOPEN)) | 5777 | if (0 != (*pflags & MHD_USE_TCP_FASTOPEN)) |
5774 | { | 5778 | { |
5775 | if (0 == daemon->fastopen_queue_size) | 5779 | if (0 == daemon->fastopen_queue_size) |
5776 | daemon->fastopen_queue_size = MHD_TCP_FASTOPEN_QUEUE_SIZE_DEFAULT; | 5780 | daemon->fastopen_queue_size = MHD_TCP_FASTOPEN_QUEUE_SIZE_DEFAULT; |
@@ -5813,7 +5817,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
5813 | _("Failed to set nonblocking mode on listening socket: %s\n"), | 5817 | _("Failed to set nonblocking mode on listening socket: %s\n"), |
5814 | MHD_socket_last_strerr_()); | 5818 | MHD_socket_last_strerr_()); |
5815 | #endif | 5819 | #endif |
5816 | if (0 != (flags & MHD_USE_EPOLL) || | 5820 | if (0 != (*pflags & MHD_USE_EPOLL) || |
5817 | daemon->worker_pool_size > 0) | 5821 | daemon->worker_pool_size > 0) |
5818 | { | 5822 | { |
5819 | /* Accept must be non-blocking. Multiple children may wake up | 5823 | /* Accept must be non-blocking. Multiple children may wake up |
@@ -5826,7 +5830,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
5826 | if ( (MHD_INVALID_SOCKET != listen_fd) && | 5830 | if ( (MHD_INVALID_SOCKET != listen_fd) && |
5827 | (! MHD_SCKT_FD_FITS_FDSET_(listen_fd, | 5831 | (! MHD_SCKT_FD_FITS_FDSET_(listen_fd, |
5828 | NULL)) && | 5832 | NULL)) && |
5829 | (0 == (flags & (MHD_USE_POLL | MHD_USE_EPOLL)) ) ) | 5833 | (0 == (*pflags & (MHD_USE_POLL | MHD_USE_EPOLL)) ) ) |
5830 | { | 5834 | { |
5831 | #ifdef HAVE_MESSAGES | 5835 | #ifdef HAVE_MESSAGES |
5832 | MHD_DLOG (daemon, | 5836 | MHD_DLOG (daemon, |
@@ -5839,11 +5843,11 @@ MHD_start_daemon_va (unsigned int flags, | |||
5839 | } | 5843 | } |
5840 | 5844 | ||
5841 | #ifdef EPOLL_SUPPORT | 5845 | #ifdef EPOLL_SUPPORT |
5842 | if ( (0 != (flags & MHD_USE_EPOLL)) && | 5846 | if ( (0 != (*pflags & MHD_USE_EPOLL)) && |
5843 | (0 == daemon->worker_pool_size) && | 5847 | (0 == daemon->worker_pool_size) && |
5844 | (0 == (daemon->options & MHD_USE_NO_LISTEN_SOCKET)) ) | 5848 | (0 == (*pflags & MHD_USE_NO_LISTEN_SOCKET)) ) |
5845 | { | 5849 | { |
5846 | if (0 != (flags & MHD_USE_THREAD_PER_CONNECTION)) | 5850 | if (0 != (*pflags & MHD_USE_THREAD_PER_CONNECTION)) |
5847 | { | 5851 | { |
5848 | #ifdef HAVE_MESSAGES | 5852 | #ifdef HAVE_MESSAGES |
5849 | MHD_DLOG (daemon, | 5853 | MHD_DLOG (daemon, |
@@ -5880,7 +5884,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
5880 | 5884 | ||
5881 | #ifdef HTTPS_SUPPORT | 5885 | #ifdef HTTPS_SUPPORT |
5882 | /* initialize HTTPS daemon certificate aspects & send / recv functions */ | 5886 | /* initialize HTTPS daemon certificate aspects & send / recv functions */ |
5883 | if ( (0 != (flags & MHD_USE_TLS)) && | 5887 | if ( (0 != (*pflags & MHD_USE_TLS)) && |
5884 | (0 != MHD_TLS_init (daemon)) ) | 5888 | (0 != MHD_TLS_init (daemon)) ) |
5885 | { | 5889 | { |
5886 | #ifdef HAVE_MESSAGES | 5890 | #ifdef HAVE_MESSAGES |
@@ -5894,11 +5898,11 @@ MHD_start_daemon_va (unsigned int flags, | |||
5894 | goto free_and_fail; | 5898 | goto free_and_fail; |
5895 | } | 5899 | } |
5896 | #endif /* HTTPS_SUPPORT */ | 5900 | #endif /* HTTPS_SUPPORT */ |
5897 | if ( ( (0 != (flags & MHD_USE_INTERNAL_POLLING_THREAD)) && | 5901 | if ( ( (0 != (*pflags & MHD_USE_INTERNAL_POLLING_THREAD)) && |
5898 | (0 == daemon->worker_pool_size) ) && | 5902 | (0 == daemon->worker_pool_size) ) && |
5899 | (0 == (daemon->options & MHD_USE_NO_LISTEN_SOCKET)) && | 5903 | (0 == (*pflags & MHD_USE_NO_LISTEN_SOCKET)) && |
5900 | (! MHD_create_named_thread_ (&daemon->pid, | 5904 | (! MHD_create_named_thread_ (&daemon->pid, |
5901 | (flags & MHD_USE_THREAD_PER_CONNECTION) ? | 5905 | (*pflags & MHD_USE_THREAD_PER_CONNECTION) ? |
5902 | "MHD-listen" : "MHD-single", | 5906 | "MHD-listen" : "MHD-single", |
5903 | daemon->thread_stack_size, | 5907 | daemon->thread_stack_size, |
5904 | &MHD_select_thread, | 5908 | &MHD_select_thread, |
@@ -5916,7 +5920,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
5916 | goto free_and_fail; | 5920 | goto free_and_fail; |
5917 | } | 5921 | } |
5918 | if ( (daemon->worker_pool_size > 0) && | 5922 | if ( (daemon->worker_pool_size > 0) && |
5919 | (0 == (daemon->options & MHD_USE_NO_LISTEN_SOCKET)) ) | 5923 | (0 == (*pflags & MHD_USE_NO_LISTEN_SOCKET)) ) |
5920 | { | 5924 | { |
5921 | /* Coarse-grained count of connections per thread (note error | 5925 | /* Coarse-grained count of connections per thread (note error |
5922 | * due to integer division). Also keep track of how many | 5926 | * due to integer division). Also keep track of how many |
@@ -5961,7 +5965,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
5961 | goto thread_failed; | 5965 | goto thread_failed; |
5962 | } | 5966 | } |
5963 | } | 5967 | } |
5964 | if ( (0 == (flags & (MHD_USE_POLL | MHD_USE_EPOLL))) && | 5968 | if ( (0 == (*pflags & (MHD_USE_POLL | MHD_USE_EPOLL))) && |
5965 | (! MHD_SCKT_FD_FITS_FDSET_(MHD_itc_r_fd_ (d->itc), | 5969 | (! MHD_SCKT_FD_FITS_FDSET_(MHD_itc_r_fd_ (d->itc), |
5966 | NULL)) ) | 5970 | NULL)) ) |
5967 | { | 5971 | { |
@@ -5980,7 +5984,7 @@ MHD_start_daemon_va (unsigned int flags, | |||
5980 | if (i < leftover_conns) | 5984 | if (i < leftover_conns) |
5981 | ++d->connection_limit; | 5985 | ++d->connection_limit; |
5982 | #ifdef EPOLL_SUPPORT | 5986 | #ifdef EPOLL_SUPPORT |
5983 | if ( (0 != (daemon->options & MHD_USE_EPOLL)) && | 5987 | if ( (0 != (*pflags & MHD_USE_EPOLL)) && |
5984 | (MHD_YES != setup_epoll_to_listen (d)) ) | 5988 | (MHD_YES != setup_epoll_to_listen (d)) ) |
5985 | goto thread_failed; | 5989 | goto thread_failed; |
5986 | #endif | 5990 | #endif |
@@ -6072,7 +6076,7 @@ thread_failed: | |||
6072 | MHD_mutex_destroy_chk_ (&daemon->nnc_lock); | 6076 | MHD_mutex_destroy_chk_ (&daemon->nnc_lock); |
6073 | #endif | 6077 | #endif |
6074 | #ifdef HTTPS_SUPPORT | 6078 | #ifdef HTTPS_SUPPORT |
6075 | if (0 != (flags & MHD_USE_TLS)) | 6079 | if (0 != (*pflags & MHD_USE_TLS)) |
6076 | gnutls_priority_deinit (daemon->priority_cache); | 6080 | gnutls_priority_deinit (daemon->priority_cache); |
6077 | #endif /* HTTPS_SUPPORT */ | 6081 | #endif /* HTTPS_SUPPORT */ |
6078 | if (MHD_ITC_IS_VALID_(daemon->itc)) | 6082 | if (MHD_ITC_IS_VALID_(daemon->itc)) |