Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/kern/uipc_socket.c,v retrieving revision 1.116.2.4 retrieving revision 1.117 diff -u -p -r1.116.2.4 -r1.117 --- src/sys/kern/uipc_socket.c 2006/08/11 15:45:47 1.116.2.4 +++ src/sys/kern/uipc_socket.c 2006/04/11 09:32:58 1.117 @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_socket.c,v 1.116.2.4 2006/08/11 15:45:47 yamt Exp $ */ +/* $NetBSD: uipc_socket.c,v 1.117 2006/04/11 09:32:58 yamt Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.116.2.4 2006/08/11 15:45:47 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.117 2006/04/11 09:32:58 yamt Exp $"); #include "opt_sock_counters.h" #include "opt_sosend_loan.h" @@ -91,7 +91,6 @@ __KERNEL_RCSID(0, "$NetBSD: uipc_socket. #include #include #include -#include #include @@ -127,12 +126,20 @@ EVCNT_ATTACH_STATIC(sosend_kvalimit); #endif /* SOSEND_COUNTERS */ -static struct callback_entry sokva_reclaimerentry; +void +soinit(void) +{ + + /* Set the initial adjusted socket buffer size. */ + if (sb_max_set(sb_max)) + panic("bad initial sb_max value: %lu", sb_max); + +} #ifdef SOSEND_NO_LOAN -int sock_loan_thresh = -1; +int use_sosend_loan = 0; #else -int sock_loan_thresh = 4096; +int use_sosend_loan = 1; #endif static struct simplelock so_pendfree_slock = SIMPLELOCK_INITIALIZER; @@ -145,6 +152,7 @@ int somaxkva = SOMAXKVA; static int socurkva; static int sokvawaiters; +#define SOCK_LOAN_THRESH 4096 #define SOCK_LOAN_CHUNK 65536 static size_t sodopendfree(void); @@ -431,32 +439,6 @@ sosend_loan(struct socket *so, struct ui return (space); } -static int -sokva_reclaim_callback(struct callback_entry *ce, void *obj, void *arg) -{ - - KASSERT(ce == &sokva_reclaimerentry); - KASSERT(obj == NULL); - - sodopendfree(); - if (!vm_map_starved_p(kernel_map)) { - return CALLBACK_CHAIN_ABORT; - } - return CALLBACK_CHAIN_CONTINUE; -} - -void -soinit(void) -{ - - /* Set the initial adjusted socket buffer size. */ - if (sb_max_set(sb_max)) - panic("bad initial sb_max value: %lu", sb_max); - - callback_register(&vm_map_to_kernel(kernel_map)->vmk_reclaim_callback, - &sokva_reclaimerentry, NULL, sokva_reclaim_callback); -} - /* * Socket operation routines. * These routines are called by the routines in @@ -477,16 +459,7 @@ socreate(int dom, struct socket **aso, i prp = pffindproto(dom, proto, type); else prp = pffindtype(dom, type); - if (prp == 0) { - /* no support for domain */ - if (pffinddomain(dom) == 0) - return (EAFNOSUPPORT); - /* no support for socket type */ - if (proto == 0 && type != 0) - return (EPROTOTYPE); - return (EPROTONOSUPPORT); - } - if (prp->pr_usrreq == 0) + if (prp == 0 || prp->pr_usrreq == 0) return (EPROTONOSUPPORT); if (prp->pr_type != type) return (EPROTOTYPE); @@ -505,7 +478,7 @@ socreate(int dom, struct socket **aso, i so->so_mowner = &prp->pr_domain->dom_mowner; #endif if (l != NULL) { - uid = kauth_cred_geteuid(l->l_cred); + uid = l->l_proc->p_ucred->cr_uid; } else { uid = 0; } @@ -852,9 +825,9 @@ sosend(struct socket *so, struct mbuf *a mlen = MLEN; } MCLAIM(m, so->so_snd.sb_mowner); - if (sock_loan_thresh >= 0 && - uio->uio_iov->iov_len >= sock_loan_thresh && - space >= sock_loan_thresh && + if (use_sosend_loan && + uio->uio_iov->iov_len >= SOCK_LOAN_THRESH && + space >= SOCK_LOAN_THRESH && (len = sosend_loan(so, uio, m, space)) != 0) { SOSEND_COUNTER_INCR(&sosend_loan_big);