uipc_sockbuf.c (157370) | uipc_sockbuf.c (157927) |
---|---|
1/*- 2 * Copyright (c) 1982, 1986, 1988, 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 16 unchanged lines hidden (view full) --- 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * @(#)uipc_socket2.c 8.1 (Berkeley) 6/10/93 30 */ 31 32#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1982, 1986, 1988, 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 16 unchanged lines hidden (view full) --- 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * @(#)uipc_socket2.c 8.1 (Berkeley) 6/10/93 30 */ 31 32#include <sys/cdefs.h> |
33__FBSDID("$FreeBSD: head/sys/kern/uipc_sockbuf.c 157370 2006-04-01 15:42:02Z rwatson $"); | 33__FBSDID("$FreeBSD: head/sys/kern/uipc_sockbuf.c 157927 2006-04-21 09:25:40Z ps $"); |
34 35#include "opt_mac.h" 36#include "opt_param.h" 37 38#include <sys/param.h> 39#include <sys/aio.h> /* for aio_swake proto */ 40#include <sys/domain.h> 41#include <sys/event.h> | 34 35#include "opt_mac.h" 36#include "opt_param.h" 37 38#include <sys/param.h> 39#include <sys/aio.h> /* for aio_swake proto */ 40#include <sys/domain.h> 41#include <sys/event.h> |
42#include <sys/eventhandler.h> |
|
42#include <sys/file.h> /* for maxfiles */ 43#include <sys/kernel.h> 44#include <sys/lock.h> 45#include <sys/mac.h> 46#include <sys/malloc.h> 47#include <sys/mbuf.h> 48#include <sys/mutex.h> 49#include <sys/proc.h> --- 1453 unchanged lines hidden (view full) --- 1503 */ 1504SYSCTL_NODE(_kern, KERN_IPC, ipc, CTLFLAG_RW, 0, "IPC"); 1505 1506/* This takes the place of kern.maxsockbuf, which moved to kern.ipc. */ 1507static int dummy; 1508SYSCTL_INT(_kern, KERN_DUMMY, dummy, CTLFLAG_RW, &dummy, 0, ""); 1509SYSCTL_OID(_kern_ipc, KIPC_MAXSOCKBUF, maxsockbuf, CTLTYPE_ULONG|CTLFLAG_RW, 1510 &sb_max, 0, sysctl_handle_sb_max, "LU", "Maximum socket buffer size"); | 43#include <sys/file.h> /* for maxfiles */ 44#include <sys/kernel.h> 45#include <sys/lock.h> 46#include <sys/mac.h> 47#include <sys/malloc.h> 48#include <sys/mbuf.h> 49#include <sys/mutex.h> 50#include <sys/proc.h> --- 1453 unchanged lines hidden (view full) --- 1504 */ 1505SYSCTL_NODE(_kern, KERN_IPC, ipc, CTLFLAG_RW, 0, "IPC"); 1506 1507/* This takes the place of kern.maxsockbuf, which moved to kern.ipc. */ 1508static int dummy; 1509SYSCTL_INT(_kern, KERN_DUMMY, dummy, CTLFLAG_RW, &dummy, 0, ""); 1510SYSCTL_OID(_kern_ipc, KIPC_MAXSOCKBUF, maxsockbuf, CTLTYPE_ULONG|CTLFLAG_RW, 1511 &sb_max, 0, sysctl_handle_sb_max, "LU", "Maximum socket buffer size"); |
1511SYSCTL_INT(_kern_ipc, OID_AUTO, maxsockets, CTLFLAG_RDTUN, 1512 &maxsockets, 0, "Maximum number of sockets avaliable"); | 1512static int 1513sysctl_maxsockets(SYSCTL_HANDLER_ARGS) 1514{ 1515 int error, newmaxsockets; 1516 1517 newmaxsockets = maxsockets; 1518 error = sysctl_handle_int(oidp, &newmaxsockets, sizeof(int), req); 1519 if (error == 0 && req->newptr) { 1520 if (newmaxsockets > maxsockets) { 1521 maxsockets = newmaxsockets; 1522 if (maxsockets > ((maxfiles / 4) * 3)) { 1523 maxfiles = (maxsockets * 5) / 4; 1524 maxfilesperproc = (maxfiles * 9) / 10; 1525 } 1526 EVENTHANDLER_INVOKE(maxsockets_change); 1527 } else 1528 error = EINVAL; 1529 } 1530 return (error); 1531} 1532SYSCTL_PROC(_kern_ipc, OID_AUTO, maxsockets, CTLTYPE_INT|CTLFLAG_RW, 1533 &maxsockets, 0, sysctl_maxsockets, "IU", 1534 "Maximum number of sockets avaliable"); |
1513SYSCTL_ULONG(_kern_ipc, KIPC_SOCKBUF_WASTE, sockbuf_waste_factor, CTLFLAG_RW, 1514 &sb_efficiency, 0, ""); 1515 1516/* 1517 * Initialise maxsockets 1518 */ 1519static void init_maxsockets(void *ignored) 1520{ 1521 TUNABLE_INT_FETCH("kern.ipc.maxsockets", &maxsockets); 1522 maxsockets = imax(maxsockets, imax(maxfiles, nmbclusters)); 1523} 1524SYSINIT(param, SI_SUB_TUNABLES, SI_ORDER_ANY, init_maxsockets, NULL); | 1535SYSCTL_ULONG(_kern_ipc, KIPC_SOCKBUF_WASTE, sockbuf_waste_factor, CTLFLAG_RW, 1536 &sb_efficiency, 0, ""); 1537 1538/* 1539 * Initialise maxsockets 1540 */ 1541static void init_maxsockets(void *ignored) 1542{ 1543 TUNABLE_INT_FETCH("kern.ipc.maxsockets", &maxsockets); 1544 maxsockets = imax(maxsockets, imax(maxfiles, nmbclusters)); 1545} 1546SYSINIT(param, SI_SUB_TUNABLES, SI_ORDER_ANY, init_maxsockets, NULL); |