Skip to content

Commit 4dfb754

Browse files
committed
added retries to curl send
1 parent f91b8f6 commit 4dfb754

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/reader_network.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ void send_output_file() {
555555
struct stat file_info;
556556
curl_off_t fsize;
557557
char noproxy_host[1024];
558-
int slash_pos = 6, i = 0;
558+
int slash_pos = 6, i = 0, j = 0;
559559

560560
memset(file, 0, 1024);
561561

@@ -619,14 +619,15 @@ void send_output_file() {
619619
curl_easy_setopt(ch, CURLOPT_ERRORBUFFER, buff_2);
620620

621621
/* Now run off and do what you've been told! */
622-
res = curl_easy_perform(ch);
623622

624-
if (res != CURLE_OK) {
625-
log_printf(LOG_ERROR, "ERROR curl(1): %s\nERROR curl(2): %s\n", curl_easy_strerror(res), buff_2);
623+
for(j = 0; j<5; j++) {
624+
log_printf(LOG_VERBOSE, "sending ftp file, curl try number(%d)\n", j);
626625
res = curl_easy_perform(ch);
627-
if (res != CURLE_OK) {
628-
log_printf(LOG_ERROR, "ERROR curl(3): %s\nERROR curl(4): %s\n", curl_easy_strerror(res), buff_2);
629-
}
626+
if (res == CURLE_OK) {
627+
break;
628+
}
629+
log_printf(LOG_ERROR, "ERROR curl(1): %s\nERROR curl(2): %s\n", curl_easy_strerror(res), buff_2);
630+
sleep(1);
630631
}
631632

632633
/* always cleanup */

0 commit comments

Comments
 (0)