From 4b62fe5b0b4a6fa11fadb1a363a3dabdeb534722 Mon Sep 17 00:00:00 2001 From: Andre Oppermann Date: Fri, 19 Oct 2012 12:16:29 +0000 Subject: [PATCH] Move socket UMA zone initialization functionality together into one place. --- sys/kern/uipc_socket.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 2939be130d6f..b31bdae1fde2 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -173,11 +173,8 @@ static struct filterops sowrite_filtops = { .f_event = filt_sowrite, }; -uma_zone_t socket_zone; so_gen_t so_gencnt; /* generation count for sockets */ -int maxsockets; - MALLOC_DEFINE(M_SONAME, "soname", "socket name"); MALLOC_DEFINE(M_PCB, "pcb", "protocol control block"); @@ -230,6 +227,9 @@ SYSCTL_NODE(_kern, KERN_IPC, ipc, CTLFLAG_RW, 0, "IPC"); * Initialize the socket subsystem and set up the socket * memory allocator. */ +uma_zone_t socket_zone; +int maxsockets; + static void socket_zone_change(void *tag) { @@ -249,6 +249,19 @@ socket_init(void *tag) } SYSINIT(socket, SI_SUB_PROTO_DOMAININIT, SI_ORDER_ANY, socket_init, NULL); +/* + * Initialise maxsockets. This SYSINIT must be run after + * tunable_mbinit(). + */ +static void +init_maxsockets(void *ignored) +{ + + TUNABLE_INT_FETCH("kern.ipc.maxsockets", &maxsockets); + maxsockets = imax(maxsockets, imax(maxfiles, nmbclusters)); +} +SYSINIT(param, SI_SUB_TUNABLES, SI_ORDER_ANY, init_maxsockets, NULL); + /* * Sysctl to get and set the maximum global sockets limit. Notify protocols * of the change so that they can update their dependent limits as required. @@ -273,24 +286,10 @@ sysctl_maxsockets(SYSCTL_HANDLER_ARGS) } return (error); } - SYSCTL_PROC(_kern_ipc, OID_AUTO, maxsockets, CTLTYPE_INT|CTLFLAG_RW, &maxsockets, 0, sysctl_maxsockets, "IU", "Maximum number of sockets avaliable"); -/* - * Initialise maxsockets. This SYSINIT must be run after - * tunable_mbinit(). - */ -static void -init_maxsockets(void *ignored) -{ - - TUNABLE_INT_FETCH("kern.ipc.maxsockets", &maxsockets); - maxsockets = imax(maxsockets, imax(maxfiles, nmbclusters)); -} -SYSINIT(param, SI_SUB_TUNABLES, SI_ORDER_ANY, init_maxsockets, NULL); - /* * Socket operation routines. These routines are called by the routines in * sys_socket.c or from a system process, and implement the semantics of