(patch) fix for spinning child processes in daemon mode

Colin Walters walters at debian.org
Fri Jan 11 18:32:03 EST 2002


Hello,

The attached patch should fix Debian bug #128632
(http://bugs.debian.org/128632).  This bug happened because if an error
occurred in writefd_unbuffered (such as the remote end closing the
socket), it would call rprintf, which would call io_multiplexing_write,
which would in turn call writefd_unbuffered, which would then just sit
in a loop trying to write to the broken socket.

Also, we have to ignore SIGPIPE; it is better to handle an EPIPE return
code.  Otherwise we end up calling rprintf inside the sigint handler,
and we're back in the same boat.

Does this look right?  The rsync error handling is...complex, to say the
least.

--- io.c.~1.87.~	Sun Sep  9 00:42:09 2001
+++ io.c	Fri Jan 11 02:20:52 2002
@@ -438,6 +438,8 @@
 			}
 
 			if (ret <= 0) {
+				/* Don't try to write errors back across the stream */
+				io_multiplexing_close();
 				rprintf(FERROR,
 					"error writing %d unbuffered bytes"
 					" - exiting: %s\n", len,
Index: main.c
===================================================================
RCS file: /cvsroot/rsync/main.c,v
retrieving revision 1.135
diff -u -u -r1.135 main.c
--- main.c	11 Jan 2002 07:16:11 -0000	1.135
+++ main.c	11 Jan 2002 07:23:18 -0000
@@ -821,9 +821,11 @@
 	}
 
 	signal(SIGINT,SIGNAL_CAST sig_int);
-	signal(SIGPIPE,SIGNAL_CAST sig_int);
 	signal(SIGHUP,SIGNAL_CAST sig_int);
 	signal(SIGTERM,SIGNAL_CAST sig_int);
+
+	/* Ignore SIGPIPE; we check error codes consistently. */
+	signal(SIGPIPE,SIG_IGN);
 
 	/* Initialize push_dir here because on some old systems getcwd
 	   (implemented by forking "pwd" and reading its output) doesn't




More information about the rsync mailing list