30#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
40#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
50#ifdef MHD_USE_SYS_TSEARCH
58#ifdef MHD_HTTPS_REQUIRE_GCRYPT
63#if defined(_WIN32) && ! defined(__CYGWIN__)
64#ifndef WIN32_LEAN_AND_MEAN
65#define WIN32_LEAN_AND_MEAN 1
70#ifdef MHD_USE_POSIX_THREADS
79#ifdef MHD_POSIX_SOCKETS
80#define MHD_MAX_CONNECTIONS_DEFAULT (FD_SETSIZE - 3 - 1 - MHD_ITC_NUM_FDS_)
82#define MHD_MAX_CONNECTIONS_DEFAULT (FD_SETSIZE - 2)
88#define MHD_POOL_SIZE_DEFAULT (32 * 1024)
134#ifdef _AUTOINIT_FUNCS_ARE_SUPPORTED
139#define MHD_check_global_init_() (void) 0
146#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
147#ifdef MHD_MUTEX_STATIC_DEFN_INIT_
163#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
164#ifdef MHD_MUTEX_STATIC_DEFN_INIT_
170#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
171#ifdef MHD_MUTEX_STATIC_DEFN_INIT_
262#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
279#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
318 struct MHD_IPCount *key)
327 if (
AF_INET == addr->ss_family)
374 struct MHD_IPCount *
keyp;
375 struct MHD_IPCount **
nodep;
383 newkeyp = (
struct MHD_IPCount *) malloc (
sizeof(
struct MHD_IPCount));
408 _ (
"Failed to add IP connection count node.\n"));
464 MHD_PANIC (
_ (
"Failed to find previously-added IP address.\n"));
470 MHD_PANIC (
_ (
"Previously-added IP address had counter of zero.\n"));
500#if GNUTLS_VERSION_MAJOR >= 3
501 if (
NULL != daemon->cert_callback)
504 daemon->cert_callback);
507#if GNUTLS_VERSION_NUMBER >= 0x030603
508 else if (
NULL != daemon->cert_callback2)
511 daemon->cert_callback2);
515 if (
NULL != daemon->https_mem_trust)
523 _ (
"Too long trust certificate.\n"));
535 _ (
"Bad trust certificate format.\n"));
541 if (daemon->have_dhparams)
544 daemon->https_mem_dhparams);
547 if ( (
NULL != daemon->https_mem_cert) &&
548 (
NULL != daemon->https_mem_key) )
560 _ (
"Too long key or certificate.\n"));
569 if (
NULL != daemon->https_key_password)
571#if GNUTLS_VERSION_NUMBER >= 0x030111
576 daemon->https_key_password,
581 _ (
"Failed to setup x509 certificate/key: pre 3.X.X version " \
582 "of GnuTLS does not support setting key password.\n"));
595 _ (
"GnuTLS failed to setup x509 certificate/key: %s\n"),
600#if GNUTLS_VERSION_MAJOR >= 3
601 if (
NULL != daemon->cert_callback)
604#if GNUTLS_VERSION_NUMBER >= 0x030603
605 else if (
NULL != daemon->cert_callback2)
610 _ (
"You need to specify a certificate and key location.\n"));
625 switch (daemon->cred_type)
643 _ (
"Error: invalid credentials type %d specified.\n"),
700 daemon->fdset_size_set_by_app ?
701 ((
unsigned int) daemon->fdset_size) :
710#if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT)
735#ifndef HAS_FD_SETSIZE_OVERRIDABLE
744 if ( (
urh->in_buffer_used <
urh->in_buffer_size) &&
750 if ( (0 !=
urh->out_buffer_used) &&
759 ((0 !=
urh->in_buffer_size) ||
760 (0 !=
urh->out_buffer_size) ||
761 (0 !=
urh->out_buffer_used))
770 if ( (
urh->out_buffer_used <
urh->out_buffer_size) &&
776 if ( (0 !=
urh->in_buffer_used) &&
785 ((0 !=
urh->out_buffer_size) ||
786 (0 !=
urh->in_buffer_size) ||
787 (0 !=
urh->in_buffer_used))
827#ifndef HAS_FD_SETSIZE_OVERRIDABLE
889 if (
urh->in_buffer_used <
urh->in_buffer_size)
891 if (0 !=
urh->out_buffer_used)
897 ((0 !=
urh->in_buffer_size) ||
898 (0 !=
urh->out_buffer_size) ||
899 (0 !=
urh->out_buffer_used)))
902 if (
urh->out_buffer_used <
urh->out_buffer_size)
904 if (0 !=
urh->in_buffer_used)
910 ((0 !=
urh->out_buffer_size) ||
911 (0 !=
urh->in_buffer_size) ||
912 (0 !=
urh->in_buffer_used)))
927 p[0].fd =
urh->connection->socket_fd;
928 p[1].fd =
urh->mhd.socket;
1000#ifndef HAS_FD_SETSIZE_OVERRIDABLE
1057#ifdef MHD_POSIX_SOCKETS
1071#ifdef MHD_POSIX_SOCKETS
1092#ifdef MHD_WINSOCK_SOCKETS
1108#if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT)
1141#if _MHD_DEBUG_CONNECT
1145 _ (
"Maximum socket in select set: %d\n"),
1195 if ( (
NULL == daemon) ||
1206 _ (
"MHD_get_fdset2() called with except_fd_set "
1207 "set to NULL. Such behavior is unsupported.\n"));
1211#ifdef HAS_FD_SETSIZE_OVERRIDABLE
1217 else if (daemon->fdset_size > ((
int)
fd_setsize))
1219 if (daemon->fdset_size_set_by_app)
1222 _ (
"%s() called with fd_setsize (%u) " \
1223 "less than value set by MHD_OPTION_APP_FD_SETSIZE (%d). " \
1224 "Some socket FDs may be not processed. " \
1225 "Use MHD_OPTION_APP_FD_SETSIZE with the correct value.\n"),
1226 "MHD_get_fdset2",
fd_setsize, daemon->fdset_size);
1231 _ (
"%s() called with fd_setsize (%u) " \
1232 "less than FD_SETSIZE used by MHD (%d). " \
1233 "Some socket FDs may be not processed. " \
1234 "Consider using MHD_OPTION_APP_FD_SETSIZE option.\n"),
1235 "MHD_get_fdset2",
fd_setsize, daemon->fdset_size);
1244 _ (
"%s() called with fd_setsize (%u) " \
1245 "less than fixed FD_SETSIZE value (%d) used on the " \
1312 if (
con->tls_read_ready)
1386 if ( (!
con->daemon->data_already_pending) &&
1390 con->daemon->data_already_pending =
true;
1392 else if ( (
con->tls_read_ready) &&
1394 con->daemon->data_already_pending =
true;
1401#ifdef UPGRADE_SUPPORT
1429 connection->urh =
NULL;
1437#if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT)
1460#ifdef MHD_USE_THREADS
1471 if (!
urh->was_closed)
1474 _ (
"Initiated daemon shutdown while \"upgraded\" " \
1475 "connection was not closed.\n"));
1478 urh->was_closed =
true;
1485 if (0 <
urh->in_buffer_used)
1489 _ (
"Failed to forward to application %" PRIu64 \
1490 " bytes of data received from remote side: " \
1491 "application closed data forwarding.\n"),
1497 urh->in_buffer_used = 0;
1501 urh->in_buffer_size = 0;
1518 &
urh->app.celi)) ||
1520 (
urh->in_buffer_used <
urh->in_buffer_size))
1530 &
urh->in_buffer[
urh->in_buffer_used],
1545 urh->in_buffer_size = 0;
1568 && (
urh->out_buffer_used <
urh->out_buffer_size))
1578 &
urh->out_buffer[
urh->out_buffer_used],
1598 urh->out_buffer_size = 0;
1614 (
urh->out_buffer_used > 0) )
1619 data_size =
urh->out_buffer_used;
1637 _ (
"Failed to forward to remote client %" PRIu64 \
1638 " bytes of data received from application: %s\n"),
1643 urh->out_buffer_used = 0;
1645 urh->out_buffer_size = 0;
1661 if ( (0 ==
urh->out_buffer_used) &&
1669 urh->out_buffer_size = 0;
1678 (
urh->in_buffer_used > 0) )
1683 data_size =
urh->in_buffer_used;
1703 _ (
"Failed to forward to application %" PRIu64 \
1704 " bytes of data received from remote side: %s\n"),
1709 urh->in_buffer_used = 0;
1711 urh->in_buffer_size = 0;
1725 if (data_size > (
size_t)
res)
1730 if ( (0 ==
urh->in_buffer_used) &&
1736 urh->in_buffer_size = 0;
1745 (
urh->in_buffer_used <
urh->in_buffer_size) &&
1750 ( (0 !=
urh->out_buffer_size) ||
1751 (0 !=
urh->out_buffer_used) ) )
1755 if (0 <
urh->out_buffer_used)
1757 _ (
"Failed to forward to remote client %" PRIu64 \
1758 " bytes of data received from application: daemon shut down.\n"),
1762 urh->out_buffer_used = 0;
1766 urh->out_buffer_size = 0;
1777#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
1778#ifdef UPGRADE_SUPPORT
1802 while ( (0 !=
urh->in_buffer_size) ||
1803 (0 !=
urh->out_buffer_size) ||
1804 (0 !=
urh->in_buffer_used) ||
1805 (0 !=
urh->out_buffer_used) )
1829 _ (
"Error preparing select.\n"));
1838 if (((
con->tls_read_ready) &&
1839 (
urh->in_buffer_used <
urh->in_buffer_size)) ||
1864 _ (
"Error during select (%d): `%s'\n"),
1886 p[0].fd =
urh->connection->socket_fd;
1887 p[1].fd =
urh->mhd.socket;
1889 while ( (0 !=
urh->in_buffer_size) ||
1890 (0 !=
urh->out_buffer_size) ||
1891 (0 !=
urh->in_buffer_used) ||
1892 (0 !=
urh->out_buffer_used) )
1898 if (((
con->tls_read_ready) &&
1899 (
urh->in_buffer_used <
urh->in_buffer_size)) ||
1915 _ (
"Error during poll: `%s'\n"),
2008#define EXTRA_SLOTS 1
2010#define EXTRA_SLOTS 0
2028#ifdef UPGRADE_SUPPORT
2031 static const void *
const urh =
NULL;
2034 if ( (
con->suspended) &&
2047 #ifdef HAVE_MESSAGES
2049 _ (
"Failed to add FD to fd_set.\n"));
2065 _ (
"Error during select (%d): `%s'\n"),
2086 _ (
"Error during poll: `%s'\n"),
2108 || ( (
con->tls_read_ready) &&
2124 else if (
con->connection_timeout_ms > 0)
2127#if (SIZEOF_UINT64_T - 2) >= SIZEOF_STRUCT_TIMEVAL_TV_SEC
2144 switch (
con->event_loop_info)
2186 _ (
"Failed to add FD to fd_set.\n"));
2204 _ (
"Error during select (%d): `%s'\n"),
2235 else if (
con->connection_timeout_ms > 0)
2238#if SIZEOF_UINT64_T >= SIZEOF_INT
2250 p[0].fd =
con->socket_fd;
2251 switch (
con->event_loop_info)
2289 _ (
"Error during poll: `%s'\n"),
2309#ifdef UPGRADE_SUPPORT
2315 (
con->rq.client_aware) )
2318 &
con->rq.client_context,
2320 con->rq.client_aware =
false;
2326 con->urh->clean_ready =
true;
2341 _ (
"Processing thread terminating. Closing connection.\n"));
2359 shutdown (
con->socket_fd,
2370 _ (
"Failed to signal thread termination via inter-thread " \
2371 "communication channel.\n"));
2391#if defined(HTTPS_SUPPORT)
2392#if defined(MHD_SEND_SPIPE_SUPPRESS_NEEDED) && \
2393 defined(MHD_SEND_SPIPE_SUPPRESS_POSSIBLE) && \
2394 ! defined(MHD_socket_nosignal_) && \
2395 (GNUTLS_VERSION_NUMBER + 0 < 0x030402) && defined(MSG_NOSIGNAL)
2401#define MHD_TLSLIB_NEED_PUSH_FUNC 1
2407#ifdef MHD_TLSLIB_NEED_PUSH_FUNC
2417#if (MHD_SCKT_SEND_MAX_SIZE_ < SSIZE_MAX) || (0 == SSIZE_MAX)
2438 const char *username,
2443#if GNUTLS_VERSION_MAJOR >= 3
2449 if (
NULL == connection)
2453 MHD_PANIC (
_ (
"Internal server error. This should be impossible.\n"));
2457 daemon = connection->
daemon;
2458#if GNUTLS_VERSION_MAJOR >= 3
2459 if (
NULL == daemon->cred_callback)
2463 _ (
"PSK not supported by this server.\n"));
2467 if (0 != daemon->cred_callback (daemon->cred_callback_cls,
2477 _ (
"PSK authentication failed: gnutls_malloc failed to " \
2478 "allocate memory.\n"));
2487 _ (
"PSK authentication failed: PSK too long.\n"));
2502 _ (
"PSK not supported by this server.\n"));
2548#if _MHD_DEBUG_CONNECT
2550 _ (
"Accepted connection on socket %d.\n"),
2562 _ (
"Server reached connection limit. " \
2563 "Closing inbound connection.\n"));
2566#if defined(ENFILE) && (ENFILE + 0 != 0)
2581 _ (
"Connection rejected by application. Closing connection.\n"));
2588#if defined(EACCESS) && (EACCESS + 0 != 0)
2599 _ (
"Error allocating memory: %s\n"),
2628 _ (
"Error allocating memory: %s\n"),
2650#ifdef MHD_USE_THREADS
2667#if (GNUTLS_VERSION_NUMBER + 0 >= 0x030500)
2675#if (GNUTLS_VERSION_NUMBER + 0 >= 0x030402)
2678#if GNUTLS_VERSION_MAJOR >= 3
2681#if (GNUTLS_VERSION_NUMBER + 0 >= 0x030603)
2685#if (GNUTLS_VERSION_NUMBER + 0 >= 0x030605)
2693 daemon->priority_cache)))
2695 if (
NULL != connection->tls_session)
2702 free (connection->
addr);
2706 _ (
"Failed to initialise TLS session.\n"));
2708#if defined(EPROTO) && (EPROTO + 0 != 0)
2713#if (GNUTLS_VERSION_NUMBER + 0 >= 0x030200)
2714 if (!
daemon->disable_alpn)
2716 static const char prt1[] =
"http/1.1";
2717 static const char prt2[] =
"http/1.0";
2730 _ (
"Failed to set ALPN protocols.\n"));
2739 switch (
daemon->cred_type)
2760 _ (
"Failed to setup TLS credentials: " \
2761 "unknown credential type %d.\n"),
2770 free (connection->
addr);
2772 MHD_PANIC (
_ (
"Unknown credential type.\n"));
2773#if defined(EINVAL) && (EINVAL + 0 != 0)
2778#if (GNUTLS_VERSION_NUMBER + 0 >= 0x030109) && ! defined(_WIN64)
2786#ifdef MHD_TLSLIB_NEED_PUSH_FUNC
2790 if (
daemon->https_mem_trust)
2798 free (connection->
addr);
2800 MHD_PANIC (
_ (
"TLS connection on non-TLS daemon.\n"));
2813#ifdef MHD_USE_THREADS
2832 if (
NULL != connection->tls_session)
2843 free (connection->
addr);
2869#ifdef MHD_USE_THREADS
2886 _ (
"Error allocating memory: %s\n"),
2889#if defined(ENOMEM) && (ENOMEM + 0 != 0)
2903 _ (
"Server reached connection limit. "
2904 "Closing inbound connection.\n"));
2906#if defined(ENFILE) && (ENFILE + 0 != 0)
2932#ifdef MHD_USE_THREADS
2938 daemon->thread_stack_size,
2947 _ (
"Failed to create a new thread because it would "
2948 "have exceeded the system limit on the number of "
2949 "threads or no system resources available.\n"));
2953 _ (
"Failed to create a thread: %s\n"),
2965#ifdef MHD_USE_THREADS
2966 connection->tid =
daemon->tid;
2976 event.data.ptr = connection;
2985 _ (
"Call to epoll_ctl failed: %s\n"),
3002 daemon->eready_tail,
3036 if (
NULL != connection->tls_session)
3043 free (connection->
addr);
3096#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
3106 _ (
"New connection socket descriptor (%d) is not less " \
3107 "than FD_SETSIZE (%d).\n"),
3112#if defined(ENFILE) && (ENFILE + 0 != 0)
3123 _ (
"Epoll mode supports only non-blocking sockets\n"));
3126#if defined(EINVAL) && (EINVAL + 0 != 0)
3139 if (
NULL == connection)
3160 _ (
"Failed to signal new connection via inter-thread " \
3161 "communication channel.\n"));
3205 _ (
"Failed to start serving new connection.\n"));
3229#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
3239#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
3269 daemon->eready_tail,
3271 connection->epoll_state &=
3280 MHD_PANIC (
_ (
"Failed to remove FD from epoll set.\n"));
3281 connection->epoll_state &=
3287#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
3326#ifdef MHD_USE_THREADS
3333 MHD_PANIC (
_ (
"Cannot suspend connections without " \
3334 "enabling MHD_ALLOW_SUSPEND_RESUME!\n"));
3335#ifdef UPGRADE_SUPPORT
3336 if (
NULL != connection->urh)
3340 _ (
"Error: connection scheduled for \"upgrade\" cannot " \
3341 "be suspended.\n"));
3368#if defined(MHD_USE_THREADS)
3373 MHD_PANIC (
_ (
"Cannot resume connections without enabling " \
3374 "MHD_ALLOW_SUSPEND_RESUME!\n"));
3375#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
3380#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
3388 _ (
"Failed to signal resume via inter-thread " \
3389 "communication channel.\n"));
3395#ifdef UPGRADE_SUPPORT
3408#if defined(MHD_USE_THREADS)
3415 connection->urh->was_closed =
true;
3424 _ (
"Failed to signal resume via " \
3425 "inter-thread communication channel.\n"));
3450#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
3457#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
3473#ifdef UPGRADE_SUPPORT
3476 static const void *
const urh =
NULL;
3482 ( (!
urh->was_closed) ||
3483 (!
urh->clean_ready) ) )
3517 MHD_PANIC (
"Resumed connection was already in EREADY set.\n");
3521 daemon->eready_tail,
3530#ifdef UPGRADE_SUPPORT
3555#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
3566 _ (
"Failed to signal resume of connection via " \
3567 "inter-thread communication channel.\n"));
3622 _ (
"MHD_add_connection() has been called for daemon started"
3623 " without MHD_USE_ITC flag.\nDaemon will not process newly"
3624 " added connection until any activity occurs in already"
3625 " added sockets.\n"));
3630 if (
AF_INET == addr->sa_family)
3636 _ (
"MHD_add_connection() has been called with "
3637 "incorrect 'addrlen' value.\n"));
3641#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
3642 if ((0 != addr->sa_len) &&
3643 (
sizeof(
struct sockaddr_in) > (
size_t) addr->sa_len) )
3647 _ (
"MHD_add_connection() has been called with " \
3648 "non-zero value of 'sa_len' member of " \
3649 "'struct sockaddr' which does not match 'sa_family'.\n"));
3662 _ (
"MHD_add_connection() has been called with "
3663 "incorrect 'addrlen' value.\n"));
3667#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
3668 if ((0 != addr->sa_len) &&
3669 (
sizeof(
struct sockaddr_in6) > (
size_t) addr->sa_len) )
3673 _ (
"MHD_add_connection() has been called with " \
3674 "non-zero value of 'sa_len' member of " \
3675 "'struct sockaddr' which does not match 'sa_family'.\n"));
3681#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
3682 if ((0 != addr->sa_len) &&
3693 _ (
"Failed to set nonblocking mode on new client socket: %s\n"),
3701#ifndef MHD_WINSOCK_SOCKETS
3706#if defined(MHD_socket_nosignal_)
3713 _ (
"Failed to suppress SIGPIPE on new client socket: %s\n"),
3737 _ (
"Failed to set noninheritable mode on new client socket.\n"));
3744#ifdef HAVE_STRUCT_SOCKADDR_STORAGE_SS_LEN
3748#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
3772#if defined(ENFILE) && (ENFILE + 0 != 0)
3815#if defined(_DEBUG) && defined (USE_ACCEPT4)
3817#elif defined (USE_ACCEPT4)
3823#ifdef MHD_USE_THREADS
3837#ifdef HAVE_STRUCT_SOCKADDR_STORAGE_SS_LEN
3857#ifndef MHD_WINSOCK_SOCKETS
3865#if defined(_DEBUG) || ! defined(USE_ACCEPT4)
3872#ifdef MHD_ACCEPT_INHERIT_NONBLOCK
3877#ifndef MHD_WINSOCK_SOCKETS
3899 _ (
"Error accepting connection: %s\n"),
3912 _ (
"Hit process or system resource limit at FIRST " \
3913 "connection. This is really bad as there is no sane " \
3914 "way to proceed. Will try busy waiting for system " \
3915 "resources to become magically available.\n"));
3920#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
3924#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
3929 _ (
"Hit process or system resource limit at %u " \
3930 "connections, temporarily suspending accept(). " \
3931 "Consider setting a lower MHD_OPTION_CONNECTION_LIMIT.\n"),
3945 _ (
"Accepted socket has zero-length address. "
3946 "Processing the new socket as a socket with " \
3947 "unknown type.\n"));
3958 _ (
"Accepted socket address is larger than expected by " \
3959 "system headers. Processing the new socket as a socket with " \
3960 "unknown type.\n"));
3970 _ (
"Failed to set nonblocking mode on incoming connection " \
3984 _ (
"Failed to set noninheritable mode on incoming connection " \
3991#if defined(MHD_socket_nosignal_)
3996 _ (
"Failed to suppress SIGPIPE on incoming connection " \
4016#if _MHD_DEBUG_CONNECT
4018 _ (
"Accepted connection on socket %d\n"),
4047#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
4059#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
4064 MHD_PANIC (
_ (
"Failed to join a thread.\n"));
4066#ifdef UPGRADE_SUPPORT
4071 if (
NULL != pos->tls_session)
4095 if ( (-1 !=
daemon->epoll_fd) &&
4108 MHD_PANIC (
_ (
"Failed to remove FD from epoll set.\n"));
4126#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
4132#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
4180#if SIZEOF_UINT64_T > SIZEOF_UNSIGNED_LONG_LONG
4234#ifdef MHD_USE_THREADS
4243 _ (
"Illegal call to MHD_get_timeout.\n"));
4275 if ( (
NULL != pos) &&
4305#if defined(HAVE_POLL) || defined(EPOLL_SUPPORT)
4399#if SIZEOF_INT >= SIZEOF_INT64_T
4460#if SIZEOF_INT < SIZEOF_INT64_T
4489#if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT)
4503#ifndef HAS_FD_SETSIZE_OVERRIDABLE
4585#if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT)
4599 if ( (0 ==
urh->in_buffer_size) &&
4600 (0 ==
urh->out_buffer_size) &&
4601 (0 ==
urh->in_buffer_used) &&
4602 (0 ==
urh->out_buffer_used) )
4605 urh->clean_ready =
true;
4616#undef MHD_run_from_select
4665 _ (
"MHD_run_from_select() called with except_fd_set "
4666 "set to NULL. Such behavior is deprecated.\n"));
4670#ifdef HAS_FD_SETSIZE_OVERRIDABLE
4678 if (
daemon->fdset_size_set_by_app)
4681 _ (
"%s() called with fd_setsize (%u) " \
4682 "less than value set by MHD_OPTION_APP_FD_SETSIZE (%d). " \
4683 "Some socket FDs may be not processed. " \
4684 "Use MHD_OPTION_APP_FD_SETSIZE with the correct value.\n"),
4690 _ (
"%s() called with fd_setsize (%u) " \
4691 "less than FD_SETSIZE used by MHD (%d). " \
4692 "Some socket FDs may be not processed. " \
4693 "Consider using MHD_OPTION_APP_FD_SETSIZE option.\n"),
4703 _ (
"%s() called with fd_setsize (%u) " \
4704 "less than fixed FD_SETSIZE value (%d) used on the " \
4774 daemon->fdset_size_set_by_app ?
4775 ((
unsigned int)
daemon->fdset_size) :
4835 _ (
"Could not obtain daemon fdsets.\n"));
4854 MHD_DLOG (daemon,
_ (
"Could not add control inter-thread " \
4855 "communication channel FD to fdset.\n"));
4880 _ (
"Could not add listen socket to fdset.\n"));
4924#if (SIZEOF_UINT64_T - 2) >= SIZEOF_STRUCT_TIMEVAL_TV_SEC
4948 _ (
"select failed: %s\n"),
4978 unsigned int num_connections;
4981#if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT)
4998 num_connections = 0;
5001#if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT)
5003 num_connections += 2;
5020 _ (
"Error allocating memory: %s\n"),
5073#if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT)
5097 _ (
"poll failed: %s\n"),
5132 while (
NULL != (pos = prev))
5136 if (
i >= num_connections)
5147#if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT)
5150 if (
i >= num_connections)
5165 if ( (0 ==
urh->in_buffer_size) &&
5166 (0 ==
urh->out_buffer_size) &&
5167 (0 ==
urh->in_buffer_used) &&
5168 (0 ==
urh->out_buffer_used) )
5173 urh->clean_ready =
true;
5254 _ (
"poll failed: %s\n"),
5314#define MAX_EVENTS 128
5317#if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT)
5331 if ( (0 ==
urh->in_buffer_size) &&
5332 (0 ==
urh->out_buffer_size) &&
5333 (0 ==
urh->in_buffer_used) &&
5334 (0 ==
urh->out_buffer_used) )
5339 &
urh->app.celi)) ||
5341 (
urh->in_buffer_used <
urh->in_buffer_size) )
5344 &
urh->mhd.celi)) ||
5346 (
urh->out_buffer_used <
urh->out_buffer_size) )
5349 (
urh->out_buffer_used > 0) )
5352 (
urh->in_buffer_used > 0) )
5374#ifdef MHD_USE_THREADS
5396 _ (
"Call to epoll_wait failed: %s\n"),
5407 if (
urh->clean_ready)
5432 if (!
urh->in_eready_list)
5438 daemon->eready_urh_tail,
5440 urh->in_eready_list =
true;
5445 prev = daemon->eready_urh_tail;
5446 while (
NULL != (pos = prev))
5453 daemon->eready_urh_tail,
5455 pos->in_eready_list =
false;
5458 if ( (0 == pos->in_buffer_size) &&
5459 (0 == pos->out_buffer_size) &&
5460 (0 == pos->in_buffer_used) &&
5461 (0 == pos->out_buffer_used) )
5464 pos->clean_ready =
true;
5499#if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT)
5510#if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT)
5522 if (-1 == daemon->epoll_fd)
5529 (! daemon->listen_socket_in_epoll) &&
5533 event.data.ptr = daemon;
5541 _ (
"Call to epoll_ctl failed: %s\n"),
5546 daemon->listen_socket_in_epoll =
true;
5549 (daemon->listen_socket_in_epoll) )
5557 MHD_PANIC (
"Failed to remove listen FD from epoll set.\n");
5558 daemon->listen_socket_in_epoll =
false;
5561#if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT)
5562 if ( ( (! daemon->upgrade_fd_in_epoll) &&
5563 (-1 != daemon->epoll_upgrade_fd) ) )
5569 daemon->epoll_upgrade_fd,
5574 _ (
"Call to epoll_ctl failed: %s\n"),
5579 daemon->upgrade_fd_in_epoll =
true;
5582 if ( (daemon->listen_socket_in_epoll) &&
5593 MHD_PANIC (
_ (
"Failed to remove listen FD from epoll set.\n"));
5594 daemon->listen_socket_in_epoll =
false;
5628 _ (
"Call to epoll_wait failed: %s\n"),
5639#if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT)
5674 daemon->eready_tail,
5689 daemon->eready_tail,
5701 daemon->eready_tail,
5738 while (
NULL != (pos = prev))
5748 while (
NULL != (pos = prev))
5756#if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT)
5762 prev = daemon->eready_tail;
5763 while (
NULL != (pos = prev))
5781 daemon->eready_tail,
5905#ifdef HAS_FD_SETSIZE_OVERRIDABLE
5907 if (daemon->fdset_size_set_by_app
5908 && (((
int)
FD_SETSIZE) < daemon->fdset_size))
5911 _ (
"MHD_run()/MHD_run_wait() called for daemon started with " \
5912 "MHD_OPTION_APP_FD_SETSIZE option (%d). " \
5913 "The library was compiled with smaller FD_SETSIZE (%d). " \
5914 "Some socket FDs may be not processed. " \
5915 "Use MHD_run_from_select2() instead of MHD_run() or " \
5916 "do not use MHD_OPTION_APP_FD_SETSIZE option.\n"),
5942#ifdef MHD_USE_THREADS
5955#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
5975#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
5981#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
5993#ifdef HAVE_PTHREAD_SIGMASK
5999#ifdef HAVE_PTHREAD_SIGMASK
6012 _ (
"Failed to block SIGPIPE on daemon thread: %s\n"),
6075 _ (
"The URL encoding is broken.\n"));
6150#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
6164 _ (
"Using MHD_quiesce_daemon in this mode " \
6165 "requires MHD_USE_ITC.\n"));
6170#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
6184 MHD_PANIC (
_ (
"Failed to remove listen FD from epoll set.\n"));
6192 MHD_PANIC (
_ (
"Failed to signal quiesce via inter-thread " \
6193 "communication channel.\n"));
6200 (-1 != daemon->epoll_fd) &&
6201 (daemon->listen_socket_in_epoll) )
6209 MHD_PANIC (
"Failed to remove listen FD from epoll set.\n");
6210 daemon->listen_socket_in_epoll =
false;
6215 MHD_PANIC (
_ (
"failed to signal quiesce via inter-thread " \
6216 "communication channel.\n"));
6226struct MHD_InterimParams_
6239 bool fdset_size_set;
6255 bool pserver_addr_set;
6259 const struct sockaddr *pserver_addr;
6263 bool server_addr_len_set;
6294 struct MHD_InterimParams_ *
params,
6309 struct MHD_InterimParams_ *
params,
6332#if GNUTLS_VERSION_NUMBER >= 0x030300
6341#if GNUTLS_VERSION_NUMBER >= 0x030300
6379 _ (
"GnuTLS priorities have been initialised with " \
6380 "@LIBMICROHTTPD application-specific system-wide " \
6381 "configuration.\n") );
6385 _ (
"GnuTLS priorities have been initialised with " \
6386 "@SYSTEM system-wide configuration.\n") );
6388#if GNUTLS_VERSION_NUMBER >= 0x030300
6391 _ (
"GnuTLS priorities have been initialised with " \
6392 "GnuTLS default configuration.\n") );
6397 _ (
"GnuTLS priorities have been initialised with " \
6398 "NORMAL configuration.\n") );
6410 _ (
"Failed to set GnuTLS priorities. Last error: %s\n"),
6450#if GNUTLS_VERSION_NUMBER >= 0x030300
6451#if GNUTLS_VERSION_NUMBER >= 0x030603
6488 _ (
"GnuTLS priorities have been initialised with " \
6489 "priorities specified by application appended to " \
6490 "@LIBMICROHTTPD application-specific system-wide " \
6491 "configuration.\n") );
6495 _ (
"GnuTLS priorities have been initialised with " \
6496 "priorities specified by application appended to " \
6497 "@SYSTEM system-wide configuration.\n") );
6499#if GNUTLS_VERSION_NUMBER >= 0x030300
6502 _ (
"GnuTLS priorities have been initialised with " \
6503 "priorities specified by application appended to " \
6504 "GnuTLS default configuration.\n") );
6509 _ (
"GnuTLS priorities have been initialised with " \
6510 "priorities specified by application appended to " \
6511 "NORMAL configuration.\n") );
6523 _ (
"Failed to set GnuTLS priorities. Last error: %s. " \
6524 "The problematic part starts at: %s\n"),
6531#define LOCAL_BUFF_SIZE 128
6574 _ (
"Error allocating memory: %s\n"),
6601 struct MHD_InterimParams_ *
params,
6610#if GNUTLS_VERSION_MAJOR >= 3
6613#if GNUTLS_VERSION_NUMBER >= 0x030603
6639 _ (
"Warning: specified " \
6640 "MHD_OPTION_CONNECTION_MEMORY_LIMIT " \
6641 "value is too small and rounded up to 64.\n"));
6665 _ (
"Warning: specified " \
6666 "MHD_OPTION_CONNECTION_MEMORY_INCREMENT value is " \
6667 "too large and rounded down to 1/4 of " \
6668 "MHD_OPTION_CONNECTION_MEMORY_LIMIT.\n"));
6682#if (SIZEOF_UINT64_T - 2) <= SIZEOF_UNSIGNED_INT
6687 _ (
"The specified connection timeout (%u) is too large. " \
6688 "Maximum allowed value (%" PRIu64 ") will be used " \
6717 params->server_addr_len_set =
true;
6720 params->pserver_addr_set =
true;
6723 params->server_addr_len_set =
false;
6726 params->pserver_addr_set =
true;
6739#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
6751 _ (
"Warning: value \"1\", specified as the thread pool " \
6752 "size, is ignored. Thread pool is not used.\n"));
6756#if SIZEOF_UNSIGNED_INT >= (SIZEOF_SIZE_T - 2)
6765 _ (
"Specified thread pool size (%u) too big.\n"),
6777 _ (
"MHD_OPTION_THREAD_POOL_SIZE option is specified but "
6778 "MHD_USE_INTERNAL_POLLING_THREAD flag is not specified.\n"));
6786 _ (
"Both MHD_OPTION_THREAD_POOL_SIZE option and "
6787 "MHD_USE_THREAD_PER_CONNECTION flag are specified.\n"));
6799 daemon->https_mem_key =
pstr;
6803 _ (
"MHD HTTPS option %d passed to MHD but " \
6804 "MHD_USE_TLS not set.\n"),
6812 daemon->https_key_password =
pstr;
6816 _ (
"MHD HTTPS option %d passed to MHD but " \
6817 "MHD_USE_TLS not set.\n"),
6825 daemon->https_mem_cert =
pstr;
6829 _ (
"MHD HTTPS option %d passed to MHD but " \
6830 "MHD_USE_TLS not set.\n"),
6838 daemon->https_mem_trust =
pstr;
6842 _ (
"MHD HTTPS option %d passed to MHD but " \
6843 "MHD_USE_TLS not set.\n"),
6863 _ (
"Error initializing DH parameters.\n"));
6873 _ (
"Diffie-Hellman parameters string too long.\n"));
6884 _ (
"Bad Diffie-Hellman parameters format.\n"));
6889 daemon->have_dhparams =
true;
6894 _ (
"MHD HTTPS option %d passed to MHD but " \
6895 "MHD_USE_TLS not set.\n"),
6905 if (
NULL != daemon->priority_cache)
6919 _ (
"Setting priorities to '%s' failed: %s " \
6920 "The problematic part starts at: %s\n"),
6925 daemon->priority_cache =
NULL;
6932 daemon->priority_cache =
NULL;
6940 _ (
"MHD HTTPS option %d passed to MHD but " \
6941 "MHD_USE_TLS not set.\n"),
6946#if GNUTLS_VERSION_MAJOR < 3
6949 _ (
"MHD_OPTION_HTTPS_CERT_CALLBACK requires building " \
6950 "MHD with GnuTLS >= 3.0.\n"));
6957 daemon->cert_callback =
pgcrf;
6961 _ (
"MHD HTTPS option %d passed to MHD but " \
6962 "MHD_USE_TLS not set.\n"),
6968#if GNUTLS_VERSION_NUMBER < 0x030603
6971 _ (
"MHD_OPTION_HTTPS_CERT_CALLBACK2 requires building " \
6972 "MHD with GnuTLS >= 3.6.3.\n"));
6979 daemon->cert_callback2 =
pgcrf2;
6983 _ (
"MHD HTTPS option %d passed to MHD but " \
6984 "MHD_USE_TLS not set.\n"),
6993 daemon->digest_auth_rand_size =
va_arg (
ap,
6995 daemon->digest_auth_random =
va_arg (
ap,
6999 daemon->digest_auth_random_copy = daemon;
7001 daemon->digest_auth_random_copy =
NULL;
7004 daemon->nonce_nc_size =
va_arg (
ap,
7008 daemon->dauth_bind_type =
va_arg (
ap,
7020 daemon->dauth_def_nonce_timeout =
val;
7030 daemon->dauth_def_max_nc =
val;
7037 params->listen_fd_set =
true;
7041 daemon->custom_error_log =
va_arg (
ap,
7043 daemon->custom_error_log_cls =
va_arg (
ap,
7045 if (1 !=
params->num_opts)
7047 _ (
"MHD_OPTION_EXTERNAL_LOGGER is not the first option "
7048 "specified for the daemon. Some messages may be "
7049 "printed by the standard MHD logger.\n"));
7058#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
7060 daemon->thread_stack_size =
va_arg (
ap,
7066 daemon->fastopen_queue_size =
va_arg (
ap,
7072 _ (
"TCP fastopen is not supported on this platform.\n"));
7078 unsigned int) ? 1 : -1;
7096 _ (
"Flag MHD_USE_PEDANTIC_CHECKS is ignored because "
7097 "another behaviour is specified by "
7098 "MHD_OPTION_STRICT_CLIENT.\n"));
7109 _ (
"Flag MHD_USE_PEDANTIC_CHECKS is ignored because "
7110 "another behaviour is specified by "
7111 "MHD_OPTION_CLIENT_DISCIPLINE_LVL.\n"));
7265#if GNUTLS_VERSION_MAJOR >= 3
7266 daemon->cred_callback =
va_arg (
ap,
7268 daemon->cred_callback_cls =
va_arg (
ap,
7273 _ (
"MHD HTTPS option %d passed to MHD compiled " \
7274 "without GNUtls >= 3.\n"),
7291 daemon->disable_alpn = (
va_arg (
ap,
7299 _ (
"MHD HTTPS option %d passed to MHD " \
7300 "but MHD_USE_TLS not set.\n"),
7305 params->fdset_size_set =
true;
7309#ifndef HTTPS_SUPPORT
7323 _ (
"MHD HTTPS option %d passed to MHD "
7324 "compiled without HTTPS support.\n"),
7333 _ (
"Invalid option %d! (Did you terminate "
7334 "the list with MHD_OPTION_END?).\n"),
7350#ifndef HAVE_MESSAGES
7354#ifdef USE_EPOLL_CREATE1
7363 _ (
"Call to epoll_create1 failed: %s\n"),
7368#if ! defined(USE_EPOLL_CREATE1)
7373 _ (
"Failed to set noninheritable mode on epoll FD.\n"));
7415 _ (
"The epoll FD is too large to be used with fd_set.\n"));
7420 if (-1 == daemon->epoll_fd)
7422#if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT)
7434 event.data.ptr = daemon;
7442 _ (
"Call to epoll_ctl failed: %s\n"),
7447 daemon->listen_socket_in_epoll =
true;
7461 _ (
"Call to epoll_ctl failed: %s\n"),
7489 struct MHD_InterimParams_ *
params)
7491 if (
params->fdset_size_set)
7493 if (0 >=
params->fdset_size)
7497 _ (
"MHD_OPTION_APP_FD_SETSIZE value (%d) is not positive.\n"),
7506 _ (
"MHD_OPTION_APP_FD_SETSIZE is ignored for daemon started " \
7507 "with MHD_USE_INTERNAL_POLLING_THREAD.\n"));
7515 _ (
"MHD_OPTION_APP_FD_SETSIZE is ignored for daemon started " \
7516 "with MHD_USE_POLL.\n"));
7522#ifndef HAS_FD_SETSIZE_OVERRIDABLE
7527 _ (
"MHD_OPTION_APP_FD_SETSIZE value (%d) does not match " \
7528 "the platform FD_SETSIZE value (%d) and this platform " \
7529 "does not support overriding of FD_SETSIZE.\n"),
7535 d->fdset_size =
params->fdset_size;
7536 d->fdset_size_set_by_app =
true;
7541 if (
params->listen_fd_set)
7547#ifdef HAS_SIGNED_SOCKET
7548 else if (0 >
params->listen_fd)
7552 _ (
"The value provided for MHD_OPTION_LISTEN_SOCKET " \
7562 _ (
"MHD_OPTION_LISTEN_SOCKET specified for daemon "
7563 "with MHD_USE_NO_LISTEN_SOCKET flag set.\n"));
7570 d->listen_fd =
params->listen_fd;
7572#ifdef MHD_USE_GETSOCKNAME
7579 if (
params->pserver_addr_set)
7584 if (
params->server_addr_len_set && (0 !=
params->server_addr_len))
7592 _ (
"MHD_OPTION_LISTEN_SOCKET cannot be used together with " \
7593 "MHD_OPTION_SOCK_ADDR_LEN or MHD_OPTION_SOCK_ADDR.\n"));
7601 _ (
"MHD_OPTION_SOCK_ADDR_LEN or MHD_OPTION_SOCK_ADDR " \
7602 "specified for daemon with MHD_USE_NO_LISTEN_SOCKET " \
7615 if (
params->server_addr_len_set)
7618 if (0 ==
params->server_addr_len)
7665#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
7687#ifndef EPOLL_SUPPORT
7691#ifndef HTTPS_SUPPORT
7701#ifdef UPGRADE_SUPPORT
7707#ifdef MHD_USE_THREADS
7736#if defined(EPOLL_SUPPORT) && defined(HAVE_POLL)
7741#elif defined(HAVE_POLL)
7744#elif defined(EPOLL_SUPPORT)
7756#ifdef HAVE_LISTEN_SHUTDOWN
7765 MHD_calloc_ (1,
sizeof (
struct MHD_InterimParams_));
7774 daemon->epoll_fd = -1;
7775#if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT)
7776 daemon->epoll_upgrade_fd = -1;
7781 daemon->priority_cache =
NULL;
7790 daemon->
port = port;
7802#ifdef MHD_USE_THREADS
7812 daemon->custom_error_log_cls =
stderr;
7814#ifndef MHD_WINSOCK_SOCKETS
7820#if defined(_DEBUG) && defined(HAVE_ACCEPT4)
7821 daemon->avoid_accept4 =
false;
7823#ifdef HAS_FD_SETSIZE_OVERRIDABLE
7825 daemon->fdset_size_set_by_app =
false;
7829 daemon->digest_auth_rand_size = 0;
7830 daemon->digest_auth_random =
NULL;
7831 daemon->nonce_nc_size = 4;
7858 (
NULL != daemon->priority_cache) )
7878 && (
NULL == daemon->priority_cache)
7883 _ (
"Failed to initialise GnuTLS priorities.\n"));
7895 _ (
"Warning: MHD_USE_THREAD_PER_CONNECTION must be used " \
7896 "only with MHD_USE_INTERNAL_POLLING_THREAD. " \
7897 "Flag MHD_USE_INTERNAL_POLLING_THREAD was added. " \
7898 "Consider setting MHD_USE_INTERNAL_POLLING_THREAD " \
7911 _ (
"Using debug build of libmicrohttpd.\n") );
7925 _ (
"Failed to create inter-thread communication channel: %s\n"),
7929 if (
NULL != daemon->priority_cache)
7940 _ (
"file descriptor for inter-thread communication " \
7941 "channel exceeds maximum value.\n"));
7945 if (
NULL != daemon->priority_cache)
7954 if (
NULL != daemon->digest_auth_random_copy)
7956 mhd_assert (daemon == daemon->digest_auth_random_copy);
7957 daemon->digest_auth_random_copy = malloc (daemon->digest_auth_rand_size);
7958 if (
NULL == daemon->digest_auth_random_copy)
7967 memcpy (daemon->digest_auth_random_copy,
7968 daemon->digest_auth_random,
7969 daemon->digest_auth_rand_size);
7970 daemon->digest_auth_random = daemon->digest_auth_random_copy;
7972 if (daemon->nonce_nc_size > 0)
7975 /
sizeof(
struct MHD_NonceNc) != daemon->nonce_nc_size)
7979 _ (
"Specified value for NC_SIZE too large.\n"));
7985 free (daemon->digest_auth_random_copy);
7991 if (
NULL == daemon->nnc)
7995 _ (
"Failed to allocate memory for nonce-nc map: %s\n"),
8002 free (daemon->digest_auth_random_copy);
8008#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
8013 _ (
"MHD failed to initialize nonce-nc mutex.\n"));
8019 free (daemon->digest_auth_random_copy);
8028#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
8034 _ (
"MHD thread polling only works with " \
8035 "MHD_USE_INTERNAL_POLLING_THREAD.\n"));
8056#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
8064 _ (
"MHD_USE_IPv6 is enabled, but 'struct sockaddr *' " \
8065 "specified for MHD_OPTION_SOCK_ADDR_LEN or " \
8066 "MHD_OPTION_SOCK_ADDR is not IPv6 address.\n"));
8083 _ (
"The size specified for MHD_OPTION_SOCK_ADDR_LEN " \
8084 "option is wrong.\n"));
8088#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
8095 _ (
"The value of 'struct sockaddr.sa_len' provided " \
8096 "via MHD_OPTION_SOCK_ADDR_LEN option is not zero " \
8097 "and does not match 'sa_family' value of the " \
8098 "same structure.\n"));
8110#ifndef MHD_USE_GETSOCKNAME
8128 _ (
"The size specified for MHD_OPTION_SOCK_ADDR_LEN " \
8129 "option is wrong.\n"));
8133#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
8140 _ (
"The value of 'struct sockaddr.sa_len' provided " \
8141 "via MHD_OPTION_SOCK_ADDR_LEN option is not zero " \
8142 "and does not match 'sa_family' value of the " \
8143 "same structure.\n"));
8155#ifndef MHD_USE_GETSOCKNAME
8168#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
8178 _ (
"The 'sa_family' of the 'struct sockaddr' provided " \
8179 "via MHD_OPTION_SOCK_ADDR option is not supported.\n"));
8217#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
8228#ifdef IN6ADDR_ANY_INIT
8236#ifdef IN6ADDR_ANY_INIT
8239#ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN
8255 _ (
"Failed to create socket for listening: %s\n"),
8265 _ (
"Listen socket descriptor (%d) is not " \
8266 "less than daemon FD_SETSIZE value (%d).\n"),
8278#ifndef MHD_WINSOCK_SOCKETS
8286 (
const void *) &
on,
sizeof (
on)))
8290 _ (
"setsockopt failed: %s\n"),
8299#ifndef MHD_WINSOCK_SOCKETS
8305 (
const void *) &
on,
sizeof (
on)))
8309 _ (
"setsockopt failed: %s\n"),
8319#if defined(MHD_WINSOCK_SOCKETS) || defined(SO_REUSEPORT)
8332 _ (
"setsockopt failed: %s\n"),
8342 _ (
"Cannot allow listening address reuse: " \
8343 "SO_REUSEPORT not defined.\n"));
8356#if (defined(MHD_WINSOCK_SOCKETS) && defined(SO_EXCLUSIVEADDRUSE)) || \
8357 (defined(__sun) && defined(SO_EXCLBIND))
8370 _ (
"setsockopt failed: %s\n"),
8375#elif defined(MHD_WINSOCK_SOCKETS)
8378 _ (
"Cannot disallow listening address reuse: " \
8379 "SO_EXCLUSIVEADDRUSE not defined.\n"));
8405 _ (
"setsockopt failed: %s\n"),
8416 _ (
"Failed to bind to port %u: %s\n"),
8417 (
unsigned int) port,
8427 if (0 == daemon->fastopen_queue_size)
8432 (
const void *) &daemon->fastopen_queue_size,
8433 sizeof (daemon->fastopen_queue_size)))
8437 _ (
"setsockopt failed: %s\n"),
8443 if (0 !=
listen (listen_fd,
8448 _ (
"Failed to listen for connections: %s\n"),
8463 _ (
"Listen socket descriptor (%d) is not " \
8464 "less than daemon FD_SETSIZE value (%d).\n"),
8472#if defined(SOL_SOCKET) && (defined(SO_DOMAIN) || defined(SO_PROTOCOL_INFOW))
8526#ifdef MHD_USE_GETSOCKNAME
8531#ifdef MHD_USE_GETSOCKNAME
8532 if ( (0 == daemon->
port) &&
8542#ifdef HAVE_STRUCT_SOCKADDR_STORAGE_SS_LEN
8551 _ (
"Failed to get listen port number: %s\n"),
8555#ifdef MHD_POSIX_SOCKETS
8561 _ (
"Failed to get listen port number " \
8562 "(`struct sockaddr_storage` too small!?).\n"));
8608 _ (
"Listen socket has unknown address family!\n"));
8625 _ (
"Failed to set nonblocking mode on listening socket: %s\n"),
8663 _ (
"Combining MHD_USE_THREAD_PER_CONNECTION and " \
8664 "MHD_USE_EPOLL is not supported.\n"));
8673#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
8678 _ (
"MHD failed to initialize IP connection limit mutex.\n"));
8693 _ (
"Failed to initialize TLS support.\n"));
8697#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
8703#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
8711#ifdef HAVE_LISTEN_SHUTDOWN
8725 _ (
"Failed to initialise internal lists mutex.\n"));
8736 _ (
"Failed to initialise mutex.\n"));
8746 "MHD-listen" :
"MHD-single",
8747 daemon->thread_stack_size,
8755 _ (
"Failed to create a new thread because it would have " \
8756 "exceeded the system limit on the number of threads or " \
8757 "no system resources available.\n"));
8761 _ (
"Failed to create listen thread: %s\n"),
8803 d->worker_pool =
NULL;
8808 _ (
"Failed to initialise internal lists mutex.\n"));
8816 _ (
"Failed to initialise mutex.\n"));
8827 _ (
"Failed to create worker inter-thread " \
8828 "communication channel: %s\n"),
8840 _ (
"File descriptor for worker inter-thread " \
8841 "communication channel exceeds maximum value.\n"));
8852#ifdef HAVE_LISTEN_SHUTDOWN
8864 ++
d->connection_limit;
8877#if defined(MHD_USE_THREADS)
8878 memset (&
d->per_ip_connection_mutex, 0x7F,
8879 sizeof(
d->per_ip_connection_mutex));
8883 d->nonce_nc_size = 0;
8884 d->digest_auth_random_copy =
NULL;
8885#if defined(MHD_USE_THREADS)
8886 memset (&
d->nnc_lock, 0x7F,
sizeof(
d->nnc_lock));
8893 daemon->thread_stack_size,
8901 _ (
"Failed to create a new pool thread because it would " \
8902 "have exceeded the system limit on the number of " \
8903 "threads or no system resources available.\n"));
8907 _ (
"Failed to create pool thread: %s\n"),
8928 _ (
"Failed to initialise internal lists mutex.\n"));
8939 _ (
"Failed to initialise mutex.\n"));
8952 daemon->https_key_password =
NULL;
8957#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
8987#if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT)
8988 if (daemon->upgrade_fd_in_epoll)
8992 daemon->epoll_upgrade_fd,
8994 MHD_PANIC (
_ (
"Failed to remove FD from epoll set.\n"));
8995 daemon->upgrade_fd_in_epoll =
false;
8998 if (-1 != daemon->epoll_fd)
8999 close (daemon->epoll_fd);
9000#if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT)
9001 if (-1 != daemon->epoll_upgrade_fd)
9002 close (daemon->epoll_upgrade_fd);
9006 free (daemon->digest_auth_random_copy);
9008#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
9016 if (daemon->x509_cred)
9018 if (daemon->psk_cred)
9047#ifdef UPGRADE_SUPPORT
9050#if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT)
9056#ifdef MHD_USE_THREADS
9064#ifdef MHD_USE_THREADS
9079#if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT)
9090 urh->clean_ready =
true;
9107#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
9110#ifdef UPGRADE_SUPPORT
9119 MHD_PANIC (
_ (
"MHD_stop_daemon() called while we have " \
9120 "suspended connections.\n"));
9124 (!
susp->urh->clean_ready) )
9125 shutdown (
susp->urh->app.socket,
9131 if (!
susp->urh->was_closed)
9133 _ (
"Initiated daemon shutdown while \"upgraded\" " \
9134 "connection was not closed.\n"));
9136 susp->urh->was_closed =
true;
9143 susp->resuming =
true;
9152 MHD_PANIC (
_ (
"MHD_stop_daemon() called while we have " \
9153 "suspended connections.\n"));
9154#if defined(UPGRADE_SUPPORT) && defined(HTTPS_SUPPORT)
9155#ifdef MHD_USE_THREADS
9175 MHD_PANIC (
_ (
"Failed to join a thread.\n"));
9187#ifdef MHD_WINSOCK_SOCKETS
9191 MHD_PANIC (
_ (
"Failed to signal shutdown via inter-thread " \
9192 "communication channel.\n"));
9196#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
9207 MHD_PANIC (
_ (
"Failed to join a thread.\n"));
9221#ifdef UPGRADE_SUPPORT
9237#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
9240 MHD_PANIC (
_ (
"Failed to join a thread.\n"));
9258#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
9265 MHD_PANIC (
_ (
"MHD_stop_daemon() was called twice."));
9283#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
9297 MHD_PANIC (
_ (
"Failed to signal shutdown via inter-thread " \
9298 "communication channel.\n"));
9303#ifdef HAVE_LISTEN_SHUTDOWN
9318#if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT)
9326#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
9335 MHD_PANIC (
_ (
"Failed to signal shutdown via inter-thread " \
9336 "communication channel.\n"));
9340#ifdef HAVE_LISTEN_SHUTDOWN
9354 MHD_PANIC (
_ (
"Failed to join a thread.\n"));
9368#if defined(UPGRADE_SUPPORT) && defined(HTTPS_SUPPORT)
9377 (-1 !=
daemon->epoll_fd) )
9379#if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT)
9381 (-1 !=
daemon->epoll_upgrade_fd) )
9386#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
9401 if (
daemon->have_dhparams)
9404 daemon->have_dhparams =
false;
9417 free (
daemon->digest_auth_random_copy);
9419#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
9423#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
9469 daemon->daemon_info_dummy_epoll_fd.epoll_fd = daemon->epoll_fd;
9470 return &daemon->daemon_info_dummy_epoll_fd;
9477#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
9514#ifdef PACKAGE_VERSION
9517 static char ver[12] =
"\0\0\0\0\0\0\0\0\0\0\0";
9578#if defined(HTTPS_SUPPORT) && GNUTLS_VERSION_MAJOR >= 3
9584#if defined(HTTPS_SUPPORT) && GNUTLS_VERSION_NUMBER >= 0x030603
9596#if defined(IPPROTO_IPV6) && defined(IPV6_V6ONLY)
9614#ifdef HAVE_LISTEN_SHUTDOWN
9620#ifdef _MHD_ITC_SOCKETPAIR
9644#ifdef HAVE_POSTPROCESSOR
9650#if defined(HTTPS_SUPPORT) && GNUTLS_VERSION_NUMBER >= 0x030111
9656#if defined(HAVE_PREAD64) || defined(_WIN32)
9658#elif defined(HAVE_PREAD)
9660#elif defined(HAVE_LSEEK64)
9666#if defined(MHD_USE_THREAD_NAME_)
9672#if defined(UPGRADE_SUPPORT)
9678#if defined(HAVE_PREAD64) || defined(HAVE_PREAD) || defined(_WIN32)
9684#ifdef MHD_USE_GETSOCKNAME
9690#if defined(MHD_SEND_SPIPE_SUPPRESS_POSSIBLE) || \
9691 ! defined(MHD_SEND_SPIPE_SUPPRESS_NEEDED)
9697#ifdef _MHD_HAVE_SENDFILE
9703#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
9709#if defined(COOKIE_SUPPORT)
9721#if defined(DAUTH_SUPPORT) && defined(MHD_MD5_SUPPORT)
9727#if defined(DAUTH_SUPPORT) && defined(MHD_SHA256_SUPPORT)
9733#if defined(DAUTH_SUPPORT) && defined(MHD_SHA512_256_SUPPORT)
9757#if defined(MHD_MD5_TLSLIB) || defined(MHD_SHA256_TLSLIB)
9769#ifdef HAS_FD_SETSIZE_OVERRIDABLE
9782#ifdef MHD_HTTPS_REQUIRE_GCRYPT
9783#if defined(HTTPS_SUPPORT) && GCRYPT_VERSION_NUMBER < 0x010600
9784#if defined(MHD_USE_POSIX_THREADS)
9786#elif defined(MHD_W32_MUTEX_)
9846#if defined(MHD_WINSOCK_SOCKETS)
9852#if defined(MHD_WINSOCK_SOCKETS)
9854 MHD_PANIC (
_ (
"Failed to initialize winsock.\n"));
9856 MHD_PANIC (
_ (
"Winsock version 2.2 is not available.\n"));
9859#ifdef MHD_HTTPS_REQUIRE_GCRYPT
9860#if GCRYPT_VERSION_NUMBER < 0x010600
9861#if GNUTLS_VERSION_NUMBER <= 0x020b00
9862#if defined(MHD_USE_POSIX_THREADS)
9865 MHD_PANIC (
_ (
"Failed to initialise multithreading in libgcrypt.\n"));
9866#elif defined(MHD_W32_MUTEX_)
9869 MHD_PANIC (
_ (
"Failed to initialise multithreading in libgcrypt.\n"));
9875 MHD_PANIC (
_ (
"libgcrypt is too old. MHD was compiled for " \
9876 "libgcrypt 1.6.0 or newer.\n"));
9902#if defined(MHD_WINSOCK_SOCKETS)
9909#ifdef _AUTOINIT_FUNCS_ARE_SUPPORTED
#define _SET_INIT_AND_DEINIT_FUNCS(FI, FD)
void MHD_connection_set_initial_state_(struct MHD_Connection *c)
void MHD_connection_handle_write(struct MHD_Connection *connection)
void MHD_set_http_callbacks_(struct MHD_Connection *connection)
enum MHD_Result MHD_connection_handle_idle(struct MHD_Connection *connection)
void MHD_connection_handle_read(struct MHD_Connection *connection, bool socket_error)
Methods for managing connections.
#define MHD_connection_finish_forward_(conn)
static MHD_THRD_RTRN_TYPE_ MHD_THRD_CALL_SPEC_ thread_main_handle_connection(void *data)
void MHD_connection_mark_closed_(struct MHD_Connection *connection)
void MHD_connection_close_(struct MHD_Connection *connection, enum MHD_RequestTerminationCode rtc)
void MHD_set_https_callbacks(struct MHD_Connection *connection)
Methods for managing connections.
void MHD_update_last_activity_(struct MHD_Connection *connection)
static void MHD_ip_limit_del(struct MHD_Daemon *daemon, const struct sockaddr_storage *addr, socklen_t addrlen)
static void close_all_connections(struct MHD_Daemon *daemon)
static enum MHD_Result MHD_ip_addr_to_key(const struct sockaddr_storage *addr, socklen_t addrlen, struct MHD_IPCount *key)
void internal_suspend_connection_(struct MHD_Connection *connection)
static enum MHD_Result MHD_ip_limit_add(struct MHD_Daemon *daemon, const struct sockaddr_storage *addr, socklen_t addrlen)
static enum MHD_Result call_handlers(struct MHD_Connection *con, bool read_ready, bool write_ready, bool force_close)
static void MHD_ip_count_unlock(struct MHD_Daemon *daemon)
static struct MHD_Connection * new_connection_prepare_(struct MHD_Daemon *daemon, MHD_socket client_socket, const struct sockaddr_storage *addr, socklen_t addrlen, bool external_add, bool non_blck, bool sk_spipe_supprs, enum MHD_tristate sk_is_nonip)
volatile int global_init_count
void MHD_check_global_init_(void)
static void close_connection(struct MHD_Connection *pos)
_MHD_EXTERN void MHD_resume_connection(struct MHD_Connection *connection)
static enum MHD_Result MHD_select(struct MHD_Daemon *daemon, int32_t millisec)
static enum MHD_Result parse_options(struct MHD_Daemon *daemon, struct MHD_InterimParams_ *params,...)
static int MHD_ip_addr_compare(const void *a1, const void *a2)
static void new_connections_list_process_(struct MHD_Daemon *daemon)
static void MHD_cleanup_connections(struct MHD_Daemon *daemon)
void(* VfprintfFunctionPointerType)(void *cls, const char *format, va_list va)
static enum MHD_Result MHD_accept_connection(struct MHD_Daemon *daemon)
static enum MHD_Result parse_options_va(struct MHD_Daemon *daemon, struct MHD_InterimParams_ *params, va_list ap)
#define MHD_MAX_CONNECTIONS_DEFAULT
static size_t unescape_wrapper(void *cls, struct MHD_Connection *connection, char *val)
static enum MHD_Result new_connection_process_(struct MHD_Daemon *daemon, struct MHD_Connection *connection)
static enum MHD_Result internal_add_connection(struct MHD_Daemon *daemon, MHD_socket client_socket, const struct sockaddr_storage *addr, socklen_t addrlen, bool external_add, bool non_blck, bool sk_spipe_supprs, enum MHD_tristate sk_is_nonip)
static void MHD_ip_count_lock(struct MHD_Daemon *daemon)
static enum MHD_Result resume_suspended_connections(struct MHD_Daemon *daemon)
#define MHD_POOL_SIZE_DEFAULT
static bool process_interim_params(struct MHD_Daemon *d, const struct sockaddr **ppsockaddr, socklen_t *psockaddr_len, struct MHD_InterimParams_ *params)
_MHD_EXTERN void MHD_suspend_connection(struct MHD_Connection *connection)
static MHD_THRD_RTRN_TYPE_ MHD_THRD_CALL_SPEC_ MHD_polling_thread(void *cls)
_MHD_EXTERN int MHD_get_timeout_i(struct MHD_Daemon *daemon)
_MHD_EXTERN int64_t MHD_get_timeout64s(struct MHD_Daemon *daemon)
#define MHD_run_from_select(d, r, w, e)
_MHD_EXTERN void MHD_stop_daemon(struct MHD_Daemon *daemon)
_MHD_EXTERN struct MHD_Daemon * MHD_start_daemon_va(unsigned int flags, uint16_t port, MHD_AcceptPolicyCallback apc, void *apc_cls, MHD_AccessHandlerCallback dh, void *dh_cls, va_list ap)
_MHD_EXTERN enum MHD_Result MHD_run(struct MHD_Daemon *daemon)
static enum MHD_Result internal_run_from_select(struct MHD_Daemon *daemon, const fd_set *read_fd_set, const fd_set *write_fd_set, const fd_set *except_fd_set, int fd_setsize)
_MHD_EXTERN enum MHD_Result MHD_get_fdset2(struct MHD_Daemon *daemon, fd_set *read_fd_set, fd_set *write_fd_set, fd_set *except_fd_set, MHD_socket *max_fd, unsigned int fd_setsize)
static enum MHD_Result internal_get_fdset2(struct MHD_Daemon *daemon, fd_set *read_fd_set, fd_set *write_fd_set, fd_set *except_fd_set, MHD_socket *max_fd, int fd_setsize)
#define MHD_get_fdset(daemon, read_fd_set, write_fd_set, except_fd_set, max_fd)
_MHD_EXTERN enum MHD_Result MHD_get_timeout(struct MHD_Daemon *daemon, MHD_UNSIGNED_LONG_LONG *timeout)
_MHD_EXTERN enum MHD_Result MHD_get_timeout64(struct MHD_Daemon *daemon, uint64_t *timeout)
_MHD_EXTERN enum MHD_Result MHD_run_from_select2(struct MHD_Daemon *daemon, const fd_set *read_fd_set, const fd_set *write_fd_set, const fd_set *except_fd_set, unsigned int fd_setsize)
_MHD_EXTERN struct MHD_Daemon * MHD_start_daemon(unsigned int flags, uint16_t port, MHD_AcceptPolicyCallback apc, void *apc_cls, MHD_AccessHandlerCallback dh, void *dh_cls,...)
_MHD_EXTERN enum MHD_Result MHD_run_wait(struct MHD_Daemon *daemon, int32_t millisec)
_MHD_EXTERN void MHD_set_panic_func(MHD_PanicCallback cb, void *cls)
void(* MHD_RequestCompletedCallback)(void *cls, struct MHD_Connection *connection, void **req_cls, enum MHD_RequestTerminationCode toe)
void(* MHD_NotifyConnectionCallback)(void *cls, struct MHD_Connection *connection, void **socket_context, enum MHD_ConnectionNotificationCode toe)
@ MHD_CONNECTION_NOTIFY_STARTED
@ MHD_CONNECTION_NOTIFY_CLOSED
@ MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN
@ MHD_REQUEST_TERMINATED_COMPLETED_OK
@ MHD_REQUEST_TERMINATED_WITH_ERROR
_MHD_EXTERN void MHD_destroy_response(struct MHD_Response *response)
_MHD_EXTERN enum MHD_Result MHD_add_connection(struct MHD_Daemon *daemon, MHD_socket client_socket, const struct sockaddr *addr, socklen_t addrlen)
_MHD_EXTERN enum MHD_Result MHD_is_feature_supported(enum MHD_FEATURE feature)
_MHD_EXTERN MHD_socket MHD_quiesce_daemon(struct MHD_Daemon *daemon)
_MHD_EXTERN const union MHD_DaemonInfo * MHD_get_daemon_info(struct MHD_Daemon *daemon, enum MHD_DaemonInfoType info_type,...)
_MHD_EXTERN uint32_t MHD_get_version_bin(void)
_MHD_EXTERN const char * MHD_get_version(void)
_MHD_EXTERN void MHD_free(void *ptr)
#define XDLL_insert(head, tail, element)
@ MHD_EPOLL_STATE_SUSPENDED
@ MHD_EPOLL_STATE_IN_EREADY_EDLL
@ MHD_EPOLL_STATE_READ_READY
@ MHD_EPOLL_STATE_IN_EPOLL_SET
@ MHD_EPOLL_STATE_WRITE_READY
#define DLL_insert(head, tail, element)
#define EDLL_insert(head, tail, element)
#define EDLL_remove(head, tail, element)
#define XDLL_remove(head, tail, element)
#define DLL_remove(head, tail, element)
void MHD_pool_destroy(struct MemoryPool *pool)
struct MemoryPool * MHD_pool_create(size_t max)
void * MHD_calloc_(size_t nelem, size_t elsize)
#define MHD_strerror_(errnum)
#define MHD_ITC_IS_INVALID_(itc)
#define MHD_itc_destroy_chk_(itc)
#define TIMEVAL_TV_SEC_MAX
#define MHD_mutex_unlock_chk_(pmutex)
#define MHD_mutex_destroy_chk_(pmutex)
#define MHD_mutex_lock_chk_(pmutex)
void MHD_monotonic_sec_counter_finish(void)
void MHD_monotonic_sec_counter_init(void)
int MHD_add_to_fd_set_(MHD_socket fd, fd_set *set, MHD_socket *max_fd, unsigned int fd_setsize)
int MHD_socket_noninheritable_(MHD_socket sock)
int MHD_socket_nonblocking_(MHD_socket sock)
MHD_socket MHD_socket_create_listen_(int pf)
#define MHD_SCKT_ERR_IS_DISCNN_BEFORE_ACCEPT_(err)
#define MHD_SCKT_FD_FITS_FDSET_SETSIZE_(fd, pset, setsize)
#define MHD_SCKT_ERR_IS_(err, code)
#define MHD_socket_close_(fd)
#define MHD_SCKT_ERR_IS_EAGAIN_(err)
#define MHD_SCKT_ERR_IS_LOW_RESOURCES_(err)
#define _MHD_SYS_DEFAULT_FD_SETSIZE
#define MHD_socket_strerr_(err)
#define MHD_socket_last_strerr_()
#define MHD_socket_get_error_()
#define MHD_socket_close_chk_(fd)
#define MHD_SCKT_ERR_IS_EINTR_(err)
#define MHD_socket_fset_error_(err)
#define MHD_SCKT_SEND_MAX_SIZE_
#define MHD_recv_(s, b, l)
#define MHD_send_(s, b, l)
#define MHD_SCKT_LAST_ERR_IS_(code)
#define MHD_SYS_select_(n, r, w, e, t)
#define MHD_STATICSTR_LEN_(macro)
#define MHD_create_named_thread_(t, n, s, r, a)
void * tfind(const void *vkey, void *const *vrootp, int(*compar)(const void *, const void *))
void * tdelete(const void *__restrict vkey, void **__restrict vrootp, int(*compar)(const void *, const void *))
void * tsearch(const void *vkey, void **vrootp, int(*compar)(const void *, const void *))
#define MHD_DAUTH_DEF_TIMEOUT_
#define MHD_DAUTH_DEF_MAX_NC_
void MHD_send_init_static_vars_(void)
Declarations of send() wrappers.
#define _MHD_S_STR_W_LEN(str)
MHD internal shared structures.
@ MHD_CONNECTION_HEADERS_SENDING
@ MHD_CONNECTION_NORMAL_BODY_READY
@ MHD_CONNECTION_CHUNKED_BODY_READY
#define MHD_D_IS_USING_POLL_(d)
#define MHD_D_DOES_SCKT_FIT_FDSET_(sckt, d)
@ MHD_EVENT_LOOP_INFO_PROCESS_READ
@ MHD_EVENT_LOOP_INFO_PROCESS
@ MHD_EVENT_LOOP_INFO_READ
@ MHD_EVENT_LOOP_INFO_WRITE
@ MHD_EVENT_LOOP_INFO_CLEANUP
#define MHD_D_IS_USING_SELECT_(d)
void *(* LogCallback)(void *cls, const char *uri, struct MHD_Connection *con)
_MHD_static_inline struct MHD_Daemon * MHD_get_master(struct MHD_Daemon *const daemon)
#define _MHD_DROP_CONST(ptr)
#define MHD_D_GET_FD_SETSIZE_(d)
#define MHD_D_IS_USING_THREAD_PER_CONN_(d)
#define MHD_D_IS_USING_THREADS_(d)
#define MHD_TEST_ALLOW_SUSPEND_RESUME
size_t(* UnescapeCallback)(void *cls, struct MHD_Connection *conn, char *uri)
#define MHD_D_IS_USING_EPOLL_(d)
#define MHD_D_IS_THREAD_SAFE_(d)
void MHD_init_mem_pools_(void)
memory pool; mostly used for efficient (de)allocation for each connection and bounding memory use for...
Header for platform missing functions.
Header for platform-independent inter-thread communication.
limits values definitions
Header for platform-independent locks abstraction.
#define MHD_mutex_destroy_(ignore)
#define MHD_mutex_unlock_(ignore)
#define MHD_mutex_lock_(ignore)
#define MHD_mutex_init_(ignore)
uint64_t MHD_monotonic_msec_counter(void)
internal monotonic clock functions implementations
#define SOCK_NONBLOCK_OR_ZERO
#define SOCK_NOSIGPIPE_OR_ZERO
#define SOCK_CLOEXEC_OR_ZERO
size_t MHD_str_pct_decode_in_place_lenient_(char *str, bool *broken_encoding)
size_t MHD_str_pct_decode_in_place_strict_(char *str)
Header for string manipulating helpers.
Header for platform-independent threads abstraction.
#define MHD_thread_handle_ID_set_current_thread_ID_(hndl_id_ptr)
#define MHD_thread_handle_ID_is_current_thread_(hndl_id)
#define MHD_thread_handle_ID_is_valid_handle_(hndl_id)
#define MHD_thread_handle_ID_join_thread_(hndl_id)
#define MHD_thread_handle_ID_set_invalid_(hndl_id_ptr)
#define MHD_thread_handle_ID_is_valid_ID_(hndl_id)
@ MHD_FEATURE_POSTPROCESSOR
@ MHD_FEATURE_SHUTDOWN_LISTEN_SOCKET
@ MHD_FEATURE_DIGEST_AUTH_USERHASH
@ MHD_FEATURE_DIGEST_AUTH_AUTH_INT
@ MHD_FEATURE_DIGEST_AUTH_SHA256
@ MHD_FEATURE_AUTODETECT_BIND_PORT
@ MHD_FEATURE_DIGEST_AUTH_SHA512_256
@ MHD_FEATURE_EXTERN_HASH
@ MHD_FEATURE_HTTPS_CERT_CALLBACK
@ MHD_FEATURE_DIGEST_AUTH
@ MHD_FEATURE_THREAD_NAMES
@ MHD_FEATURE_DEBUG_BUILD
@ MHD_FEATURE_FLEXIBLE_FD_SETSIZE
@ MHD_FEATURE_HTTPS_KEY_PASSWORD
@ MHD_FEATURE_AUTOSUPPRESS_SIGPIPE
@ MHD_FEATURE_RESPONSES_SHARED_FD
@ MHD_FEATURE_DIGEST_AUTH_ALGO_SESSION
@ MHD_FEATURE_DIGEST_AUTH_MD5
@ MHD_FEATURE_HTTPS_COOKIE_PARSING
@ MHD_FEATURE_TCP_FASTOPEN
@ MHD_FEATURE_DIGEST_AUTH_RFC2069
@ MHD_FEATURE_HTTPS_CERT_CALLBACK2
@ MHD_OPTION_HTTPS_PRIORITIES_APPEND
@ MHD_OPTION_CONNECTION_MEMORY_INCREMENT
@ MHD_OPTION_HTTPS_CRED_TYPE
@ MHD_OPTION_URI_LOG_CALLBACK
@ MHD_OPTION_HTTPS_CERT_CALLBACK2
@ MHD_OPTION_DIGEST_AUTH_DEFAULT_NONCE_TIMEOUT
@ MHD_OPTION_CLIENT_DISCIPLINE_LVL
@ MHD_OPTION_SOCK_ADDR_LEN
@ MHD_OPTION_APP_FD_SETSIZE
@ MHD_OPTION_SIGPIPE_HANDLED_BY_APP
@ MHD_OPTION_UNESCAPE_CALLBACK
@ MHD_OPTION_EXTERNAL_LOGGER
@ MHD_OPTION_LISTEN_BACKLOG_SIZE
@ MHD_OPTION_HTTPS_PRIORITIES
@ MHD_OPTION_HTTPS_MEM_DHPARAMS
@ MHD_OPTION_NOTIFY_CONNECTION
@ MHD_OPTION_LISTENING_ADDRESS_REUSE
@ MHD_OPTION_THREAD_POOL_SIZE
@ MHD_OPTION_CONNECTION_LIMIT
@ MHD_OPTION_PER_IP_CONNECTION_LIMIT
@ MHD_OPTION_DIGEST_AUTH_DEFAULT_MAX_NC
@ MHD_OPTION_TCP_FASTOPEN_QUEUE_SIZE
@ MHD_OPTION_HTTPS_MEM_CERT
@ MHD_OPTION_SERVER_INSANITY
@ MHD_OPTION_LISTEN_SOCKET
@ MHD_OPTION_HTTPS_MEM_KEY
@ MHD_OPTION_DIGEST_AUTH_RANDOM
@ MHD_OPTION_HTTPS_KEY_PASSWORD
@ MHD_OPTION_NONCE_NC_SIZE
@ MHD_OPTION_CONNECTION_MEMORY_LIMIT
@ MHD_OPTION_THREAD_STACK_SIZE
@ MHD_OPTION_DIGEST_AUTH_RANDOM_COPY
@ MHD_OPTION_STRICT_FOR_CLIENT
@ MHD_OPTION_DIGEST_AUTH_NONCE_BIND_TYPE
@ MHD_OPTION_CONNECTION_TIMEOUT
@ MHD_OPTION_GNUTLS_PSK_CRED_HANDLER
@ MHD_OPTION_HTTPS_MEM_TRUST
@ MHD_OPTION_HTTPS_CERT_CALLBACK
@ MHD_OPTION_NOTIFY_COMPLETED
enum MHD_Result(* MHD_AcceptPolicyCallback)(void *cls, const struct sockaddr *addr, socklen_t addrlen)
#define MHD_UNSIGNED_LONG_LONG
enum MHD_Result(* MHD_AccessHandlerCallback)(void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls)
#define MHD_INVALID_SOCKET
int(* MHD_PskServerCredentialsCallback)(void *cls, const struct MHD_Connection *connection, const char *username, void **psk, size_t *psk_size)
@ MHD_DAEMON_INFO_MAC_KEY_SIZE
@ MHD_DAEMON_INFO_BIND_PORT
@ MHD_DAEMON_INFO_EPOLL_FD
@ MHD_DAEMON_INFO_KEY_SIZE
@ MHD_DAEMON_INFO_CURRENT_CONNECTIONS
@ MHD_DAEMON_INFO_LISTEN_FD
MHD_FLAG
Flags for the struct MHD_Daemon.
@ MHD_ALLOW_SUSPEND_RESUME
@ MHD_USE_THREAD_PER_CONNECTION
@ MHD_USE_POST_HANDSHAKE_AUTH_SUPPORT
@ MHD_USE_SELECT_INTERNALLY
@ MHD_USE_INSECURE_TLS_EARLY_DATA
@ MHD_USE_NO_LISTEN_SOCKET
@ MHD_USE_PEDANTIC_CHECKS
@ MHD_USE_INTERNAL_POLLING_THREAD
@ MHD_USE_NO_THREAD_SAFETY
@ MHD_DAUTH_BIND_NONCE_URI
@ MHD_DAUTH_BIND_NONCE_URI_PARAMS
Methods for managing response objects.
enum MHD_tristate sk_nodelay
struct MHD_Connection * prevX
enum MHD_ConnectionEventLoopInfo event_loop_info
enum MHD_tristate is_nonip
struct MHD_Connection * next
struct sockaddr_storage addr
size_t read_buffer_offset
struct MHD_Connection * prev
struct MHD_Connection * nextX
enum MHD_CONNECTION_STATE state
struct MHD_Daemon * daemon
uint64_t connection_timeout_ms
enum MHD_tristate sk_corked
MHD_NotifyConnectionCallback notify_connection
MHD_AccessHandlerCallback default_handler
LogCallback uri_log_callback
bool data_already_pending
MHD_mutex_ per_ip_connection_mutex
union MHD_DaemonInfo daemon_info_dummy_port
void * per_ip_connection_count
struct MHD_Connection * new_connections_tail
unsigned int connection_limit
void * unescape_callback_cls
MHD_mutex_ cleanup_connection_mutex
enum MHD_DisableSanityCheck insanity_level
struct MHD_Connection * connections_head
union MHD_DaemonInfo daemon_info_dummy_listen_fd
unsigned int listen_backlog_size
union MHD_DaemonInfo daemon_info_dummy_flags
MHD_RequestCompletedCallback notify_completed
unsigned int worker_pool_size
int listening_address_reuse
uint64_t connection_timeout_ms
unsigned int per_ip_connection_limit
struct MHD_Connection * manual_timeout_tail
union MHD_DaemonInfo daemon_info_dummy_num_connections
void * notify_connection_cls
UnescapeCallback unescape_callback
void * notify_completed_cls
struct MHD_Connection * cleanup_tail
struct MHD_Daemon * worker_pool
struct MHD_Connection * new_connections_head
struct MHD_Connection * manual_timeout_head
enum MHD_tristate listen_is_unix
void * default_handler_cls
struct MHD_Connection * suspended_connections_tail
MHD_AcceptPolicyCallback apc
struct MHD_Connection * cleanup_head
struct MHD_Daemon * master
struct MHD_Connection * normal_timeout_head
struct MHD_Connection * normal_timeout_tail
void * uri_log_callback_cls
struct MHD_Connection * suspended_connections_head
struct MHD_Connection * connections_tail
struct MHD_Response * response
unsigned int num_connections