From 720efebbba89f0ed3381913203af601ee17ba25f Mon Sep 17 00:00:00 2001 From: rwatson Date: Fri, 21 Jul 2006 17:11:15 +0000 Subject: Change semantics of socket close and detach. Add a new protocol switch function, pru_close, to notify protocols that the file descriptor or other consumer of a socket is closing the socket. pru_abort is now a notification of close also, and no longer detaches. pru_detach is no longer used to notify of close, and will be called during socket tear-down by sofree() when all references to a socket evaporate after an earlier call to abort or close the socket. This means detach is now an unconditional teardown of a socket, whereas previously sockets could persist after detach of the protocol retained a reference. This faciliates sharing mutexes between layers of the network stack as the mutex is required during the checking and removal of references at the head of sofree(). With this change, pru_detach can now assume that the mutex will no longer be required by the socket layer after completion, whereas before this was not necessarily true. Reviewed by: gnn --- sys/net/raw_usrreq.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'sys/net/raw_usrreq.c') diff --git a/sys/net/raw_usrreq.c b/sys/net/raw_usrreq.c index 4f2f006..b584860 100644 --- a/sys/net/raw_usrreq.c +++ b/sys/net/raw_usrreq.c @@ -146,7 +146,16 @@ raw_uabort(struct socket *so) KASSERT(rp != NULL, ("raw_uabort: rp == NULL")); raw_disconnect(rp); soisdisconnected(so); - raw_detach(rp); +} + +static void +raw_uclose(struct socket *so) +{ + struct rawcb *rp = sotorawcb(so); + + KASSERT(rp != NULL, ("raw_uabort: rp == NULL")); + raw_disconnect(rp); + soisdisconnected(so); } /* pru_accept is EOPNOTSUPP */ @@ -295,4 +304,5 @@ struct pr_usrreqs raw_usrreqs = { .pru_send = raw_usend, .pru_shutdown = raw_ushutdown, .pru_sockaddr = raw_usockaddr, + .pru_close = raw_uclose, }; -- cgit v1.1