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.
This commit is contained in:
Robert Watson 2004-06-20 17:50:42 +00:00
parent 6f4b1b5578
commit fa8368a8fe

View File

@ -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;