From a152f8a36128ce99cc252941396d7db06ec7084e Mon Sep 17 00:00:00 2001 From: Robert Watson 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/netatm/atm_aal5.c | 15 ++++++++++++++- sys/netatm/atm_usrreq.c | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'sys/netatm') diff --git a/sys/netatm/atm_aal5.c b/sys/netatm/atm_aal5.c index f21ad7980b56..a0534b7d0d26 100644 --- a/sys/netatm/atm_aal5.c +++ b/sys/netatm/atm_aal5.c @@ -88,6 +88,7 @@ static int atm_aal5_incoming(void *, Atm_connection *, Atm_attributes *, void **); static void atm_aal5_cpcs_data(void *, KBuffer *); static caddr_t atm_aal5_getname(void *); +static void atm_aal5_close(struct socket *); /* @@ -108,6 +109,7 @@ struct pr_usrreqs atm_aal5_usrreqs = { .pru_sense = atm_aal5_sense, .pru_shutdown = atm_aal5_shutdown, .pru_sockaddr = atm_aal5_sockaddr, + .pru_close = atm_aal5_close, }; /* @@ -565,8 +567,19 @@ atm_aal5_abort(so) { ATM_INTRO_NOERR("abort"); + (void)atm_sock_disconnect(so); so->so_error = ECONNABORTED; - atm_sock_detach(so); + + ATM_OUTRO_NOERR(); +} + +static void +atm_aal5_close(so) + struct socket *so; +{ + ATM_INTRO_NOERR("close"); + + (void)atm_sock_disconnect(so); ATM_OUTRO_NOERR(); } diff --git a/sys/netatm/atm_usrreq.c b/sys/netatm/atm_usrreq.c index 8facb95994bc..ad14e84a366f 100644 --- a/sys/netatm/atm_usrreq.c +++ b/sys/netatm/atm_usrreq.c @@ -79,6 +79,7 @@ struct pr_usrreqs atm_dgram_usrreqs = { .pru_sosend = NULL, .pru_soreceive = NULL, .pru_sopoll = NULL, + .pru_close = atm_proto_notsupp5, }; -- cgit v1.3