Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern A loop to expand file descriptor table and retry is...



details:   https://anonhg.NetBSD.org/src/rev/44417d22f09f
branches:  trunk
changeset: 526206:44417d22f09f
user:      enami <enami%NetBSD.org@localhost>
date:      Sat Apr 27 21:36:50 2002 +0000

description:
A loop to expand file descriptor table and retry is move from fdalloc()
to caller.  So, no longer need to loop in fdalloc().

diffstat:

 sys/kern/kern_descrip.c |  38 ++++++++++++++++++--------------------
 1 files changed, 18 insertions(+), 20 deletions(-)

diffs (62 lines):

diff -r ada32d6f3033 -r 44417d22f09f sys/kern/kern_descrip.c
--- a/sys/kern/kern_descrip.c   Sat Apr 27 21:31:41 2002 +0000
+++ b/sys/kern/kern_descrip.c   Sat Apr 27 21:36:50 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_descrip.c,v 1.89 2002/04/27 21:31:41 enami Exp $  */
+/*     $NetBSD: kern_descrip.c,v 1.90 2002/04/27 21:36:50 enami Exp $  */
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1991, 1993
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.89 2002/04/27 21:31:41 enami Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.90 2002/04/27 21:36:50 enami Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -613,27 +613,25 @@
         * expanding the ofile array.
         */
        lim = min((int)p->p_rlimit[RLIMIT_NOFILE].rlim_cur, maxfiles);
-       for (;;) {
-               last = min(fdp->fd_nfiles, lim);
-               if ((i = want) < fdp->fd_freefile)
-                       i = fdp->fd_freefile;
-               for (; i < last; i++) {
-                       if (fdp->fd_ofiles[i] == NULL) {
-                               fd_used(fdp, i);
-                               if (want <= fdp->fd_freefile)
-                                       fdp->fd_freefile = i;
-                               *result = i;
-                               return (0);
-                       }
+       last = min(fdp->fd_nfiles, lim);
+       if ((i = want) < fdp->fd_freefile)
+               i = fdp->fd_freefile;
+       for (; i < last; i++) {
+               if (fdp->fd_ofiles[i] == NULL) {
+                       fd_used(fdp, i);
+                       if (want <= fdp->fd_freefile)
+                               fdp->fd_freefile = i;
+                       *result = i;
+                       return (0);
                }
+       }
 
-               /* No space in current array.  Expand? */
-               if (fdp->fd_nfiles >= lim)
-                       return (EMFILE);
+       /* No space in current array.  Expand? */
+       if (fdp->fd_nfiles >= lim)
+               return (EMFILE);
 
-               /* Let the caller do it. */
-               return (ENOSPC);
-       }
+       /* Let the caller do it. */
+       return (ENOSPC);
 }
 
 void



Home | Main Index | Thread Index | Old Index