svn commit: r212822 - in head/sys: kern sys

Robert Watson rwatson at FreeBSD.org
Sat Sep 18 11:18:42 UTC 2010


Author: rwatson
Date: Sat Sep 18 11:18:42 2010
New Revision: 212822
URL: http://svn.freebsd.org/changeset/base/212822

Log:
  With reworking of the socket life cycle in 7.x, the need for a "sotryfree()"
  was eliminated: all references to sockets are explicitly managed by sorele()
  and the protocols.  As such, garbage collect sotryfree(), and update
  sofree() comments to make the new world order more clear.
  
  MFC after:	3 days
  Reported by:	Anuranjan Shukla <anshukla at juniper dot net>

Modified:
  head/sys/kern/uipc_socket.c
  head/sys/sys/socketvar.h

Modified: head/sys/kern/uipc_socket.c
==============================================================================
--- head/sys/kern/uipc_socket.c	Sat Sep 18 11:16:43 2010	(r212821)
+++ head/sys/kern/uipc_socket.c	Sat Sep 18 11:18:42 2010	(r212822)
@@ -559,9 +559,12 @@ solisten_proto(struct socket *so, int ba
 }
 
 /*
- * Attempt to free a socket.  This should really be sotryfree().
+ * Evaluate the reference count and named references on a socket; if no
+ * references remain, free it.  This should be called whenever a reference is
+ * released, such as in sorele(), but also when named reference flags are
+ * cleared in socket or protocol code.
  *
- * sofree() will succeed if:
+ * sofree() will free the socket if:
  *
  * - There are no outstanding file descriptor references or related consumers
  *   (so_count == 0).
@@ -574,9 +577,6 @@ solisten_proto(struct socket *so, int ba
  * - The socket is not in a completed connection queue, so a process has been
  *   notified that it is present.  If it is removed, the user process may
  *   block in accept() despite select() saying the socket was ready.
- *
- * Otherwise, it will quietly abort so that a future call to sofree(), when
- * conditions are right, can succeed.
  */
 void
 sofree(struct socket *so)

Modified: head/sys/sys/socketvar.h
==============================================================================
--- head/sys/sys/socketvar.h	Sat Sep 18 11:16:43 2010	(r212821)
+++ head/sys/sys/socketvar.h	Sat Sep 18 11:18:42 2010	(r212822)
@@ -234,17 +234,6 @@ struct xsocket {
 	}								\
 } while (0)
 
-#define	sotryfree(so) do {						\
-	ACCEPT_LOCK_ASSERT();						\
-	SOCK_LOCK_ASSERT(so);						\
-	if ((so)->so_count == 0)					\
-		sofree(so);						\
-	else {								\
-		SOCK_UNLOCK(so);					\
-		ACCEPT_UNLOCK();					\
-	}								\
-} while(0)
-
 /*
  * In sorwakeup() and sowwakeup(), acquire the socket buffer lock to
  * avoid a non-atomic test-and-wakeup.  However, sowakeup is


More information about the svn-src-all mailing list