[PATCH] Batch-mode rewrite

Chris Shoemaker c.shoemaker at cox.net
Mon Jul 12 22:35:30 GMT 2004

	A couple more thoughts:

On Mon, Jul 12, 2004 at 12:34:38PM -0700, Wayne Davison wrote:
> First, a summary of my thoughts:
> One thought here:  would it make things simpler to separate the option-
> parsing variables (read_batch & write_batch) from a set of variables
> that would indicate that the mode is currently active (for instance,
> "read_batch_enabled" and "write_batch_enabled")?  This might allow you
> to remove the hack from start_inband_exchange() IFF the recording of the
> protocol can be turned on at a single common point (perhaps with an
> exception to write out the version number).  I didn't look to see how
> much starting and stopped is needed, though, so this idea may not be of
> any use.

I followed this suggestion and it worked.  Then I followed your
suggestion below about write_batch_monitor_{in|out}.  I think the latter
covers all the bases, removing the need for a "batch_enabled" flag,
since the "if (fd==write_batch_monitor{in|out})" check is happening

> I'm thinking these checks might be safer if some init code did this:
> int write_batch_monitor_in = -1;
> int write_batch_monitor_out = -1;
> 	if (write_batch) {
> 		if (am_sender)
> 			write_batch_monitor_out = f_out;
> 		else
> 			write_batch_monitor_in = f_in;
> 	}
> Then the code in readfd() could be "if (fd == write_batch_monitor_in)"
> and the code in writefd() could be "if (fd == write_batch_monitor_out)".
> Thus, the code could never record any I/O to the wrong fd.  For
> instance, a diff in the patches dir makes the receiver read data on
> a pipe from the generator, and we wouldn't want that going into the
> batch file (when the receiver was the one writing the batch file).

I agree that this scheme is better, since it allows selectivity w.r.t.
the particular stream captured.  However, it may not be much "safer".
Afterall, couldn't the forked generator reuse the integer fds for a
different stream.  Therefore, in either case, to be "safe" don't I need
to explicitly disable batch mode for the generator (or any children
whose streams I don't want to capture?)


More information about the rsync mailing list