global_queuelen 1.81 KB
Newer Older
1 2
--- a/inetd.c
+++ b/inetd.c
Marco d'Itri's avatar
Marco d'Itri committed
3
@@ -175,6 +175,7 @@ int lflag = 0;
4 5 6 7
 #endif
 
 int	 debug = 0;
+int	 global_queuelen = 128;
Marco d'Itri's avatar
Marco d'Itri committed
8 9 10 11 12
 int	 maxsock;
 int	 toomany = TOOMANY;
 int	 timingout;
@@ -315,7 +316,7 @@ main(int argc, char *argv[], char *envp[
 
13 14 15 16 17 18 19
 	initsetproctitle(argc, argv, envp);
 
-	while ((ch = getopt(argc, argv, "dEilR:")) != -1)
+	while ((ch = getopt(argc, argv, "dEilq:R:")) != -1)
 		switch (ch) {
 		case 'd':
 			debug = 1;
Marco d'Itri's avatar
Marco d'Itri committed
20
@@ -335,6 +336,11 @@ main(int argc, char *argv[], char *envp[
21 22 23 24 25 26 27 28 29 30 31
 			    progname);
 			exit(1);
 #endif
+		case 'q':
+			global_queuelen = atoi(optarg);
+			if (global_queuelen < 10)
+				global_queuelen = 10;
+			break;
 		case 'R': {	/* invocation rate */
 			char *p;
 			int val;
Marco d'Itri's avatar
Marco d'Itri committed
32
@@ -352,7 +358,7 @@ main(int argc, char *argv[], char *envp[
33 34 35
 		case '?':
 		default:
 			fprintf(stderr,
36 37
-			    "usage: inetd [-dEil] [-R rate] [configuration_file]\n");
+			    "usage: inetd [-dEil] [-q len] [-R rate] [configuration_file]\n");
38 39
 			exit(1);
 		}
40
 	argc -= optind;
Marco d'Itri's avatar
Marco d'Itri committed
41
@@ -932,7 +938,7 @@ setsockopt(fd, SOL_SOCKET, opt, &on, siz
42 43 44 45 46 47
 		return;
 	}
 	if (sep->se_socktype == SOCK_STREAM)
-		listen(sep->se_fd, 10);
+		listen(sep->se_fd, global_queuelen);
 
Marco d'Itri's avatar
Marco d'Itri committed
48 49
 	if (!sep->se_wait && sep->se_socktype == SOCK_STREAM) {
 		event_set(&sep->se_event, sep->se_fd, EV_READ|EV_PERSIST,
50 51 52 53 54 55 56 57 58 59
--- a/inetd.8
+++ b/inetd.8
@@ -41,6 +41,7 @@
 .Op Fl E
 .Op Fl i
 .Op Fl l
+.Op Fl q Ar length
 .Op Fl R Ar rate
 .Op Ar configuration_file
 .Sh DESCRIPTION
Marco d'Itri's avatar
Marco d'Itri committed
60
@@ -77,6 +78,10 @@ Internal services cannot be wrapped.  Wh
61 62 63 64 65 66 67 68 69 70
 is silently not executed even if present in
 .Pa /etc/inetd.conf
 and instead libwrap is called directly by inetd.
+.It Fl q Ar length
+Specify the length of the
+.Xr listen 2
+connections queue; the default is 128.
 .It Fl R Ar rate
 Specify the maximum number of times a service can be invoked
 in one minute; the default is 256.