uipc_socket.c (243627) | uipc_socket.c (243631) |
---|---|
1/*- 2 * Copyright (c) 1982, 1986, 1988, 1990, 1993 3 * The Regents of the University of California. 4 * Copyright (c) 2004 The FreeBSD Foundation 5 * Copyright (c) 2004-2008 Robert N. M. Watson 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 87 unchanged lines hidden (view full) --- 96 * NOTE: With regard to VNETs the general rule is that callers do not set 97 * curvnet. Exceptions to this rule include soabort(), sodisconnect(), 98 * sofree() (and with that sorele(), sotryfree()), as well as sonewconn() 99 * and sorflush(), which are usually called from a pre-set VNET context. 100 * sopoll() currently does not need a VNET context to be set. 101 */ 102 103#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1982, 1986, 1988, 1990, 1993 3 * The Regents of the University of California. 4 * Copyright (c) 2004 The FreeBSD Foundation 5 * Copyright (c) 2004-2008 Robert N. M. Watson 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 87 unchanged lines hidden (view full) --- 96 * NOTE: With regard to VNETs the general rule is that callers do not set 97 * curvnet. Exceptions to this rule include soabort(), sodisconnect(), 98 * sofree() (and with that sorele(), sotryfree()), as well as sonewconn() 99 * and sorflush(), which are usually called from a pre-set VNET context. 100 * sopoll() currently does not need a VNET context to be set. 101 */ 102 103#include <sys/cdefs.h> |
104__FBSDID("$FreeBSD: head/sys/kern/uipc_socket.c 243627 2012-11-27 20:04:52Z andre $"); | 104__FBSDID("$FreeBSD: head/sys/kern/uipc_socket.c 243631 2012-11-27 21:19:58Z andre $"); |
105 106#include "opt_inet.h" 107#include "opt_inet6.h" 108#include "opt_zero.h" 109#include "opt_compat.h" 110 111#include <sys/param.h> 112#include <sys/systm.h> --- 172 unchanged lines hidden (view full) --- 285 * Initialise maxsockets. This SYSINIT must be run after 286 * tunable_mbinit(). 287 */ 288static void 289init_maxsockets(void *ignored) 290{ 291 292 TUNABLE_INT_FETCH("kern.ipc.maxsockets", &maxsockets); | 105 106#include "opt_inet.h" 107#include "opt_inet6.h" 108#include "opt_zero.h" 109#include "opt_compat.h" 110 111#include <sys/param.h> 112#include <sys/systm.h> --- 172 unchanged lines hidden (view full) --- 285 * Initialise maxsockets. This SYSINIT must be run after 286 * tunable_mbinit(). 287 */ 288static void 289init_maxsockets(void *ignored) 290{ 291 292 TUNABLE_INT_FETCH("kern.ipc.maxsockets", &maxsockets); |
293 maxsockets = imax(maxsockets, imax(maxfiles, nmbclusters)); | 293 maxsockets = imax(maxsockets, maxfiles); |
294} 295SYSINIT(param, SI_SUB_TUNABLES, SI_ORDER_ANY, init_maxsockets, NULL); 296 297/* 298 * Sysctl to get and set the maximum global sockets limit. Notify protocols 299 * of the change so that they can update their dependent limits as required. 300 */ 301static int 302sysctl_maxsockets(SYSCTL_HANDLER_ARGS) 303{ 304 int error, newmaxsockets; 305 306 newmaxsockets = maxsockets; 307 error = sysctl_handle_int(oidp, &newmaxsockets, 0, req); 308 if (error == 0 && req->newptr) { | 294} 295SYSINIT(param, SI_SUB_TUNABLES, SI_ORDER_ANY, init_maxsockets, NULL); 296 297/* 298 * Sysctl to get and set the maximum global sockets limit. Notify protocols 299 * of the change so that they can update their dependent limits as required. 300 */ 301static int 302sysctl_maxsockets(SYSCTL_HANDLER_ARGS) 303{ 304 int error, newmaxsockets; 305 306 newmaxsockets = maxsockets; 307 error = sysctl_handle_int(oidp, &newmaxsockets, 0, req); 308 if (error == 0 && req->newptr) { |
309 if (newmaxsockets > maxsockets) { | 309 if (newmaxsockets > maxsockets && 310 newmaxsockets <= maxfiles) { |
310 maxsockets = newmaxsockets; | 311 maxsockets = newmaxsockets; |
311 if (maxsockets > ((maxfiles / 4) * 3)) { 312 maxfiles = (maxsockets * 5) / 4; 313 maxfilesperproc = (maxfiles * 9) / 10; 314 } | |
315 EVENTHANDLER_INVOKE(maxsockets_change); 316 } else 317 error = EINVAL; 318 } 319 return (error); 320} 321SYSCTL_PROC(_kern_ipc, OID_AUTO, maxsockets, CTLTYPE_INT|CTLFLAG_RW, 322 &maxsockets, 0, sysctl_maxsockets, "IU", --- 3383 unchanged lines hidden --- | 312 EVENTHANDLER_INVOKE(maxsockets_change); 313 } else 314 error = EINVAL; 315 } 316 return (error); 317} 318SYSCTL_PROC(_kern_ipc, OID_AUTO, maxsockets, CTLTYPE_INT|CTLFLAG_RW, 319 &maxsockets, 0, sysctl_maxsockets, "IU", --- 3383 unchanged lines hidden --- |