summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/main.c b/src/main.c
index 85f2969..961b650 100644
--- a/src/main.c
+++ b/src/main.c
@@ -61,6 +61,7 @@ struct tip_client {
int num_retries;
int fd;
bool error;
+ bool fatal;
bool redirected;
bool server_only;
struct timeval tv_start, tv_last;
@@ -289,6 +290,7 @@ static int tip_client_head_hdr(struct tip_client *cli)
syslog(LOG_ERR, "failed to allocate room for file %s: %s",
filename, strerror(errno));
delete_file(filename);
+ cli->fatal = true;
return -1;
}
@@ -501,6 +503,10 @@ static int tip_client_request_file(struct tip_client *cli,
ev_loop(tip_main_loop, 0);
if (cli->error) {
+ if (cli->fatal) {
+ syslog(LOG_ERR, "Fatal error, bailing out!\n");
+ return -1;
+ }
syslog(LOG_ERR, "Failed to fetch file %s\n", filename);
sleep(WAIT_RETRY);
if (cli->num_retries++ >= MAX_RETRIES) {
@@ -581,7 +587,7 @@ int main(int argc, char *argv[])
} while (ret > 0);
if (ret < 0)
- goto err_max_retries;
+ goto err_bailout;
if (_cli.state != TIP_CLIENT_DONE)
goto err;
@@ -613,7 +619,7 @@ int main(int argc, char *argv[])
}
if (ret < 0)
- goto err_max_retries;
+ goto err_bailout;
if (_cli.redirected)
tip_client_stats.redirects++;
@@ -655,7 +661,10 @@ err:
tip_client_stats.redirects);
return EXIT_FAILURE;
-err_max_retries:
+err_bailout:
+ if (_cli.fatal)
+ return EXIT_FAILURE;
+
syslog(LOG_INFO, "Failure after maximum number of retries. "
"Direct from server: %u Redirected: %u\n",
tip_client_stats.direct_from_server,