[Midnightbsd-cvs] src: sys_pipe.c: Fix from FreeBSD: The kernel uses two ways to write

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sun Nov 25 13:05:17 EST 2007


Log Message:
-----------
Fix from FreeBSD:

 The kernel uses two ways to write data on a pipe:
      o  buffered write, for chunks smaller than PIPE_MINDIRECT bytes
      o  direct write, for everything else

  A call to writev(2) may receive struct iov of various size and the
  kernel may have to switch from one solution to the other. Before doing
  this, it must wake reader processes and any select/poll/kqueue up.

  This commit fixes a bug where select/poll/kqueue are not triggered
  when switching from buffered write to direct write. It adds calls to
  pipeselwakeup().

Modified Files:
--------------
    src/sys/kern:
        sys_pipe.c (r1.1.1.2 -> r1.2)

-------------- next part --------------
Index: sys_pipe.c
===================================================================
RCS file: /home/cvs/src/sys/kern/sys_pipe.c,v
retrieving revision 1.1.1.2
retrieving revision 1.2
diff -L sys/kern/sys_pipe.c -L sys/kern/sys_pipe.c -u -r1.1.1.2 -r1.2
--- sys/kern/sys_pipe.c
+++ sys/kern/sys_pipe.c
@@ -897,6 +897,7 @@
 	while (wpipe->pipe_state & PIPE_DIRECTW) {
 		if (wpipe->pipe_state & PIPE_WANTR) {
 			wpipe->pipe_state &= ~PIPE_WANTR;
+			pipeselwakeup(wpipe);
 			wakeup(wpipe);
 		}
 		wpipe->pipe_state |= PIPE_WANTW;
@@ -912,6 +913,7 @@
 	if (wpipe->pipe_buffer.cnt > 0) {
 		if (wpipe->pipe_state & PIPE_WANTR) {
 			wpipe->pipe_state &= ~PIPE_WANTR;
+			pipeselwakeup(wpipe);
 			wakeup(wpipe);
 		}
 		wpipe->pipe_state |= PIPE_WANTW;
@@ -1096,6 +1098,7 @@
 		if (wpipe->pipe_state & PIPE_DIRECTW) {
 			if (wpipe->pipe_state & PIPE_WANTR) {
 				wpipe->pipe_state &= ~PIPE_WANTR;
+				pipeselwakeup(wpipe);
 				wakeup(wpipe);
 			}
 			pipeunlock(wpipe);


More information about the Midnightbsd-cvs mailing list