summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2001-03-22 07:36:51 +0000
committerAndrew Tridgell <tridge@samba.org>2001-03-22 07:36:51 +0000
commitff81e809f46293171a332a2faa320aca57277b4b (patch)
treebf4d165b7a24029b531567cbbe92ecc94ceba997
parentfd2dd2aa231954db2bcc0b60f2a696bc38161aa9 (diff)
downloadrsync-ff81e809f46293171a332a2faa320aca57277b4b.tar.gz
new error handling system
we now give a non-0 exit code if *any* of the files we have been asked to transfer fail to transfer
-rw-r--r--cleanup.c7
-rw-r--r--clientserver.c2
-rw-r--r--compat.c4
-rw-r--r--io.c12
-rw-r--r--log.c4
-rw-r--r--main.c10
6 files changed, 19 insertions, 20 deletions
diff --git a/cleanup.c b/cleanup.c
index bd562ae6..4b9cad3a 100644
--- a/cleanup.c
+++ b/cleanup.c
@@ -40,6 +40,7 @@ extern int io_error;
void _exit_cleanup(int code, const char *file, int line)
{
extern int keep_partial;
+ extern int log_got_error;
if (code == 0 && io_error) code = RERR_FILEIO;
@@ -69,6 +70,12 @@ void _exit_cleanup(int code, const char *file, int line)
if (code) log_exit(code, file, line);
+ if (code == 0) {
+ if (log_got_error) {
+ code = RERR_FILEIO;
+ }
+ }
+
exit(code);
}
diff --git a/clientserver.c b/clientserver.c
index 1bb0633a..3d8b0a18 100644
--- a/clientserver.c
+++ b/clientserver.c
@@ -63,7 +63,7 @@ int start_socket_client(char *host, char *path, int argc, char *argv[])
}
if (*path == '/') {
- rprintf(FERROR,"ERROR: The remote path must start with a module name\n");
+ rprintf(FERROR,"ERROR: The remote path must start with a module name not a /\n");
return -1;
}
diff --git a/compat.c b/compat.c
index ee9e0520..305c827d 100644
--- a/compat.c
+++ b/compat.c
@@ -55,10 +55,6 @@ void setup_protocol(int f_out,int f_in)
exit_cleanup(RERR_PROTOCOL);
}
- if (verbose > 2)
- rprintf(FINFO, "local_version=%d remote_version=%d\n",
- PROTOCOL_VERSION, remote_version);
-
if (remote_version >= 12) {
if (am_server) {
checksum_seed = time(NULL);
diff --git a/io.c b/io.c
index 649bd758..1069a2e5 100644
--- a/io.c
+++ b/io.c
@@ -490,18 +490,6 @@ void io_end_buffering(int fd)
}
}
-/* some OSes have a bug where an exit causes the pending writes on
- a socket to be flushed. Do an explicit shutdown to try to prevent this */
-void io_shutdown(void)
-{
- err_list_push();
- if (multiplex_out_fd != -1) close(multiplex_out_fd);
- if (io_error_fd != -1) close(io_error_fd);
- multiplex_out_fd = -1;
- io_error_fd = -1;
-}
-
-
static void writefd(int fd,char *buf,int len)
{
stats.total_written += len;
diff --git a/log.c b/log.c
index a826b185..492948bd 100644
--- a/log.c
+++ b/log.c
@@ -31,6 +31,7 @@ static char *logfname;
static FILE *logfile;
static int log_error_fd = -1;
+int log_got_error=0;
struct {
int code;
@@ -107,6 +108,8 @@ void err_list_push(void)
while (err_list_head) {
struct err_list *el = err_list_head;
int n = write(log_error_fd, el->buf+el->written, el->len - el->written);
+ /* don't check for an error if the best way of handling the error is
+ to ignore it */
if (n == -1) break;
if (n > 0) {
el->written += n;
@@ -250,6 +253,7 @@ void rwrite(enum logcode code, char *buf, int len)
}
if (code == FERROR) {
+ log_got_error = 1;
f = stderr;
}
diff --git a/main.c b/main.c
index 86a1a55c..dae6e790 100644
--- a/main.c
+++ b/main.c
@@ -553,7 +553,7 @@ int client_run(int f_in, int f_out, int pid, int argc, char *argv[])
wait_process(pid, &status);
}
- return status | status2;
+ return MAX(status, status2);
}
static char *find_colon(char *s)
@@ -699,6 +699,8 @@ static RETSIGTYPE sigusr1_handler(int val) {
}
static RETSIGTYPE sigusr2_handler(int val) {
+ extern int log_got_error;
+ if (log_got_error) _exit(RERR_FILEIO);
_exit(0);
}
@@ -709,6 +711,7 @@ int main(int argc,char *argv[])
extern int dry_run;
extern int am_daemon;
extern int am_server;
+ int ret;
signal(SIGUSR1, sigusr1_handler);
signal(SIGUSR2, sigusr2_handler);
@@ -734,7 +737,6 @@ int main(int argc,char *argv[])
exit_cleanup(RERR_SYNTAX);
}
- signal(SIGCHLD,SIG_IGN);
signal(SIGINT,SIGNAL_CAST sig_int);
signal(SIGPIPE,SIGNAL_CAST sig_int);
signal(SIGHUP,SIGNAL_CAST sig_int);
@@ -771,6 +773,8 @@ int main(int argc,char *argv[])
start_server(STDIN_FILENO, STDOUT_FILENO, argc, argv);
}
- return start_client(argc, argv);
+ ret = start_client(argc, argv);
+ exit_cleanup(ret);
+ return ret;
}