svn commit: r264104 - in head/sys: kern sys
Mateusz Guzik
mjg at FreeBSD.org
Fri Apr 4 05:07:37 UTC 2014
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);
More information about the svn-src-all
mailing list