bail out after maximum number of retries
stop downloading remaining chunks if one is missing after the maximum number of retries.master
parent
e9de4e482f
commit
39e60a019a
20
src/main.c
20
src/main.c
|
@ -534,7 +534,7 @@ int main(int argc, char *argv[])
|
|||
uint64_t data_len = 0, file_size = 0;
|
||||
bool file_chunk[MAX_CHUNKS] = {};
|
||||
uint64_t chunk_size;
|
||||
int i, k, fd;
|
||||
int i, k, fd, ret;
|
||||
|
||||
if (argc != 3) {
|
||||
printf("%s [ip] [file]\n", argv[0]);
|
||||
|
@ -553,7 +553,11 @@ int main(int argc, char *argv[])
|
|||
do {
|
||||
filename = argv[2];
|
||||
_cli.state = TIP_CLIENT_HEAD_HEADER;
|
||||
} while (tip_client_request_file(&_cli, addr, filename) > 0);
|
||||
ret = tip_client_request_file(&_cli, addr, filename);
|
||||
} while (ret > 0);
|
||||
|
||||
if (ret < 0)
|
||||
goto err_max_retries;
|
||||
|
||||
if (_cli.state != TIP_CLIENT_DONE)
|
||||
goto err;
|
||||
|
@ -574,8 +578,11 @@ int main(int argc, char *argv[])
|
|||
do {
|
||||
syslog(LOG_INFO, "Requesting file %s to server\n", filename);
|
||||
_cli.state = TIP_CLIENT_GET_HEADER;
|
||||
ret = tip_client_request_file(&_cli, addr, filename);
|
||||
} while (ret > 0);
|
||||
|
||||
} while (tip_client_request_file(&_cli, addr, filename) > 0);
|
||||
if (ret < 0)
|
||||
goto err_max_retries;
|
||||
|
||||
tip_client_progress(&_cli, true);
|
||||
file_chunk[k] = true;
|
||||
|
@ -605,4 +612,11 @@ err:
|
|||
tip_client_stats.direct_from_server,
|
||||
tip_client_stats.redirects);
|
||||
return EXIT_FAILURE;
|
||||
|
||||
err_max_retries:
|
||||
syslog(LOG_INFO, "Failure after maximum number of retries. "
|
||||
"Direct from server: %u Redirected: %u\n",
|
||||
tip_client_stats.direct_from_server,
|
||||
tip_client_stats.redirects);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue