svn commit: r274023 - head/sys/kern

Konstantin Belousov kib at FreeBSD.org
Mon Nov 3 10:01:57 UTC 2014


Author: kib
Date: Mon Nov  3 10:01:56 2014
New Revision: 274023
URL: https://svnweb.freebsd.org/changeset/base/274023

Log:
  When other end of the pipe closed during the write, but some bytes
  were written, return short write instead of EPIPE.
  
  Update comment.
  
  Discussed with:	bde (long time ago)
  MFC after:	2 weeks

Modified:
  head/sys/kern/sys_pipe.c

Modified: head/sys/kern/sys_pipe.c
==============================================================================
--- head/sys/kern/sys_pipe.c	Mon Nov  3 09:26:39 2014	(r274022)
+++ head/sys/kern/sys_pipe.c	Mon Nov  3 10:01:56 2014	(r274023)
@@ -1296,13 +1296,13 @@ pipe_write(fp, uio, active_cred, flags, 
 	}
 
 	/*
-	 * Don't return EPIPE if I/O was successful
+	 * Don't return EPIPE if any byte was written.
+	 * EINTR and other interrupts are handled by generic I/O layer.
+	 * Do not pretend that I/O succeeded for obvious user error
+	 * like EFAULT.
 	 */
-	if ((wpipe->pipe_buffer.cnt == 0) &&
-	    (uio->uio_resid == 0) &&
-	    (error == EPIPE)) {
+	if (uio->uio_resid != orig_resid && error == EPIPE)
 		error = 0;
-	}
 
 	if (error == 0)
 		vfs_timestamp(&wpipe->pipe_mtime);


More information about the svn-src-head mailing list