summaryrefslogtreecommitdiffstats
path: root/sys/kern/sys_socket.c
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2008-10-07 07:10:28 +0000
committerrwatson <rwatson@FreeBSD.org>2008-10-07 07:10:28 +0000
commit064d14f0bc93c6d6cb6ff33a782794a4624c25a0 (patch)
tree2967c0189673e19ce7605ce1d66cc05ac931ca3e /sys/kern/sys_socket.c
parent83b7a52a1639cf331a280b0e55216edc2b3cd45d (diff)
downloadFreeBSD-src-064d14f0bc93c6d6cb6ff33a782794a4624c25a0.zip
FreeBSD-src-064d14f0bc93c6d6cb6ff33a782794a4624c25a0.tar.gz
Lock receive socket buffer in soo_stat() rather than commenting that we
should lock it, which may marginally improve the consistency of the results. Remove comment. MFC after: 3 days
Diffstat (limited to 'sys/kern/sys_socket.c')
-rw-r--r--sys/kern/sys_socket.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/sys/kern/sys_socket.c b/sys/kern/sys_socket.c
index aeeaf33..813b1dd 100644
--- a/sys/kern/sys_socket.c
+++ b/sys/kern/sys_socket.c
@@ -246,17 +246,16 @@ soo_stat(struct file *fp, struct stat *ub, struct ucred *active_cred,
/*
* If SBS_CANTRCVMORE is set, but there's still data left in the
* receive buffer, the socket is still readable.
- *
- * XXXRW: perhaps should lock socket buffer so st_size result is
- * consistent.
*/
- /* Unlocked read. */
+ SOCKBUF_LOCK(&so->so_rcv);
if ((so->so_rcv.sb_state & SBS_CANTRCVMORE) == 0 ||
so->so_rcv.sb_cc != 0)
ub->st_mode |= S_IRUSR | S_IRGRP | S_IROTH;
+ ub->st_size = so->so_rcv.sb_cc - so->so_rcv.sb_ctl;
+ SOCKBUF_UNLOCK(&so->so_rcv);
+ /* Unlocked read. */
if ((so->so_snd.sb_state & SBS_CANTSENDMORE) == 0)
ub->st_mode |= S_IWUSR | S_IWGRP | S_IWOTH;
- 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);
OpenPOWER on IntegriCloud