From owner-svn-src-head@FreeBSD.ORG Fri Apr 4 05:07:37 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id F3D78976; Fri, 4 Apr 2014 05:07:36 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C748AB0B; Fri, 4 Apr 2014 05:07:36 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s3457aVd093025; Fri, 4 Apr 2014 05:07:36 GMT (envelope-from mjg@svn.freebsd.org) Received: (from mjg@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s3457a3G093022; Fri, 4 Apr 2014 05:07:36 GMT (envelope-from mjg@svn.freebsd.org) Message-Id: <201404040507.s3457a3G093022@svn.freebsd.org> From: Mateusz Guzik Date: Fri, 4 Apr 2014 05:07:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r264104 - in head/sys: kern sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Apr 2014 05:07:37 -0000 Author: mjg Date: Fri Apr 4 05:07:36 2014 New Revision: 264104 URL: http://svnweb.freebsd.org/changeset/base/264104 Log: Garbage collect fdavail. It rarely returns an error and fdallocn handles the failure of fdalloc just fine. Modified: head/sys/kern/kern_descrip.c head/sys/sys/filedesc.h Modified: head/sys/kern/kern_descrip.c ============================================================================== --- head/sys/kern/kern_descrip.c Fri Apr 4 05:05:43 2014 (r264103) +++ head/sys/kern/kern_descrip.c Fri Apr 4 05:07:36 2014 (r264104) @@ -1650,9 +1650,6 @@ fdallocn(struct thread *td, int minfd, i FILEDESC_XLOCK_ASSERT(fdp); - if (!fdavail(td, n)) - return (EMFILE); - for (i = 0; i < n; i++) if (fdalloc(td, 0, &fds[i]) != 0) break; @@ -1667,35 +1664,6 @@ fdallocn(struct thread *td, int minfd, i } /* - * Check to see whether n user file descriptors are available to the process - * p. - */ -int -fdavail(struct thread *td, int n) -{ - struct proc *p = td->td_proc; - struct filedesc *fdp = td->td_proc->p_fd; - int i, lim, last; - - FILEDESC_LOCK_ASSERT(fdp); - - /* - * XXX: This is only called from uipc_usrreq.c:unp_externalize(); - * call racct_add() from there instead of dealing with containers - * here. - */ - lim = getmaxfd(p); - if ((i = lim - fdp->fd_nfiles) > 0 && (n -= i) <= 0) - return (1); - last = min(fdp->fd_nfiles, lim); - for (i = fdp->fd_freefile; i < last; i++) { - if (fdp->fd_ofiles[i].fde_file == NULL && --n <= 0) - return (1); - } - return (0); -} - -/* * Create a new open file structure and allocate a file decriptor for the * process that refers to it. We add one reference to the file for the * descriptor table and one reference for resultfp. This is to prevent us Modified: head/sys/sys/filedesc.h ============================================================================== --- head/sys/sys/filedesc.h Fri Apr 4 05:05:43 2014 (r264103) +++ head/sys/sys/filedesc.h Fri Apr 4 05:07:36 2014 (r264104) @@ -148,7 +148,6 @@ int finstall(struct thread *td, struct f struct filecaps *fcaps); int fdalloc(struct thread *td, int minfd, int *result); int fdallocn(struct thread *td, int minfd, int *fds, int n); -int fdavail(struct thread *td, int n); int fdcheckstd(struct thread *td); void fdclose(struct filedesc *fdp, struct file *fp, int idx, struct thread *td); void fdcloseexec(struct thread *td);