Deleted Added
full compact
uipc_socket.c (157359) uipc_socket.c (157366)
1/*-
2 * Copyright (c) 1982, 1986, 1988, 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 * Copyright (c) 2004 The FreeBSD Foundation
5 * Copyright (c) 2004-2006 Robert N. M. Watson
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 75 unchanged lines hidden (view full) ---

84 * these interfaces are not preferred, and should be avoided.
85 *
86 * XXXRW: The behavior of sockets after soclose() but before the last
87 * sorele() is poorly defined. We can probably entirely eliminate them with
88 * a little work, since consumers are managing references anyway.
89 */
90
91#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1982, 1986, 1988, 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 * Copyright (c) 2004 The FreeBSD Foundation
5 * Copyright (c) 2004-2006 Robert N. M. Watson
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 75 unchanged lines hidden (view full) ---

84 * these interfaces are not preferred, and should be avoided.
85 *
86 * XXXRW: The behavior of sockets after soclose() but before the last
87 * sorele() is poorly defined. We can probably entirely eliminate them with
88 * a little work, since consumers are managing references anyway.
89 */
90
91#include <sys/cdefs.h>
92__FBSDID("$FreeBSD: head/sys/kern/uipc_socket.c 157359 2006-04-01 10:45:52Z rwatson $");
92__FBSDID("$FreeBSD: head/sys/kern/uipc_socket.c 157366 2006-04-01 15:15:05Z rwatson $");
93
94#include "opt_inet.h"
95#include "opt_mac.h"
96#include "opt_zero.h"
97#include "opt_compat.h"
98
99#include <sys/param.h>
100#include <sys/systm.h>

--- 437 unchanged lines hidden (view full) ---

538 SOCK_LOCK(so);
539 KASSERT((so->so_state & SS_NOFDREF) == 0, ("soclose: NOFDREF"));
540 so->so_state |= SS_NOFDREF;
541 sorele(so);
542 return (error);
543}
544
545/*
93
94#include "opt_inet.h"
95#include "opt_mac.h"
96#include "opt_zero.h"
97#include "opt_compat.h"
98
99#include <sys/param.h>
100#include <sys/systm.h>

--- 437 unchanged lines hidden (view full) ---

538 SOCK_LOCK(so);
539 KASSERT((so->so_state & SS_NOFDREF) == 0, ("soclose: NOFDREF"));
540 so->so_state |= SS_NOFDREF;
541 sorele(so);
542 return (error);
543}
544
545/*
546 * soabort() must not be called with any socket locks held, as it calls
547 * into the protocol, which will call back into the socket code causing
548 * it to acquire additional socket locks that may cause recursion or lock
549 * order reversals.
546 * soabort() allows the socket code or protocol code to detach a socket that
547 * has been in an incomplete or completed listen queue, but has not yet been
548 * accepted.
549 *
550 * This interface is tricky, because it is called on an unreferenced socket,
551 * and must be called only by a thread that has actually removed the socket
552 * from the listen queue it was on, or races with other threads are risked.
553 *
554 * This interface will call into the protocol code, so must not be called
555 * with any socket locks held. Protocols do call it while holding their own
556 * recursible protocol mutexes, but this is something that should be subject
557 * to review in the future.
558 *
559 * XXXRW: Why do we maintain a distinction between pru_abort() and
560 * pru_detach()?
550 */
551void
552soabort(so)
553 struct socket *so;
554{
561 */
562void
563soabort(so)
564 struct socket *so;
565{
555 int error;
556
566
557 error = (*so->so_proto->pr_usrreqs->pru_abort)(so);
558 if (error) {
559 ACCEPT_LOCK();
560 SOCK_LOCK(so);
561 sotryfree(so); /* note: does not decrement the ref count */
562 }
567 /*
568 * In as much as is possible, assert that no references to this
569 * socket are held. This is not quite the same as asserting that the
570 * current thread is responsible for arranging for no references, but
571 * is as close as we can get for now.
572 */
573 KASSERT(so->so_count == 0, ("soabort: so_count"));
574 KASSERT(!(so->so_state & SS_PROTOREF), ("soabort: SS_PROTOREF"));
575 KASSERT(so->so_state & SS_NOFDREF, ("soabort: !SS_NOFDREF"));
576
577 (*so->so_proto->pr_usrreqs->pru_abort)(so);
578 ACCEPT_LOCK();
579 SOCK_LOCK(so);
580 sofree(so);
563}
564
565int
566soaccept(so, nam)
567 struct socket *so;
568 struct sockaddr **nam;
569{
570 int error;

--- 1863 unchanged lines hidden ---
581}
582
583int
584soaccept(so, nam)
585 struct socket *so;
586 struct sockaddr **nam;
587{
588 int error;

--- 1863 unchanged lines hidden ---