From owner-svn-src-user@FreeBSD.ORG Tue Dec 11 13:51:06 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B54EE75B; Tue, 11 Dec 2012 13:51:06 +0000 (UTC) (envelope-from andre@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 80B278FC08; Tue, 11 Dec 2012 13:51:06 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qBBDp6GL006769; Tue, 11 Dec 2012 13:51:06 GMT (envelope-from andre@svn.freebsd.org) Received: (from andre@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qBBDp6kg006768; Tue, 11 Dec 2012 13:51:06 GMT (envelope-from andre@svn.freebsd.org) Message-Id: <201212111351.qBBDp6kg006768@svn.freebsd.org> From: Andre Oppermann Date: Tue, 11 Dec 2012 13:51:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r244121 - user/andre/tcp_workqueue/sys/kern X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Dec 2012 13:51:06 -0000 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) {