diff options
author | andre <andre@FreeBSD.org> | 2012-10-20 10:51:32 +0000 |
---|---|---|
committer | andre <andre@FreeBSD.org> | 2012-10-20 10:51:32 +0000 |
commit | e3d188653565da508fb2c0648426ff3f8dfa0b8a (patch) | |
tree | f40a9b5686cb4ee9aa37cbc652c5e106bd10cb3d /sys/kern/uipc_socket.c | |
parent | 37c9a4dd0576b14ed709ed49090e6f5e218ecaf1 (diff) | |
download | FreeBSD-src-e3d188653565da508fb2c0648426ff3f8dfa0b8a.zip FreeBSD-src-e3d188653565da508fb2c0648426ff3f8dfa0b8a.tar.gz |
Tidy up somaxconn (accept queue limit) and related functions
and move it together into one place.
Diffstat (limited to 'sys/kern/uipc_socket.c')
-rw-r--r-- | sys/kern/uipc_socket.c | 48 |
1 files changed, 26 insertions, 22 deletions
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index b31bdae..6b5581f 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -182,15 +182,37 @@ MALLOC_DEFINE(M_PCB, "pcb", "protocol control block"); VNET_ASSERT(curvnet != NULL, \ ("%s:%d curvnet is NULL, so=%p", __func__, __LINE__, (so))); +/* + * Limit on the number of connections in the listen queue waiting + * for accept(2). + */ static int somaxconn = SOMAXCONN; -static int sysctl_somaxconn(SYSCTL_HANDLER_ARGS); -/* XXX: we dont have SYSCTL_USHORT */ + +static int +sysctl_somaxconn(SYSCTL_HANDLER_ARGS) +{ + int error; + int val; + + val = somaxconn; + error = sysctl_handle_int(oidp, &val, 0, req); + if (error || !req->newptr ) + return (error); + + if (val < 1 || val > USHRT_MAX) + return (EINVAL); + + somaxconn = val; + return (0); +} SYSCTL_PROC(_kern_ipc, KIPC_SOMAXCONN, somaxconn, CTLTYPE_UINT | CTLFLAG_RW, - 0, sizeof(int), sysctl_somaxconn, "I", "Maximum pending socket connection " - "queue size"); + 0, sizeof(int), sysctl_somaxconn, "I", + "Maximum listen socket pending connection accept queue size"); + static int numopensockets; SYSCTL_INT(_kern_ipc, OID_AUTO, numopensockets, CTLFLAG_RD, &numopensockets, 0, "Number of open sockets"); + #ifdef ZERO_COPY_SOCKETS /* These aren't static because they're used in other files. */ int so_zero_copy_send = 1; @@ -3269,24 +3291,6 @@ socheckuid(struct socket *so, uid_t uid) return (0); } -static int -sysctl_somaxconn(SYSCTL_HANDLER_ARGS) -{ - int error; - int val; - - val = somaxconn; - error = sysctl_handle_int(oidp, &val, 0, req); - if (error || !req->newptr ) - return (error); - - if (val < 1 || val > USHRT_MAX) - return (EINVAL); - - somaxconn = val; - return (0); -} - /* * These functions are used by protocols to notify the socket layer (and its * consumers) of state changes in the sockets driven by protocol-side events. |