Proposal: add pru_close protosw method, refactor abort/detach
Robert Watson
rwatson at FreeBSD.org
Sun Jun 18 08:34:46 UTC 2006
On Sun, 18 Jun 2006, Robert Watson wrote:
> Attached is a patch that attempts to further rationalize tear-down.
> Specifically, it refactors pru_detach (disconnect and conditionally free)
> and pru_abort (disconnect abruptly and free) into three protocol switch
> functions:
>
> pru_close: socket has been closed and a sensible shutdown without data loss
> is desired.
>
> pru_abort: socket is being aborted, generally due to insufficient queue
> space in a listen socket, or close of a listen socket while connections are
> waiting to be accepted: close abruptly and potentially with data loss.
>
> pru_detach: teardown is now unconditional -- both the protocol and socket
> are done.
I realized, of course, that I omitted to specifically describe the specific
chicken-and-egg problem that kicked this off: if the protocol lends a lock to
the socket layer for use over the reference count, then the protocol detach
must occur after any last possible use of that lock, and in the current world
order, the lock was used several times after the call to detach -- possibly
before a second call to detach, for example. The new arrangement basically
guarantees that the socket is done calling into the protocol and using the
potentially lent lock before calling a now unconditional detach.
Robert N M Watson
Computer Laboratory
University of Cambridge
More information about the freebsd-arch
mailing list