summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2004-06-20 17:50:42 +0000
committerrwatson <rwatson@FreeBSD.org>2004-06-20 17:50:42 +0000
commite1348f014005ed3ab9abc2e559b935e00a58c058 (patch)
treee19326061ee0ea90bf25f4ff71429c80b0da4daf /sys/kern
parentd77a417b71bbe03720a314a0002d53c25c091cf3 (diff)
downloadFreeBSD-src-e1348f014005ed3ab9abc2e559b935e00a58c058.zip
FreeBSD-src-e1348f014005ed3ab9abc2e559b935e00a58c058.tar.gz
When retrieving the SO_LINGER socket option for user space, hold the
socket lock over pulling so_options and so_linger out of the socket structure in order to retrieve a consistent snapshot. This may be overkill if user space doesn't require a consistent snapshot.
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/uipc_socket.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index 9d3aa51..b1415d7 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -1641,8 +1641,15 @@ sogetopt(so, sopt)
#endif
case SO_LINGER:
+ /*
+ * XXXRW: We grab the lock here to get a consistent
+ * snapshot of both fields. This may not really
+ * be necessary.
+ */
+ SOCK_LOCK(so);
l.l_onoff = so->so_options & SO_LINGER;
l.l_linger = so->so_linger;
+ SOCK_UNLOCK(so);
error = sooptcopyout(sopt, &l, sizeof l);
break;
OpenPOWER on IntegriCloud