diff -u src.orig/options.c src/options.c --- src.orig/options.c 2015-01-02 15:29:55.000000000 +0100 +++ src/options.c 2015-01-14 13:01:04.118253473 +0100 @@ -1635,6 +1635,24 @@ break; } + /* listenqueue option */ + switch(cmd) { + case CMD_BEGIN: + section->listenqueue=SOMAXCONN; + break; + case CMD_EXEC: + if(strcasecmp(opt, "listenqueue")) + break; + section->listenqueue=atoi(arg); + return (section->listenqueue?NULL:"Bad verify level"); + case CMD_DEFAULT: + s_log(LOG_NOTICE, "%-15s = %d", "listenqueue", SOMAXCONN); + break; + case CMD_HELP: + s_log(LOG_NOTICE, "%-15s = defines the maximum length the queue of pending connections may grow to (max SOMAXCONN)", "listenqueue"); + break; + } + #ifndef OPENSSL_NO_OCSP /* OCSP */ diff -u src.orig/prototypes.h src/prototypes.h --- src.orig/prototypes.h 2015-01-02 16:00:49.000000000 +0100 +++ src/prototypes.h 2015-01-14 13:01:50.242676838 +0100 @@ -223,6 +223,7 @@ int timeout_close; /* maximum close_notify time */ int timeout_connect; /* maximum connect() time */ int timeout_idle; /* maximum idle connection time */ + int listenqueue; /* Listen backlog */ enum {FAILOVER_RR, FAILOVER_PRIO} failover; /* failover strategy */ char *username; diff -u src.orig/stunnel.c src/stunnel.c --- src.orig/stunnel.c 2015-01-02 15:29:55.000000000 +0100 +++ src/stunnel.c 2015-01-14 13:02:19.440311818 +0100 @@ -449,7 +449,7 @@ str_free(local_address); return 1; } - if(listen(opt->fd, SOMAXCONN)) { + if(listen(opt->fd, opt->listenqueue)) { sockerror("listen"); closesocket(opt->fd); opt->fd=-1;