From 86e623adf66141bfc4b8884f035c1ce62cc8bc42 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Tue, 9 Oct 2018 09:06:28 +0200 Subject: [PATCH] write_stackdriver plugin: Set HTTP request timeout. --- src/write_stackdriver.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/write_stackdriver.c b/src/write_stackdriver.c index eb60ea9c..7be3c678 100644 --- a/src/write_stackdriver.c +++ b/src/write_stackdriver.c @@ -187,6 +187,12 @@ static int do_post(wg_callback_t *cb, char const *url, void const *payload, curl_easy_setopt(cb->curl, CURLOPT_POST, 1L); curl_easy_setopt(cb->curl, CURLOPT_URL, url); + long timeout_ms = 2 * CDTIME_T_TO_MS(plugin_get_interval()); + if (timeout_ms < 10000) { + timeout_ms = 10000; + } + curl_easy_setopt(cb->curl, CURLOPT_TIMEOUT_MS, timeout_ms); + /* header */ char *auth_header = wg_get_authorization_header(cb); if (auth_header == NULL) { -- 2.11.0