Module Name: src
Committed By: dsl
Date: Sun Dec 13 18:27:02 UTC 2009
Modified Files:
src/sys/kern: sys_pipe.c
src/sys/sys: pipe.h
Log Message:
Revert most of the previous change.
Only one fd needs clobbering, not all fds that reference the pipe.
This may be what ad@ realised when he tried to add the same code to
sockets. Unfixes part of PR/26567.
To generate a diff of this commit:
cvs rdiff -u -r1.123 -r1.124 src/sys/kern/sys_pipe.c
cvs rdiff -u -r1.30 -r1.31 src/sys/sys/pipe.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/kern/sys_pipe.c
diff -u src/sys/kern/sys_pipe.c:1.123 src/sys/kern/sys_pipe.c:1.124
--- src/sys/kern/sys_pipe.c:1.123 Sat Dec 12 21:28:04 2009
+++ src/sys/kern/sys_pipe.c Sun Dec 13 18:27:02 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_pipe.c,v 1.123 2009/12/12 21:28:04 dsl Exp $ */
+/* $NetBSD: sys_pipe.c,v 1.124 2009/12/13 18:27:02 dsl Exp $ */
/*-
* Copyright (c) 2003, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.123 2009/12/12 21:28:04 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.124 2009/12/13 18:27:02 dsl Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -542,12 +542,8 @@
* Detect EOF condition.
* Read returns 0 on EOF, no need to set error.
*/
- if (rpipe->pipe_state & (PIPE_EOF | PIPE_ABORTED)) {
- if (rpipe->pipe_state & PIPE_ABORTED)
- /* Another thread has called close() */
- error = EBADF;
+ if (rpipe->pipe_state & PIPE_EOF)
break;
- }
/*
* Don't block on non-blocking I/O.
@@ -984,13 +980,6 @@
break;
}
- if (wpipe->pipe_state & PIPE_ABORTED) {
- /* Another thread has called close() */
- if (uio->uio_resid == 0)
- error = EBADF;
- break;
- }
-
/*
* We have no more space and have something to offer,
* wake up select/poll.
@@ -1220,9 +1209,14 @@
{
struct pipe *pipe = fp->f_data;
- /* Unblock blocked reads/writes - they will return EBADF. */
+ /*
+ * Unblock blocked reads/writes in order to allow close() to complete.
+ * This isn't going to work yet!
+ * The underlying problem is that only the 'fd' in question needs
+ * its operations terminating, the pipe itself my be open via
+ * other fd.
+ */
mutex_enter(pipe->pipe_lock);
- pipe->pipe_state |= PIPE_ABORTED;
cv_broadcast(&pipe->pipe_rcv);
cv_broadcast(&pipe->pipe_wcv);
mutex_exit(pipe->pipe_lock);
Index: src/sys/sys/pipe.h
diff -u src/sys/sys/pipe.h:1.30 src/sys/sys/pipe.h:1.31
--- src/sys/sys/pipe.h:1.30 Sat Dec 12 21:28:04 2009
+++ src/sys/sys/pipe.h Sun Dec 13 18:27:02 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: pipe.h,v 1.30 2009/12/12 21:28:04 dsl Exp $ */
+/* $NetBSD: pipe.h,v 1.31 2009/12/13 18:27:02 dsl Exp $ */
/*
* Copyright (c) 1996 John S. Dyson
@@ -96,7 +96,6 @@
pointers/data. */
#define PIPE_LWANT 0x200 /* Process wants exclusive access to
pointers/data. */
-#define PIPE_ABORTED 0x400 /* fo_abort()ed, unblock read/write */
/*
* Per-pipe data structure.