commit e62708f09ff5a6bd70933be195c538d6751e088f
parent 3a22e604af2ca05ab1d1169d5217420fe99d3a7c
Author: Christian Grothoff <christian@grothoff.org>
Date: Sat, 2 Nov 2019 17:58:43 +0100
also propage timeout into curl
Diffstat:
1 file changed, 14 insertions(+), 0 deletions(-)
diff --git a/src/lib/merchant_api_poll_payment.c b/src/lib/merchant_api_poll_payment.c
@@ -204,6 +204,7 @@ TALER_MERCHANT_poll_payment (struct GNUNET_CURL_Context *ctx,
char *h_contract_s;
char *timeout_s;
unsigned int ts;
+ long tlong;
GNUNET_assert (NULL != backend_url);
GNUNET_assert (NULL != order_id);
@@ -211,6 +212,12 @@ TALER_MERCHANT_poll_payment (struct GNUNET_CURL_Context *ctx,
sizeof (*h_contract));
ts = (unsigned int) (timeout.rel_value_us
/ GNUNET_TIME_UNIT_SECONDS.rel_value_us);
+ /* set curl timeout to *our* long poll timeout plus one minute
+ (for network latency and processing delays) */
+ tlong = (long) (GNUNET_TIME_relative_add (timeout,
+ GNUNET_TIME_UNIT_MINUTES).
+ rel_value_us
+ / GNUNET_TIME_UNIT_MILLISECONDS.rel_value_us);
GNUNET_asprintf (&timeout_s,
"%u",
ts);
@@ -236,6 +243,13 @@ TALER_MERCHANT_poll_payment (struct GNUNET_CURL_Context *ctx,
GNUNET_break (0);
return NULL;
}
+ if (CURLE_OK != curl_easy_setopt (eh,
+ CURLOPT_TIMEOUT_MS,
+ tlong))
+ {
+ GNUNET_break (0);
+ return NULL;
+ }
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"polling payment from %s\n",