@@ -53,6 +53,7 @@ static const char *arg_machine = NULL;
5353static bool arg_merge = false;
5454static int arg_follow = -1 ;
5555static const char * arg_save_state = NULL ;
56+ static usec_t arg_network_timeout_usec = USEC_INFINITY ;
5657
5758static void close_fd_input (Uploader * u );
5859
@@ -211,6 +212,12 @@ int start_upload(Uploader *u,
211212 return log_error_errno (SYNTHETIC_ERRNO (ENOSR ),
212213 "Call to curl_easy_init failed." );
213214
215+ /* If configured, set a timeout for the curl operation. */
216+ if (arg_network_timeout_usec != USEC_INFINITY )
217+ easy_setopt (curl , CURLOPT_TIMEOUT ,
218+ (long ) DIV_ROUND_UP (arg_network_timeout_usec , USEC_PER_SEC ),
219+ LOG_ERR , return - EXFULL );
220+
214221 /* tell it to POST to the URL */
215222 easy_setopt (curl , CURLOPT_POST , 1L ,
216223 LOG_ERR , return - EXFULL );
@@ -561,10 +568,11 @@ static int config_parse_path_or_ignore(
561568
562569static int parse_config (void ) {
563570 const ConfigTableItem items [] = {
564- { "Upload" , "URL" , config_parse_string , 0 , & arg_url },
565- { "Upload" , "ServerKeyFile" , config_parse_path_or_ignore , 0 , & arg_key },
566- { "Upload" , "ServerCertificateFile" , config_parse_path_or_ignore , 0 , & arg_cert },
567- { "Upload" , "TrustedCertificateFile" , config_parse_path_or_ignore , 0 , & arg_trust },
571+ { "Upload" , "URL" , config_parse_string , 0 , & arg_url },
572+ { "Upload" , "ServerKeyFile" , config_parse_path_or_ignore , 0 , & arg_key },
573+ { "Upload" , "ServerCertificateFile" , config_parse_path_or_ignore , 0 , & arg_cert },
574+ { "Upload" , "TrustedCertificateFile" , config_parse_path_or_ignore , 0 , & arg_trust },
575+ { "Upload" , "NetworkTimeoutSec" , config_parse_sec , 0 , & arg_network_timeout_usec },
568576 {}
569577 };
570578
0 commit comments