#define MSG_NOSIGNAL (0)
#endif
-#if !defined(SOMAXCONN)
-#define SOMAXCONN (100)
-#endif
-
/* Size of the accepted socket queue */
#if !defined(MGSQLEN)
#define MGSQLEN (20)
SSL_CERTIFICATE,
SSL_CERTIFICATE_CHAIN,
NUM_THREADS,
+ SO_MAX_CONNECTIONS,
RUN_AS_USER,
URL_REWRITE_PATTERN,
HIDE_FILES,
{"ssl_certificate", CONFIG_TYPE_FILE, NULL},
{"ssl_certificate_chain", CONFIG_TYPE_FILE, NULL},
{"num_threads", CONFIG_TYPE_NUMBER, "50"},
+ {"max_connections", CONFIG_TYPE_NUMBER, "100"},
{"run_as_user", CONFIG_TYPE_STRING, NULL},
{"url_rewrite_patterns", CONFIG_TYPE_STRING_LIST, NULL},
{"hide_files_patterns", CONFIG_TYPE_EXT_PATTERN, NULL},
continue;
}
- if (listen(so.sock, SOMAXCONN) != 0) {
+ char *p = ctx->config[SO_MAX_CONNECTIONS];
+ long opt_max_connections = strtol(p, NULL, 10);
+ if(opt_max_connections > INT_MAX || opt_max_connections < 1) {
+ mg_cry(fc(ctx),
+ "max_connections value \"%s\" is invalid", p);
+ continue;
+ }
+
+ if (listen(so.sock, (int)opt_max_connections) != 0) {
mg_cry(fc(ctx),
"cannot listen to %.*s: %d (%s)",