summaryrefslogtreecommitdiff
path: root/src/journal-remote
diff options
context:
space:
mode:
authorJayanth Ananthapadmanaban <jayanthgem@gmail.com>2021-06-05 06:33:54 -0700
committerLennart Poettering <lennart@poettering.net>2021-06-14 11:16:38 +0200
commit279082ed4907ea7e425b0c436a068bd3076d4de7 (patch)
tree49122a28db484c2b1789ac43d42acd63c9e139ad /src/journal-remote
parent5a750c49a995d1897902b49c5c51ecade9cf06ba (diff)
downloadsystemd-279082ed4907ea7e425b0c436a068bd3076d4de7.tar.gz
Add a network timeout option to journal-upload
Diffstat (limited to 'src/journal-remote')
-rw-r--r--src/journal-remote/journal-upload.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/journal-remote/journal-upload.c b/src/journal-remote/journal-upload.c
index c3d580e49e..2a38d206ea 100644
--- a/src/journal-remote/journal-upload.c
+++ b/src/journal-remote/journal-upload.c
@@ -53,6 +53,7 @@ static const char *arg_machine = NULL;
static bool arg_merge = false;
static int arg_follow = -1;
static const char *arg_save_state = NULL;
+static usec_t arg_network_timeout_usec = USEC_INFINITY;
static void close_fd_input(Uploader *u);
@@ -211,6 +212,12 @@ int start_upload(Uploader *u,
return log_error_errno(SYNTHETIC_ERRNO(ENOSR),
"Call to curl_easy_init failed.");
+ /* If configured, set a timeout for the curl operation. */
+ if (arg_network_timeout_usec != USEC_INFINITY)
+ easy_setopt(curl, CURLOPT_TIMEOUT,
+ (long) DIV_ROUND_UP(arg_network_timeout_usec, USEC_PER_SEC),
+ LOG_ERR, return -EXFULL);
+
/* tell it to POST to the URL */
easy_setopt(curl, CURLOPT_POST, 1L,
LOG_ERR, return -EXFULL);
@@ -561,10 +568,11 @@ finalize:
static int parse_config(void) {
const ConfigTableItem items[] = {
- { "Upload", "URL", config_parse_string, 0, &arg_url },
- { "Upload", "ServerKeyFile", config_parse_path_or_ignore, 0, &arg_key },
- { "Upload", "ServerCertificateFile", config_parse_path_or_ignore, 0, &arg_cert },
- { "Upload", "TrustedCertificateFile", config_parse_path_or_ignore, 0, &arg_trust },
+ { "Upload", "URL", config_parse_string, 0, &arg_url },
+ { "Upload", "ServerKeyFile", config_parse_path_or_ignore, 0, &arg_key },
+ { "Upload", "ServerCertificateFile", config_parse_path_or_ignore, 0, &arg_cert },
+ { "Upload", "TrustedCertificateFile", config_parse_path_or_ignore, 0, &arg_trust },
+ { "Upload", "NetworkTimeoutSec", config_parse_sec, 0, &arg_network_timeout_usec },
{}
};