if we sleep during the copyout, we don't want weird stuff to happen to
our fds.  and in the 99.99% case where you neither sleep nor contend on
the lock, no change.

Index: sys_pipe.c
===================================================================
RCS file: /home/tedu/cvs/src/sys/kern/sys_pipe.c,v
retrieving revision 1.60
diff -u -p -r1.60 sys_pipe.c
--- sys_pipe.c  8 Jul 2011 05:01:27 -0000       1.60
+++ sys_pipe.c  8 Jul 2011 18:04:55 -0000
@@ -144,15 +144,12 @@ sys_pipe(struct proc *p, void *v, regist
        FILE_SET_MATURE(rf);
        FILE_SET_MATURE(wf);
 
-       fdpunlock(fdp);
-
        error = copyout(fds, SCARG(uap, fdp), sizeof(fds));
        if (error != 0) {
-               fdplock(fdp);
                fdrelease(p, fds[0]);
                fdrelease(p, fds[1]);
-               fdpunlock(fdp);
        }
+       fdpunlock(fdp);
        return (error);
 
 free3:

Reply via email to