From 1fc953c5e2322e088d3333e32ee74fde57924d7a Mon Sep 17 00:00:00 2001 From: yamt Date: Sun, 9 Nov 2003 07:52:26 +0000 Subject: [PATCH] in the non-overwritten case of sys_dup2(), call fd_used() by itsself rather than leaving it to finishdup(). --- sys/kern/kern_descrip.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 5a05fc39dc89..fb6b35769f54 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_descrip.c,v 1.116 2003/11/01 18:47:16 provos Exp $ */ +/* $NetBSD: kern_descrip.c,v 1.117 2003/11/09 07:52:26 yamt Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1991, 1993 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.116 2003/11/01 18:47:16 provos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.117 2003/11/09 07:52:26 yamt Exp $"); #include #include @@ -302,6 +302,11 @@ sys_dup2(struct lwp *l, void *v, register_t *retval) } if (new != i) panic("dup2: fdalloc"); + } else if (fdp->fd_ofiles[new] == NULL) { + /* + * Mark `new' slot "used" only if it was empty. + */ + fd_used(fdp, new); } /* @@ -520,6 +525,7 @@ finishdup(struct proc *p, int old, int new, register_t *retval) * the file may block. * * Note: `old' is already used for us. + * Note: Caller already marked `new' slot "used". */ delfp = fdp->fd_ofiles[new]; @@ -527,12 +533,6 @@ finishdup(struct proc *p, int old, int new, register_t *retval) fdp->fd_ofiles[new] = fp; fdp->fd_ofileflags[new] = fdp->fd_ofileflags[old] &~ UF_EXCLOSE; fp->f_count++; - /* - * Note, don't have to mark it "used" in the table if there - * was already a file in the `new' slot. - */ - if (delfp == NULL) - fd_used(fdp, new); *retval = new; FILE_UNUSE(fp, p);