changeset 2566:045f20e1c3af

[xemacs-hg @ 2005-02-04 04:06:23 by james] Thanks to David Evers, the dreaded email truncation bug should now be gone. See the xemacs-patches message with ID <ps3bwdnf8i.fsf@diannao.ittc.ku.edu>.
author james
date Fri, 04 Feb 2005 04:06:34 +0000
parents 744de5f3f284
children bbc3231c4812
files src/ChangeLog src/process-unix.c
diffstat 2 files changed, 33 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Fri Feb 04 03:57:34 2005 +0000
+++ b/src/ChangeLog	Fri Feb 04 04:06:34 2005 +0000
@@ -1,3 +1,8 @@
+2005-02-03  David Evers  <extsw@appliedgenerics.com>
+
+	* process-unix.c (unix_send_process): Flush the last chunk, even
+	when the pipe is blocked.
+
 2005-02-03  Ben Wing  <ben@xemacs.org>
 
 	* dumper.c:
--- a/src/process-unix.c	Fri Feb 04 03:57:34 2005 +0000
+++ b/src/process-unix.c	Fri Feb 04 04:06:34 2005 +0000
@@ -1511,30 +1511,38 @@
       Ibyte chunkbuf[512];
       Bytecount chunklen;
 
-      while (1)
+      do
 	{
 	  int writeret;
 
 	  chunklen = Lstream_read (lstream, chunkbuf, 512);
-	  if (chunklen <= 0)
-	    break; /* perhaps should ABORT() if < 0?
-		      This should never happen. */
 	  old_sigpipe =
 	    (SIGTYPE (*) (int)) EMACS_SIGNAL (SIGPIPE, send_process_trap);
-	  /* Lstream_write() will never successfully write less than
-	     the amount sent in.  In the worst case, it just buffers
-	     the unwritten data. */
-	  writeret = Lstream_write (XLSTREAM (DATA_OUTSTREAM (p)), chunkbuf,
-				    chunklen);
-	  {
-	    int save_errno = errno;
-	    EMACS_SIGNAL (SIGPIPE, old_sigpipe);
-	    errno = save_errno;
-	    if (writeret < 0)
-	      /* This is a real error.  Blocking errors are handled
-		 specially inside of the filedesc stream. */
-	      report_process_error ("writing to process", proc);
-	  }
+	  if (chunklen > 0)
+	    {
+	      int save_errno;
+
+	      /* Lstream_write() will never successfully write less than
+		 the amount sent in.  In the worst case, it just buffers
+		 the unwritten data. */
+	      writeret = Lstream_write (XLSTREAM (DATA_OUTSTREAM(p)), chunkbuf,
+					chunklen);
+	      save_errno = errno;
+	      EMACS_SIGNAL (SIGPIPE, old_sigpipe);
+	      errno = save_errno;
+	      if (writeret < 0)
+		/* This is a real error.  Blocking errors are handled
+		   specially inside of the filedesc stream. */
+		report_file_error ("writing to process", list1 (proc));
+	    }
+	  else
+	    {
+	      /* Need to make sure that everything up to and including the
+		 last chunk is flushed, even when the pipe is currently
+		 blocked. */
+	      Lstream_flush (XLSTREAM (DATA_OUTSTREAM(p)));
+	      EMACS_SIGNAL (SIGPIPE, old_sigpipe);
+	    }
 	  while (Lstream_was_blocked_p (XLSTREAM (p->pipe_outstream)))
 	    {
 	      /* Buffer is full.  Wait, accepting input;
@@ -1549,7 +1557,9 @@
 	      Lstream_flush (XLSTREAM (p->pipe_outstream));
 	      EMACS_SIGNAL (SIGPIPE, old_sigpipe);
 	    }
+	  /* Perhaps should ABORT() if < 0?  This should never happen. */
 	}
+      while (chunklen > 0);
     }
   else
     { /* We got here from a longjmp() from the SIGPIPE handler */