summaryrefslogtreecommitdiffstats
path: root/sys/netatalk/ddp_usrreq.c
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2006-07-21 17:11:15 +0000
committerrwatson <rwatson@FreeBSD.org>2006-07-21 17:11:15 +0000
commit720efebbba89f0ed3381913203af601ee17ba25f (patch)
treec584d49beb0289bc5110816075b0f48383df5bfd /sys/netatalk/ddp_usrreq.c
parentec82ec19cb2d1e5f72d91c4479b80a91ec859f6e (diff)
downloadFreeBSD-src-720efebbba89f0ed3381913203af601ee17ba25f.zip
FreeBSD-src-720efebbba89f0ed3381913203af601ee17ba25f.tar.gz
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
Diffstat (limited to 'sys/netatalk/ddp_usrreq.c')
-rw-r--r--sys/netatalk/ddp_usrreq.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/sys/netatalk/ddp_usrreq.c b/sys/netatalk/ddp_usrreq.c
index 1421c8d..1876856 100644
--- a/sys/netatalk/ddp_usrreq.c
+++ b/sys/netatalk/ddp_usrreq.c
@@ -202,6 +202,10 @@ out:
return (error);
}
+/*
+ * XXXRW: This is never called because we only invoke abort on stream
+ * protocols.
+ */
static void
ddp_abort(struct socket *so)
{
@@ -210,10 +214,22 @@ ddp_abort(struct socket *so)
ddp = sotoddpcb(so);
KASSERT(ddp != NULL, ("ddp_abort: ddp == NULL"));
- DDP_LIST_XLOCK();
DDP_LOCK(ddp);
- at_pcbdetach(so, ddp);
- DDP_LIST_XUNLOCK();
+ at_pcbdisconnect(ddp);
+ DDP_UNLOCK(ddp);
+}
+
+static void
+ddp_close(struct socket *so)
+{
+ struct ddpcb *ddp;
+
+ ddp = sotoddpcb(so);
+ KASSERT(ddp != NULL, ("ddp_close: ddp == NULL"));
+
+ DDP_LOCK(ddp);
+ at_pcbdisconnect(ddp);
+ DDP_UNLOCK(ddp);
}
void
@@ -276,4 +292,5 @@ struct pr_usrreqs ddp_usrreqs = {
.pru_send = ddp_send,
.pru_shutdown = ddp_shutdown,
.pru_sockaddr = at_setsockaddr,
+ .pru_close = ddp_close,
};
OpenPOWER on IntegriCloud