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)
Wed, Jan 22, 10:29 PM
Unknown Object (File)
Fri, Jan 3, 11:31 AM
Unknown Object (File)
Sat, Dec 28, 8:39 AM
Unknown Object (File)
Dec 5 2024, 2:57 AM
Unknown Object (File)
Dec 4 2024, 9:22 PM
Unknown Object (File)
Dec 2 2024, 4:31 AM
Unknown Object (File)
Nov 24 2024, 3:47 PM
Unknown Object (File)
Nov 22 2024, 10:31 AM
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.