summaryrefslogtreecommitdiffstats
path: root/sys/net
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/net
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/net')
-rw-r--r--sys/net/raw_usrreq.c12
-rw-r--r--sys/net/rtsock.c8
2 files changed, 19 insertions, 1 deletions
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,
};
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index 76913a5..8ab39e4 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -144,6 +144,13 @@ rts_abort(struct socket *so)
raw_usrreqs.pru_abort(so);
}
+static void
+rts_close(struct socket *so)
+{
+
+ raw_usrreqs.pru_close(so);
+}
+
/* pru_accept is EOPNOTSUPP */
static int
@@ -292,6 +299,7 @@ static struct pr_usrreqs route_usrreqs = {
.pru_send = rts_send,
.pru_shutdown = rts_shutdown,
.pru_sockaddr = rts_sockaddr,
+ .pru_close = rts_close,
};
/*ARGSUSED*/
OpenPOWER on IntegriCloud