From: Wayne Davison Date: Sun, 11 Sep 2011 18:07:02 +0000 (-0700) Subject: Fix a potential hang on an empty file list. X-Git-Tag: v3.1.0pre1~85 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=de407c03d2f424829fc1af3db3260286788bd619;p=thirdparty%2Frsync.git Fix a potential hang on an empty file list. Fixes bug 8423. --- diff --git a/io.c b/io.c index 7cb3be13..b4e0a682 100644 --- a/io.c +++ b/io.c @@ -912,6 +912,9 @@ void noop_io_until_death(void) { char buf[1024]; + if (!iobuf.in.buf || !iobuf.out.buf || iobuf.in_fd == -1 || iobuf.out_fd == -1) + return; + kluge_around_eof = 2; /* Setting an I/O timeout ensures that if something inexplicably weird * happens, we won't hang around forever. */ diff --git a/main.c b/main.c index 5a06f177..c5e106c9 100644 --- a/main.c +++ b/main.c @@ -809,8 +809,12 @@ static void do_server_sender(int f_in, int f_out, int argc, char *argv[]) } flist = send_file_list(f_out,argc,argv); - if (!flist || flist->used == 0) + if (!flist || flist->used == 0) { + /* Make sure input buffering is off so we can't hang in noop_io_until_death(). */ + io_end_buffering_in(0); + /* TODO: we should really exit in a more controlled manner. */ exit_cleanup(0); + } io_start_buffering_in(f_in);