From 5479e5d69217e0a6876338fc7cde604067b679ca Mon Sep 17 00:00:00 2001 From: rwatson Date: Sat, 1 Apr 2006 15:42:02 +0000 Subject: Chance protocol switch method pru_detach() so that it returns void rather than an error. Detaches do not "fail", they other occur or the protocol flags SS_PROTOREF to take ownership of the socket. soclose() no longer looks at so_pcb to see if it's NULL, relying entirely on the protocol to decide whether it's time to free the socket or not using SS_PROTOREF. so_pcb is now entirely owned and managed by the protocol code. Likewise, no longer test so_pcb in other socket functions, such as soreceive(), which have no business digging into protocol internals. Protocol detach routines no longer try to free the socket on detach, this is performed in the socket code if the protocol permits it. In rts_detach(), no longer test for rp != NULL in detach, and likewise in other protocols that don't permit a NULL so_pcb, reduce the incidence of testing for it during detach. netinet and netinet6 are not fully updated to this change, which will be in an upcoming commit. In their current state they may leak memory or panic. MFC after: 3 months --- sys/net/raw_cb.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'sys/net/raw_cb.c') diff --git a/sys/net/raw_cb.c b/sys/net/raw_cb.c index 31566d1..f45be72 100644 --- a/sys/net/raw_cb.c +++ b/sys/net/raw_cb.c @@ -98,10 +98,9 @@ raw_detach(rp) { struct socket *so = rp->rcb_socket; - ACCEPT_LOCK(); - SOCK_LOCK(so); - so->so_pcb = 0; - sotryfree(so); + KASSERT(so->so_pcb == rp, ("raw_detach: so_pcb != rp")); + + so->so_pcb = NULL; mtx_lock(&rawcb_mtx); LIST_REMOVE(rp, list); mtx_unlock(&rawcb_mtx); -- cgit v1.1