Garbage collect fdavail.
It rarely returns an error and fdallocn handles the failure of fdalloc just fine.
This commit is contained in:
parent
905a22bf60
commit
439611d0ad
@ -1650,9 +1650,6 @@ fdallocn(struct thread *td, int minfd, int *fds, int n)
|
|||||||
|
|
||||||
FILEDESC_XLOCK_ASSERT(fdp);
|
FILEDESC_XLOCK_ASSERT(fdp);
|
||||||
|
|
||||||
if (!fdavail(td, n))
|
|
||||||
return (EMFILE);
|
|
||||||
|
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
if (fdalloc(td, 0, &fds[i]) != 0)
|
if (fdalloc(td, 0, &fds[i]) != 0)
|
||||||
break;
|
break;
|
||||||
@ -1666,35 +1663,6 @@ fdallocn(struct thread *td, int minfd, int *fds, int n)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* 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
|
* 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
|
* process that refers to it. We add one reference to the file for the
|
||||||
|
@ -148,7 +148,6 @@ int finstall(struct thread *td, struct file *fp, int *resultfp, int flags,
|
|||||||
struct filecaps *fcaps);
|
struct filecaps *fcaps);
|
||||||
int fdalloc(struct thread *td, int minfd, int *result);
|
int fdalloc(struct thread *td, int minfd, int *result);
|
||||||
int fdallocn(struct thread *td, int minfd, int *fds, int n);
|
int fdallocn(struct thread *td, int minfd, int *fds, int n);
|
||||||
int fdavail(struct thread *td, int n);
|
|
||||||
int fdcheckstd(struct thread *td);
|
int fdcheckstd(struct thread *td);
|
||||||
void fdclose(struct filedesc *fdp, struct file *fp, int idx, struct thread *td);
|
void fdclose(struct filedesc *fdp, struct file *fp, int idx, struct thread *td);
|
||||||
void fdcloseexec(struct thread *td);
|
void fdcloseexec(struct thread *td);
|
||||||
|
Loading…
Reference in New Issue
Block a user