Bug 8423 - Listing a non-existent remote directory hangs
Listing a non-existent remote directory hangs
Status: RESOLVED FIXED
Product: rsync
Classification: Unclassified
Component: core
3.1.0
All All
: P5 normal
: ---
Assigned To: Wayne Davison
Rsync QA Contact
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-08-30 04:01 UTC by Chris Dunlop
Modified: 2011-09-11 18:15 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dunlop 2011-08-30 04:01:44 UTC
Listing a non-existent remote directory causes rsync to "hang" (it's
not really hung, it's very busy doing nothing...).

Current git (5561c14).

Listing non-existent file fails as expected:

   local$ ./rsync-3.1.0dev-5561c14-x64 --rsync-path=/tmp/rsync-3.1.0dev-5561c14-x64 remote:/tmp/foo
   rsync: link_stat "/tmp/foo" failed: No such file or directory (2)
   rsync error: some files/attrs were not transferred (see previous errors) (code 23) at ../rsync/main.c(1635) [Receiver=3.1.0dev-5561c14]
   rsync: [Receiver] write error: Broken pipe (32)
   local$

Listing non-existent directory doesn't return:

   local$ ./rsync-3.1.0dev-5561c14-x64 --rsync-path=/tmp/rsync-3.1.0dev-5561c14-x64 remote:/tmp/foo/
   rsync: change_dir "/tmp/foo" failed: No such file or directory (2)

Strace of local side:

   local$ strace -p ${pid}
   select(0, NULL, NULL, NULL, {0, 20000}) = 0 (Timeout)
   wait4(20466, 0x7fffe3bd3f7c, WNOHANG, NULL) = 0
   select(0, NULL, NULL, NULL, {0, 20000}) = 0 (Timeout)
   wait4(20466, 0x7fffe3bd3f7c, WNOHANG, NULL) = 0
   select(0, NULL, NULL, NULL, {0, 20000}) = 0 (Timeout)
   wait4(20466, 0x7fffe3bd3f7c, WNOHANG, NULL) = 0
   select(0, NULL, NULL, NULL, {0, 20000}) = 0 (Timeout)
   wait4(20466, 0x7fffe3bd3f7c, WNOHANG, NULL) = 0
   select(0, NULL, NULL, NULL, {0, 20000}) = 0 (Timeout)
   wait4(20466, 0x7fffe3bd3f7c, WNOHANG, NULL) = 0
   select(0, NULL, NULL, NULL, {0, 20000}) = 0 (Timeout)
   wait4(20466, 0x7fffe3bd3f7c, WNOHANG, NULL) = 0
   select(0, NULL, NULL, NULL, {0, 20000}) = 0 (Timeout)
   wait4(20466, 0x7fffe3bd3f7c, WNOHANG, NULL) = 0
   select(0, NULL, NULL, NULL, {0, 20000}) = 0 (Timeout)
   wait4(20466, 0x7fffe3bd3f7c, WNOHANG, NULL) = 0
   [...continues very quicky]

Strace of remote side:

   remote$ strace -p ${pid}
   Process 8398 attached - interrupt to quit
   select(1, [0], [], [0], {11, 434460})   = 0 (Timeout)
   select(2, [0], [1], [0], {30, 0})       = 1 (out [1], left {29, 999997})
   write(1, "\0\0\0\7", 4)                 = 4
   select(1, [0], [], [0], {30, 0} (Timeout)
   select(2, [0], [1], [0], {30, 0})       = 1 (out [1], left {29, 999997})
   write(1, "\0\0\0\7", 4)                 = 4
   select(1, [0], [], [0], {30, 0}
   [...continues slowly]
Comment 1 Wayne Davison 2011-09-11 18:15:55 UTC
In the case where the chdir failed, rsync was setting an I/O error prior to aborting (due to an empty file list), and that would trigger an attempt to stick around waiting for a clean exit, even though it hadn't output enough protocol data to tell the remote side everything was done.

I have changed the code to force this premature exit to exit w/o delay.  I should probably revisit this empty-flist abnormal exit sequence in order to make the protocol behave more cleanly, but this fix is good enough for now.

Thanks for the report!