Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 11 Dec 2012 13:51:06 +0000 (UTC)
From:      Andre Oppermann <andre@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r244121 - user/andre/tcp_workqueue/sys/kern
Message-ID:  <201212111351.qBBDp6kg006768@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: andre
Date: Tue Dec 11 13:51:05 2012
New Revision: 244121
URL: http://svnweb.freebsd.org/changeset/base/244121

Log:
  Do not return ECONNABORTED on accept() when a connection has
  closed again already if there are more connections waiting.
  Instead loop and return the next from the queue.

Modified:
  user/andre/tcp_workqueue/sys/kern/uipc_syscalls.c

Modified: user/andre/tcp_workqueue/sys/kern/uipc_syscalls.c
==============================================================================
--- user/andre/tcp_workqueue/sys/kern/uipc_syscalls.c	Tue Dec 11 13:03:33 2012	(r244120)
+++ user/andre/tcp_workqueue/sys/kern/uipc_syscalls.c	Tue Dec 11 13:51:05 2012	(r244121)
@@ -344,7 +344,7 @@ kern_accept(struct thread *td, int s, st
 	struct filedesc *fdp;
 	struct file *headfp, *nfp = NULL;
 	struct sockaddr *sa = NULL;
-	int error;
+	int error, more;
 	struct socket *head, *so;
 	int fd;
 	u_int fflag;
@@ -375,6 +375,7 @@ kern_accept(struct thread *td, int s, st
 	error = falloc(td, &nfp, &fd, 0);
 	if (error)
 		goto done;
+again:
 	ACCEPT_LOCK();
 	if ((head->so_state & SS_NBIO) && TAILQ_EMPTY(&head->so_comp)) {
 		ACCEPT_UNLOCK();
@@ -418,6 +419,7 @@ kern_accept(struct thread *td, int s, st
 	so->so_head = NULL;
 
 	SOCK_UNLOCK(so);
+	more = !TAILQ_EMPTY(&head->so_comp);
 	ACCEPT_UNLOCK();
 
 	/* An extra reference on `nfp' has been held for us by falloc(). */
@@ -445,6 +447,18 @@ kern_accept(struct thread *td, int s, st
 		 */
 		if (name)
 			*namelen = 0;
+
+		/*
+		 * If we have more sockets waiting in the accept
+		 * queue try the next one.  No need to return an
+		 * error and do a round-trip to usespace.
+		 */
+		if (more) {
+			SOCK_LOCK(so);
+			soclose(so);
+			goto again;
+		}
+
 		goto noconnection;
 	}
 	if (sa == NULL) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201212111351.qBBDp6kg006768>