aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/include/microhttpd.h11
-rw-r--r--src/microhttpd/daemon.c11
-rw-r--r--src/microhttpd/internal.h5
3 files changed, 24 insertions, 3 deletions
diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h
index 05b86b74..50c7b3af 100644
--- a/src/include/microhttpd.h
+++ b/src/include/microhttpd.h
@@ -130,7 +130,7 @@ typedef intptr_t ssize_t;
130 * Current version of the library. 130 * Current version of the library.
131 * 0x01093001 = 1.9.30-1. 131 * 0x01093001 = 1.9.30-1.
132 */ 132 */
133#define MHD_VERSION 0x00094701 133#define MHD_VERSION 0x00094703
134 134
135/** 135/**
136 * MHD-internal return code for "YES". 136 * MHD-internal return code for "YES".
@@ -967,8 +967,15 @@ enum MHD_OPTION
967 * pointer to a closure to pass to the request completed callback. 967 * pointer to a closure to pass to the request completed callback.
968 * The second pointer maybe NULL. 968 * The second pointer maybe NULL.
969 */ 969 */
970 MHD_OPTION_NOTIFY_CONNECTION = 27 970 MHD_OPTION_NOTIFY_CONNECTION = 27,
971 971
972 /**
973 * Allow to change maximum length of the queue of pending connections on
974 * listen socket. If not present than default platform-specific SOMAXCONN
975 * value is used. This option should be followed by an `unsigned int`
976 * argument.
977 */
978 MHD_OPTION_LISTEN_BACKLOG_SIZE = 28
972}; 979};
973 980
974 981
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 209f8e5d..29daaad7 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -3397,6 +3397,9 @@ parse_options_va (struct MHD_Daemon *daemon,
3397 case MHD_OPTION_LISTENING_ADDRESS_REUSE: 3397 case MHD_OPTION_LISTENING_ADDRESS_REUSE:
3398 daemon->listening_address_reuse = va_arg (ap, unsigned int) ? 1 : -1; 3398 daemon->listening_address_reuse = va_arg (ap, unsigned int) ? 1 : -1;
3399 break; 3399 break;
3400 case MHD_OPTION_LISTEN_BACKLOG_SIZE:
3401 daemon->listen_backlog_size = va_arg (ap, unsigned int);
3402 break;
3400 case MHD_OPTION_ARRAY: 3403 case MHD_OPTION_ARRAY:
3401 oa = va_arg (ap, struct MHD_OptionItem*); 3404 oa = va_arg (ap, struct MHD_OptionItem*);
3402 i = 0; 3405 i = 0;
@@ -3423,6 +3426,7 @@ parse_options_va (struct MHD_Daemon *daemon,
3423 case MHD_OPTION_THREAD_POOL_SIZE: 3426 case MHD_OPTION_THREAD_POOL_SIZE:
3424 case MHD_OPTION_TCP_FASTOPEN_QUEUE_SIZE: 3427 case MHD_OPTION_TCP_FASTOPEN_QUEUE_SIZE:
3425 case MHD_OPTION_LISTENING_ADDRESS_REUSE: 3428 case MHD_OPTION_LISTENING_ADDRESS_REUSE:
3429 case MHD_OPTION_LISTEN_BACKLOG_SIZE:
3426 if (MHD_YES != parse_options (daemon, 3430 if (MHD_YES != parse_options (daemon,
3427 servaddr, 3431 servaddr,
3428 opt, 3432 opt,
@@ -3731,6 +3735,11 @@ MHD_start_daemon_va (unsigned int flags,
3731 daemon->connection_timeout = 0; /* no timeout */ 3735 daemon->connection_timeout = 0; /* no timeout */
3732 daemon->wpipe[0] = MHD_INVALID_PIPE_; 3736 daemon->wpipe[0] = MHD_INVALID_PIPE_;
3733 daemon->wpipe[1] = MHD_INVALID_PIPE_; 3737 daemon->wpipe[1] = MHD_INVALID_PIPE_;
3738#ifdef SOMAXCONN
3739 daemon->listen_backlog_size = SOMAXCONN;
3740#else /* !SOMAXCONN */
3741 daemon->listen_backlog_size = 511; /* should be safe value */
3742#endif /* !SOMAXCONN */
3734#if HAVE_MESSAGES 3743#if HAVE_MESSAGES
3735 daemon->custom_error_log = (MHD_LogCallback) &vfprintf; 3744 daemon->custom_error_log = (MHD_LogCallback) &vfprintf;
3736 daemon->custom_error_log_cls = stderr; 3745 daemon->custom_error_log_cls = stderr;
@@ -4098,7 +4107,7 @@ MHD_start_daemon_va (unsigned int flags,
4098 } 4107 }
4099 } 4108 }
4100#endif 4109#endif
4101 if (listen (socket_fd, 32) < 0) 4110 if (listen (socket_fd, daemon->listen_backlog_size) < 0)
4102 { 4111 {
4103#if HAVE_MESSAGES 4112#if HAVE_MESSAGES
4104 MHD_DLOG (daemon, 4113 MHD_DLOG (daemon,
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h
index 3760fefb..9e1a2901 100644
--- a/src/microhttpd/internal.h
+++ b/src/microhttpd/internal.h
@@ -1301,6 +1301,11 @@ struct MHD_Daemon
1301 */ 1301 */
1302 unsigned int fastopen_queue_size; 1302 unsigned int fastopen_queue_size;
1303#endif 1303#endif
1304
1305 /**
1306 * The size of queue for listen socket.
1307 */
1308 unsigned int listen_backlog_size;
1304}; 1309};
1305 1310
1306 1311