From 92f30976fe9d08c23ba40cb7e6d74d64d73af87f Mon Sep 17 00:00:00 2001 From: rwatson Date: Thu, 22 Jul 2004 20:40:23 +0000 Subject: Push Giant acquisition down into fo_stat() from most callers. Acquire Giant conditional on debug.mpsafenet in the socket soo_stat() routine, unconditionally in vn_statfile() for VFS, and otherwise don't acquire Giant. Accept an unlocked read in kqueue_stat(), and cryptof_stat() is a no-op. Don't acquire Giant in fstat() system call. Note: in fdescfs, fo_stat() is called while holding Giant due to the VFS stack sitting on top, and therefore there will still be Giant recursion in this case. --- sys/kern/sys_socket.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'sys/kern/sys_socket.c') diff --git a/sys/kern/sys_socket.c b/sys/kern/sys_socket.c index e1de4b7..cbaa587 100644 --- a/sys/kern/sys_socket.c +++ b/sys/kern/sys_socket.c @@ -225,9 +225,11 @@ soo_stat(fp, ub, active_cred, td) struct thread *td; { struct socket *so = fp->f_data; + int error; bzero((caddr_t)ub, sizeof (*ub)); ub->st_mode = S_IFSOCK; + NET_LOCK_GIANT(); /* * If SBS_CANTRCVMORE is set, but there's still data left in the * receive buffer, the socket is still readable. @@ -244,7 +246,9 @@ soo_stat(fp, ub, active_cred, td) ub->st_size = so->so_rcv.sb_cc - so->so_rcv.sb_ctl; ub->st_uid = so->so_cred->cr_uid; ub->st_gid = so->so_cred->cr_gid; - return ((*so->so_proto->pr_usrreqs->pru_sense)(so, ub)); + error = (*so->so_proto->pr_usrreqs->pru_sense)(so, ub); + NET_UNLOCK_GIANT(); + return (error); } /* -- cgit v1.1