rsync-2.5.5 memory eater problem

Dave Dykstra dwd at drdykstra.us
Thu Jan 16 20:11:06 EST 2003


Thanks for the reminder.  I checked in the second version.

- Dave

On Wed, Oct 09, 2002 at 12:45:03PM +0300, Sviatoslav Sviridov wrote:
> On Wed, 9 Oct 2002 10:03:33 +0200 (CEST)
> Ruediger Oertel <ro at suse.de> wrote:
> 
> > Hi,
> > 
> > we ran into a little problem with rsync-2.5.5.
> > 
> > Setup: you run rsync-2.5.5 as normal rsync over ssh
> > (ie. not connecting to a rsync server). If you start
> > such a rsync but interrupt the pulling process with Ctrl-C,
> > the process on the other side may start to allocate all
> > memory on the remote machine.
> > 
> > As fa as we have analyzed the problem, the remote rsync
> > process wants to issue a error message that it could not
> > write 4096 bytes, receives a SIGPIPE and errno is set to EPIPE
> > in the fwrite call (line 279 in log.c). Then exit_cleanup is called
> > which in turn will call the same routine again and will of course
> > get EPIPE again and the loop continues (as long as we have memory
> > to recursivly call the same functions again and again).
> > 
> > As a quick workaround we have the following patch, since there is
> > no real point in trying to issue an error message if you have
> > already received EPIPE on write.
> > 
> > --- log.c
> > +++ log.c	2002/10/08 11:55:52
> > @@ -276,7 +276,7 @@
> > 
> >  	if (!f) exit_cleanup(RERR_MESSAGEIO);
> > 
> > -	if (fwrite(buf, len, 1, f) != 1) exit_cleanup(RERR_MESSAGEIO);
> > +	if (fwrite(buf, len, 1, f) != 1 && errno != EPIPE)
> > exit_cleanup(RERR_MESSAGEIO);
> > 
> >  	if (buf[len-1] == '\r' || buf[len-1] == '\n') fflush(f);
> >  }
> > 
> 
> I've had the same problem, but in different situation: when rsync was started
> as piped child (I did it in "rsync" method for apt). My fist path was above 
> one, but later I've found that problem is in exit_cleanup(). I use this patch:
> 
> --- rsync-2.5.5/cleanup.c	2002-03-27 02:03:13 +0100
> +++ rsync-2.5.5.cleanup/cleanup.c	2002-07-11 12:53:52 +0200
> @@ -43,6 +43,11 @@
>  	int ocode = code;
>  	extern int keep_partial;
>  	extern int log_got_error;
> +	static int inside_cleanup = 0;
> +
> +	if (inside_cleanup != 0)
> +		return;
> +	inside_cleanup = 1;
>  
>  	signal(SIGUSR1, SIG_IGN);
>  	signal(SIGUSR2, SIG_IGN);
> 
> 
> -- 
> Sviatoslav Sviridov
> [mailto:svd at lintec.minsk.by] [ICQ#10845380] [Lintec Project] [MLUG]



More information about the rsync mailing list