freebsd-dev/sys
Robert Watson 83b3d58d05 In the current world order, each socket has two mutexes: a mutex
that protects socket and receive socket buffer state, and a second
mutex to protect send socket buffer state.  In some places, the
mutex shared between the socket and receive socket buffer will be
acquired twice, once by each layer, resulting in some
inconsistency, but providing the abstraction benefit of being able
to more easily separate the two mutexes in the future if desired.

When transitioning a socket to the SS_ISDISCONNECTING or
SS_ISDISCONNECTED states, grab the socket/receive socket buffer lock
once rather than grabbing it as the socket lock, modifying socket
state, then grabbing a second time as the receive lock in order to
modify the socket buffer state to indicate no further data can be
read.  This change is believed to close a race between the change in
socket state and the change in socket buffer state, which for a
remotely initiated close on a UNIX domain socket, resulted in
soreceive() returning ENOTCONN rather than an EOF condition.

A similar race still exists in the case of send, however, and is
harder to fix as the socket and send socket buffer mutexes are not
the same, and we would like to avoid holding combinations of socket
mutexes over sb_upcall until we've finished clarifying the locking
protocol for upcalls.

This change has the side affect of reducing the number of mutex
operations to initiate disconnect or perform disconnect on a
socket by two.

PR:		78824
Rerported by:	Marc Olzheim <marcolz@stack.nl>
MFC after:	2 weeks
2005-05-27 17:16:43 +00:00
..
alpha For ISA DMA maps, the chipsets scatter/gather feature is used. As 2005-05-25 07:25:12 +00:00
amd64 Add new ral(4) and ural(4) drivers. 2005-05-24 16:48:07 +00:00
arm Remove pmap_deactivate(), we do not use it. 2005-05-27 00:45:39 +00:00
boot Since the BAT mapping was removed a long time back, it can't 2005-05-24 21:43:49 +00:00
bsm
cam Do not initialize path variable with useless value just before 2005-05-11 17:39:33 +00:00
coda - Change all filesystems and vfs_cache to relock the dvp once the child is 2005-04-13 10:59:09 +00:00
compat Copyout to userland if kern_sigaction succeeds 2005-05-24 17:52:14 +00:00
conf MFi386: Add ReiserFS 2005-05-25 12:32:06 +00:00
contrib This commit was generated by cvs2svn to compensate for changes in r146539, 2005-05-23 13:08:32 +00:00
crypto
ddb Don't enter the debugger if KDB_UNATTENDED is set or if 2005-04-20 20:52:46 +00:00
dev Latest README to correspond to latest Intel version 2.1.7 2005-05-26 23:33:24 +00:00
doc
fs Fix three typos in comments. Two of them obtained from OpenBSD. 2005-05-11 21:10:35 +00:00
gdb check return value of gdb_rx_varhex 2005-03-28 18:31:18 +00:00
geom After provider creation!! 2005-05-25 15:54:17 +00:00
gnu Import of ReiserFS filesystem support (currently limited to read-only on 2005-05-24 12:24:45 +00:00
i4b Don't use 'i386/include' directly. 2005-04-08 03:37:20 +00:00
i386 - Move the REISERFS option in the MD NOTES file for i386, it doesn't 2005-05-24 18:31:34 +00:00
ia64 - Move bus dependent defines to {isa,cbus}_dmareg.h. 2005-05-14 10:14:56 +00:00
isa - Move bus dependent defines to {isa,cbus}_dmareg.h. 2005-05-14 10:14:56 +00:00
isofs/cd9660 - Change all filesystems and vfs_cache to relock the dvp once the child is 2005-04-13 10:59:09 +00:00
kern In the current world order, each socket has two mutexes: a mutex 2005-05-27 17:16:43 +00:00
libkern Fix kiconv on the 64bit plathomes. 2005-05-24 15:38:08 +00:00
modules Connect the ReiserFS filesystem to the modules build (i386 only). 2005-05-24 12:30:13 +00:00
net Plug mbuf leak, that I have introduced in 1.85. Also restore important comment 2005-05-26 06:50:00 +00:00
net80211 Revise crypto api lightly to improve group key handling: 2005-04-12 17:55:13 +00:00
netatalk
netatm
netgraph Remove local error variable, which leads to hiding error from return 2005-05-23 13:49:49 +00:00
netinet This is conform with the terminology in 2005-05-25 17:55:27 +00:00
netinet6 Fixes for various nits found by the Coverity tool. 2005-05-15 02:28:30 +00:00
netipsec
netipx Back out ipx.h:1.18, which introduced a Linux API compatibility field in 2005-05-27 12:25:42 +00:00
netkey
netnatm
netncp
netsmb lockmgr(...,LK_DRAIN,...) requires a balancing LK_RELEASE: recent 2005-05-13 11:27:48 +00:00
nfs
nfs4client - We want if (mrep != NULL) not if (m_freem != NULL). m_freem will never 2005-04-25 05:11:19 +00:00
nfsclient Ugh. Previous commit got the logic exactly backward. 2005-05-17 18:23:03 +00:00
nfsserver NFS write gathering defers execution of NFS server write requests to wait 2005-04-17 16:25:36 +00:00
opencrypto
pc98 MFi386: Add ReiserFS 2005-05-25 12:32:06 +00:00
pccard Change a directory layout for pc98. 2005-05-10 12:02:18 +00:00
pci Calling xl_rxeof() at the end of xl_start_locked() leads to recursion 2005-05-20 07:16:09 +00:00
posix4 Introduce MAC Framework and MAC Policy entry points to label and control 2005-05-04 10:39:15 +00:00
powerpc Quick hack-o-rama to allow the Xorg Radeon driver to start up. It 2005-05-21 00:22:57 +00:00
rpc - Don't call rpcclnt_realign() if we don't have any mbufs to realign. 2005-03-19 01:16:25 +00:00
security Introduce MAC Framework and MAC Policy entry points to label and control 2005-05-04 10:39:15 +00:00
sparc64 - Hook up machfb(4) to the sparc64 build, not enabled in GENERIC 2005-05-21 20:50:45 +00:00
sys Remove thread_upcall_check, it was used to avoid race bug in earlier 2005-05-27 15:57:27 +00:00
tools - Add the character "E" to the understood lock types. This means 2005-04-11 15:15:03 +00:00
ufs Allow removal of empty directories with high link counts. These can 2005-05-18 22:18:21 +00:00
vm Use low level constructs borrowed from interrupt threads to wait for 2005-05-23 23:01:53 +00:00
Makefile