Make somaxconn (maximum backlog in a listen(2) request) and sb_max

(maximum size of a socket buffer) tunable.

Permit callers of listen(2) to specify a negative backlog, which
is translated into somaxconn.  Previously, a negative backlog was
silently translated into 0.
This commit is contained in:
Garrett Wollman 1995-11-03 18:33:46 +00:00
parent 2fc21bbbf1
commit ff5c09da20
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=12041
3 changed files with 18 additions and 8 deletions

View File

@ -31,11 +31,12 @@
* SUCH DAMAGE.
*
* @(#)uipc_socket2.c 8.1 (Berkeley) 6/10/93
* $Id: uipc_socket2.c,v 1.4 1994/10/02 17:35:33 phk Exp $
* $Id: uipc_socket2.c,v 1.5 1995/05/30 08:06:22 rgrimes Exp $
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/proc.h>
#include <sys/file.h>
#include <sys/buf.h>
@ -46,6 +47,7 @@
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/signalvar.h>
#include <sys/sysctl.h>
/*
* Primitive routines for operating on sockets and socket buffers
@ -56,7 +58,8 @@ char netio[] = "netio";
char netcon[] = "netcon";
char netcls[] = "netcls";
u_long sb_max = SB_MAX; /* patchable */
u_long sb_max = SB_MAX; /* XXX should be static */
SYSCTL_INT(_kern, KERN_MAXSOCKBUF, maxsockbuf, CTLFLAG_RW, &sb_max, 0, "")
/*
* Procedures to manipulate state flags of socket

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)uipc_socket.c 8.3 (Berkeley) 4/15/94
* $Id: uipc_socket.c,v 1.10 1995/05/30 08:06:21 rgrimes Exp $
* $Id: uipc_socket.c,v 1.11 1995/08/25 20:27:46 bde Exp $
*/
#include <sys/param.h>
@ -47,6 +47,10 @@
#include <sys/socketvar.h>
#include <sys/resourcevar.h>
#include <sys/signalvar.h>
#include <sys/sysctl.h>
static int somaxconn = SOMAXCONN;
SYSCTL_INT(_kern, KERN_SOMAXCONN, somaxconn, CTLFLAG_RW, &somaxconn, 0, "");
/*
* Socket operation routines.
@ -125,9 +129,9 @@ solisten(so, backlog)
}
if (so->so_q == 0)
so->so_options |= SO_ACCEPTCONN;
if (backlog < 0)
backlog = 0;
so->so_qlimit = min(backlog, SOMAXCONN);
if (backlog < 0 || backlog > somaxconn)
backlog = somaxconn;
so->so_qlimit = backlog;
splx(s);
return (0);
}

View File

@ -31,11 +31,12 @@
* SUCH DAMAGE.
*
* @(#)uipc_socket2.c 8.1 (Berkeley) 6/10/93
* $Id: uipc_socket2.c,v 1.4 1994/10/02 17:35:33 phk Exp $
* $Id: uipc_socket2.c,v 1.5 1995/05/30 08:06:22 rgrimes Exp $
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/proc.h>
#include <sys/file.h>
#include <sys/buf.h>
@ -46,6 +47,7 @@
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/signalvar.h>
#include <sys/sysctl.h>
/*
* Primitive routines for operating on sockets and socket buffers
@ -56,7 +58,8 @@ char netio[] = "netio";
char netcon[] = "netcon";
char netcls[] = "netcls";
u_long sb_max = SB_MAX; /* patchable */
u_long sb_max = SB_MAX; /* XXX should be static */
SYSCTL_INT(_kern, KERN_MAXSOCKBUF, maxsockbuf, CTLFLAG_RW, &sb_max, 0, "")
/*
* Procedures to manipulate state flags of socket