svn commit: r360379 - in head/sys: fs/fifofs kern

Mark Johnston markj at FreeBSD.org
Mon Apr 27 15:59:08 UTC 2020


Author: markj
Date: Mon Apr 27 15:59:07 2020
New Revision: 360379
URL: https://svnweb.freebsd.org/changeset/base/360379

Log:
  Call pipeselwakeup() after toggling PIPE_EOF.
  
  This ensures that pipe_poll() and the pipe kqueue filters observe
  PIPE_EOF and set EV_EOF accordingly.  As a result an extra call to
  knote() after setting PIPE_EOF is unnecessary.
  
  Submitted by:	Jan Kokemüller <jan.kokemueller at gmail.com>
  MFC after:	2 weeks
  Differential Revision:	https://reviews.freebsd.org/D24528

Modified:
  head/sys/fs/fifofs/fifo_vnops.c
  head/sys/kern/sys_pipe.c

Modified: head/sys/fs/fifofs/fifo_vnops.c
==============================================================================
--- head/sys/fs/fifofs/fifo_vnops.c	Mon Apr 27 15:58:55 2020	(r360378)
+++ head/sys/fs/fifofs/fifo_vnops.c	Mon Apr 27 15:59:07 2020	(r360379)
@@ -174,8 +174,10 @@ fifo_open(ap)
 		fip->fi_rgen++;
 		if (fip->fi_readers == 1) {
 			fpipe->pipe_state &= ~PIPE_EOF;
-			if (fip->fi_writers > 0)
+			if (fip->fi_writers > 0) {
 				wakeup(&fip->fi_writers);
+				pipeselwakeup(fpipe);
+			}
 		}
 		fp->f_pipegen = fpipe->pipe_wgen - fip->fi_writers;
 	}
@@ -190,8 +192,10 @@ fifo_open(ap)
 		fip->fi_wgen++;
 		if (fip->fi_writers == 1) {
 			fpipe->pipe_state &= ~PIPE_EOF;
-			if (fip->fi_readers > 0)
+			if (fip->fi_readers > 0) {
 				wakeup(&fip->fi_readers);
+				pipeselwakeup(fpipe);
+			}
 		}
 	}
 	if ((ap->a_mode & O_NONBLOCK) == 0) {
@@ -210,6 +214,7 @@ fifo_open(ap)
 					fpipe->pipe_state |= PIPE_EOF;
 					if (fpipe->pipe_state & PIPE_WANTW)
 						wakeup(fpipe);
+					pipeselwakeup(fpipe);
 					PIPE_UNLOCK(fpipe);
 					fifo_cleanup(vp);
 				}
@@ -238,6 +243,7 @@ fifo_open(ap)
 					if (fpipe->pipe_state & PIPE_WANTR)
 						wakeup(fpipe);
 					fpipe->pipe_wgen++;
+					pipeselwakeup(fpipe);
 					PIPE_UNLOCK(fpipe);
 					fifo_cleanup(vp);
 				}

Modified: head/sys/kern/sys_pipe.c
==============================================================================
--- head/sys/kern/sys_pipe.c	Mon Apr 27 15:58:55 2020	(r360378)
+++ head/sys/kern/sys_pipe.c	Mon Apr 27 15:59:07 2020	(r360379)
@@ -1606,8 +1606,6 @@ pipeclose(struct pipe *cpipe)
 	pipelock(cpipe, 0);
 	pp = cpipe->pipe_pair;
 
-	pipeselwakeup(cpipe);
-
 	/*
 	 * If the other side is blocked, wake it up saying that
 	 * we want to close it down.
@@ -1621,16 +1619,16 @@ pipeclose(struct pipe *cpipe)
 		pipelock(cpipe, 0);
 	}
 
+	pipeselwakeup(cpipe);
+
 	/*
 	 * Disconnect from peer, if any.
 	 */
 	ppipe = cpipe->pipe_peer;
 	if (ppipe->pipe_present == PIPE_ACTIVE) {
-		pipeselwakeup(ppipe);
-
 		ppipe->pipe_state |= PIPE_EOF;
 		wakeup(ppipe);
-		KNOTE_LOCKED(&ppipe->pipe_sel.si_note, 0);
+		pipeselwakeup(ppipe);
 	}
 
 	/*


More information about the svn-src-head mailing list