On pipe reads, check for EOF before FNONBLOCK to avoid spurious EAGAIN errors.

This commit is contained in:
pk 2003-02-14 13:16:44 +00:00
parent e077f7a7d9
commit d2b7e43b18
1 changed files with 11 additions and 10 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: sys_pipe.c,v 1.35 2003/02/12 21:54:16 pk Exp $ */ /* $NetBSD: sys_pipe.c,v 1.36 2003/02/14 13:16:44 pk Exp $ */
/*- /*-
* Copyright (c) 2003 The NetBSD Foundation, Inc. * Copyright (c) 2003 The NetBSD Foundation, Inc.
@ -83,7 +83,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.35 2003/02/12 21:54:16 pk Exp $"); __KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.36 2003/02/14 13:16:44 pk Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -490,14 +490,6 @@ again:
if (nread > 0) if (nread > 0)
break; break;
/*
* don't block on non-blocking I/O
*/
if (fp->f_flag & FNONBLOCK) {
error = EAGAIN;
break;
}
PIPE_LOCK(rpipe); PIPE_LOCK(rpipe);
/* /*
@ -509,6 +501,15 @@ again:
break; break;
} }
/*
* don't block on non-blocking I/O
*/
if (fp->f_flag & FNONBLOCK) {
PIPE_UNLOCK(rpipe);
error = EAGAIN;
break;
}
/* /*
* Unlock the pipe buffer for our remaining processing. * Unlock the pipe buffer for our remaining processing.
* We will either break out with an error or we will * We will either break out with an error or we will