uipc_socket.c (136373) | uipc_socket.c (136682) |
---|---|
1/* 2 * Copyright (c) 2004 The FreeBSD Foundation 3 * Copyright (c) 2004 Robert Watson 4 * Copyright (c) 1982, 1986, 1988, 1990, 1993 5 * The Regents of the University of California. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 18 unchanged lines hidden (view full) --- 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * SUCH DAMAGE. 30 * 31 * @(#)uipc_socket.c 8.3 (Berkeley) 4/15/94 32 */ 33 34#include <sys/cdefs.h> | 1/* 2 * Copyright (c) 2004 The FreeBSD Foundation 3 * Copyright (c) 2004 Robert Watson 4 * Copyright (c) 1982, 1986, 1988, 1990, 1993 5 * The Regents of the University of California. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 18 unchanged lines hidden (view full) --- 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * SUCH DAMAGE. 30 * 31 * @(#)uipc_socket.c 8.3 (Berkeley) 4/15/94 32 */ 33 34#include <sys/cdefs.h> |
35__FBSDID("$FreeBSD: head/sys/kern/uipc_socket.c 136373 2004-10-11 08:11:26Z rwatson $"); | 35__FBSDID("$FreeBSD: head/sys/kern/uipc_socket.c 136682 2004-10-18 22:19:43Z rwatson $"); |
36 37#include "opt_inet.h" 38#include "opt_mac.h" 39#include "opt_zero.h" 40 41#include <sys/param.h> 42#include <sys/systm.h> 43#include <sys/fcntl.h> --- 178 unchanged lines hidden (view full) --- 222#endif 223 SOCK_LOCK(so); 224 knlist_init(&so->so_rcv.sb_sel.si_note, SOCKBUF_MTX(&so->so_rcv)); 225 knlist_init(&so->so_snd.sb_sel.si_note, SOCKBUF_MTX(&so->so_snd)); 226 soref(so); 227 SOCK_UNLOCK(so); 228 error = (*prp->pr_usrreqs->pru_attach)(so, proto, td); 229 if (error) { | 36 37#include "opt_inet.h" 38#include "opt_mac.h" 39#include "opt_zero.h" 40 41#include <sys/param.h> 42#include <sys/systm.h> 43#include <sys/fcntl.h> --- 178 unchanged lines hidden (view full) --- 222#endif 223 SOCK_LOCK(so); 224 knlist_init(&so->so_rcv.sb_sel.si_note, SOCKBUF_MTX(&so->so_rcv)); 225 knlist_init(&so->so_snd.sb_sel.si_note, SOCKBUF_MTX(&so->so_snd)); 226 soref(so); 227 SOCK_UNLOCK(so); 228 error = (*prp->pr_usrreqs->pru_attach)(so, proto, td); 229 if (error) { |
230 ACCEPT_LOCK(); |
|
230 SOCK_LOCK(so); 231 so->so_state |= SS_NOFDREF; 232 sorele(so); 233 return (error); 234 } 235 *aso = so; 236 return (0); 237} --- 90 unchanged lines hidden (view full) --- 328 * early for this test in order to avoid that race. 329 */ 330void 331sofree(so) 332 struct socket *so; 333{ 334 struct socket *head; 335 | 231 SOCK_LOCK(so); 232 so->so_state |= SS_NOFDREF; 233 sorele(so); 234 return (error); 235 } 236 *aso = so; 237 return (0); 238} --- 90 unchanged lines hidden (view full) --- 329 * early for this test in order to avoid that race. 330 */ 331void 332sofree(so) 333 struct socket *so; 334{ 335 struct socket *head; 336 |
336 SOCK_UNLOCK(so); 337 ACCEPT_LOCK(); 338 SOCK_LOCK(so); | 337 ACCEPT_LOCK_ASSERT(); 338 SOCK_LOCK_ASSERT(so); |
339 340 if (so->so_pcb != NULL || (so->so_state & SS_NOFDREF) == 0 || 341 so->so_count != 0) { 342 SOCK_UNLOCK(so); 343 ACCEPT_UNLOCK(); 344 return; 345 } 346 --- 115 unchanged lines hidden (view full) --- 462 } 463drop: 464 if (so->so_pcb != NULL) { 465 int error2 = (*so->so_proto->pr_usrreqs->pru_detach)(so); 466 if (error == 0) 467 error = error2; 468 } 469discard: | 339 340 if (so->so_pcb != NULL || (so->so_state & SS_NOFDREF) == 0 || 341 so->so_count != 0) { 342 SOCK_UNLOCK(so); 343 ACCEPT_UNLOCK(); 344 return; 345 } 346 --- 115 unchanged lines hidden (view full) --- 462 } 463drop: 464 if (so->so_pcb != NULL) { 465 int error2 = (*so->so_proto->pr_usrreqs->pru_detach)(so); 466 if (error == 0) 467 error = error2; 468 } 469discard: |
470 ACCEPT_LOCK(); |
|
470 SOCK_LOCK(so); 471 KASSERT((so->so_state & SS_NOFDREF) == 0, ("soclose: NOFDREF")); 472 so->so_state |= SS_NOFDREF; 473 sorele(so); 474 return (error); 475} 476 477/* --- 1784 unchanged lines hidden --- | 471 SOCK_LOCK(so); 472 KASSERT((so->so_state & SS_NOFDREF) == 0, ("soclose: NOFDREF")); 473 so->so_state |= SS_NOFDREF; 474 sorele(so); 475 return (error); 476} 477 478/* --- 1784 unchanged lines hidden --- |