Patch by Thomas Franco, rediffed for 4.20.

diff -ruN a/src/options.c b/src/options.c
--- a/src/options.c	2006-11-05 14:04:37.000000000 +0100
+++ b/src/options.c	2007-06-06 15:26:38.000000000 +0200
@@ -1202,6 +1202,24 @@
         break;
     }
 
+    /* listenqueue */
+    switch(cmd) {
+    case CMD_INIT:
+        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:
+        log_raw("%-15s = %d", "listenqueue", SOMAXCONN);
+	break;
+    case CMD_HELP:
+        log_raw("%-15s = defines the maximum length the queue of pending connections may grow to", "listenqueue");
+	break;
+    }
+
     if(cmd==CMD_EXEC)
         return option_not_found;
     return NULL; /* OK */
diff -ruN a/src/prototypes.h b/src/prototypes.h
--- a/src/prototypes.h	2006-11-11 14:03:05.000000000 +0100
+++ b/src/prototypes.h	2007-06-06 15:26:38.000000000 +0200
@@ -191,6 +191,7 @@
     int timeout_close; /* Maximum close_notify time */
     int timeout_connect; /* Maximum connect() time */
     int timeout_idle; /* Maximum idle connection time */
+    int listenqueue; /* Listen baklog */
 
         /* protocol name for protocol.c */
     char *protocol;
diff -ruN a/src/stunnel.c b/src/stunnel.c
--- a/src/stunnel.c	2006-11-30 21:47:45.000000000 +0100
+++ b/src/stunnel.c	2007-06-06 15:26:38.000000000 +0200
@@ -137,7 +137,7 @@
             exit(1);
         }
         s_log(LOG_DEBUG, "%s bound to %s", opt->servname, opt->local_address);
-        if(listen(opt->fd, 5)) {
+        if(listen(opt->fd, opt->listenqueue)) {
             sockerror("listen");
             exit(1);
         }
