You broke my patch I submitted in 2003(?). Now in copy_file() with fsync.diff, rsync first does close(ofd) and then fsync(ofd). fsync should be done first. The other (more common) fsync call in receive_data() is OK.
In case fsync(ofd) fails, close(ofd) is not called. It should do (void)close(ofd) just before "return -1".
Thanks. I've checked in these changes.