Page MenuHomeFreeBSD

[unix(4) cleanup 6/8] Simplify connection peer locking.
ClosedPublic

Authored by markj on Sep 2 2020, 4:59 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Nov 24, 3:47 PM
Unknown Object (File)
Fri, Nov 22, 10:31 AM
Unknown Object (File)
Thu, Nov 21, 2:37 PM
Unknown Object (File)
Tue, Nov 19, 9:38 AM
Unknown Object (File)
Sun, Nov 17, 11:51 PM
Unknown Object (File)
Thu, Nov 7, 12:55 AM
Unknown Object (File)
Tue, Nov 5, 9:35 AM
Unknown Object (File)
Fri, Nov 1, 7:27 PM
Subscribers

Details

Summary

unp_pcb_owned_lock2() has some sharp edges and forces callers to deal
with a bunch of cases. Simplify it:


- Rename to unp_pcb_lock_peer().
- Return the connected peer instead of forcing callers to load it
beforehand.
- Handle self-connected sockets.
- In unp_connectat(), just lock the accept socket directly. I believe
it is safe to do so.
- Get rid of connect_internal(). Callers verify that the socket is
connected afterward, and unp_connect() will be modified in a follow-up
diff to verify that the socket is not already connected.
- (Ab)use UNP_CONNECTING to guard against concurrent creation of
connections while relocking PCBs.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

markj requested review of this revision.Sep 2 2020, 4:59 PM
markj created this revision.

Use unp_pcb_unlock_pair().

sys/kern/uipc_usrreq.c
399 ↗(On Diff #76551)

This is too simplistic. We need to use a separate counter here, and unp_connectat() should sleep if threads are waiting to acquire a lock.

  • Fix the mechanism used to block new connections when another thread is attempting to lock both sides of a connection.
  • Subsume patch 8, which is closely related to this one.
This revision was not accepted when it landed; it landed in state Needs Review.Sep 15 2020, 7:23 PM
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.