diff options
author | Wayne Davison <wayned@samba.org> | 2013-05-26 14:52:50 -0700 |
---|---|---|
committer | Wayne Davison <wayned@samba.org> | 2013-05-26 16:22:56 -0700 |
commit | d4070db6312c4b38980ad165732d6beaaa0c06b3 (patch) | |
tree | 596623955444749ddeaf520a1eb2dd10c9021290 /cleanup.c | |
parent | cb784f18ec02778419c58896cabbb418f5512ae1 (diff) | |
download | android_external_rsync-d4070db6312c4b38980ad165732d6beaaa0c06b3.tar.gz android_external_rsync-d4070db6312c4b38980ad165732d6beaaa0c06b3.tar.bz2 android_external_rsync-d4070db6312c4b38980ad165732d6beaaa0c06b3.zip |
Avoid I/O via signal-handler thread.
The cleanup code will try to flush the output buffer in some
circumstances, which is not valid if we're handling an async signal
(since it might have interrupted some partial I/O in the main thread).
These signals now set a flag and try to let the main I/O handler take
care of the exit strategy. Fixes a protocol error that could happen
when trying to exit after a kill signal.
Diffstat (limited to 'cleanup.c')
-rw-r--r-- | cleanup.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -34,6 +34,7 @@ extern char *partial_dir; extern char *logfile_name; BOOL shutting_down = False; +BOOL flush_ok_after_signal = False; #ifdef HAVE_SIGACTION static struct sigaction sigact; @@ -182,7 +183,12 @@ NORETURN void _exit_cleanup(int code, const char *file, int line) #include "case_N.h" switch_step++; - if (!code || am_server || am_receiver) + if (flush_ok_after_signal) { + flush_ok_after_signal = False; + if (code == RERR_SIGNAL) + io_flush(FULL_FLUSH); + } + if (!code) io_flush(FULL_FLUSH); /* FALLTHROUGH */ |