diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-11-09 13:08:45 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-11-09 13:08:45 +0100 |
commit | 8629eb50c25e71cd58de6932c6129998ec4cb5ac (patch) | |
tree | f599d08040930565fc0765dfc07dd1c1056e33ab /src/lib | |
parent | e095f81c0acf1ae21874eb50936b30111fefef89 (diff) |
pass timeout in /check-payment
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/merchant_api_check_payment.c | 28 | ||||
-rw-r--r-- | src/lib/merchant_api_poll_payment.c | 5 |
2 files changed, 25 insertions, 8 deletions
diff --git a/src/lib/merchant_api_check_payment.c b/src/lib/merchant_api_check_payment.c index fe38a18a..4a9e70e1 100644 --- a/src/lib/merchant_api_check_payment.c +++ b/src/lib/merchant_api_check_payment.c @@ -198,10 +198,23 @@ TALER_MERCHANT_check_payment (struct GNUNET_CURL_Context *ctx, { struct TALER_MERCHANT_CheckPaymentOperation *cpo; CURL *eh; + char *timeout_s; + unsigned int ts; + long tlong; GNUNET_assert (NULL != backend_url); GNUNET_assert (NULL != order_id); - + 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); cpo = GNUNET_new (struct TALER_MERCHANT_CheckPaymentOperation); cpo->ctx = ctx; cpo->cb = check_payment_cb; @@ -209,7 +222,10 @@ TALER_MERCHANT_check_payment (struct GNUNET_CURL_Context *ctx, cpo->url = TALER_url_join (backend_url, "check-payment", "order_id", order_id, "session_id", session_id, + (0 != ts) ? "timeout" : NULL, + timeout_s, NULL); + GNUNET_free (timeout_s); eh = curl_easy_init (); if (CURLE_OK != curl_easy_setopt (eh, CURLOPT_URL, @@ -218,11 +234,17 @@ TALER_MERCHANT_check_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, - "checking payment from %s\n", + "Checking payment from %s\n", cpo->url); - if (NULL == (cpo->job = GNUNET_CURL_job_add (ctx, eh, GNUNET_YES, diff --git a/src/lib/merchant_api_poll_payment.c b/src/lib/merchant_api_poll_payment.c index 024595db..af44d2b6 100644 --- a/src/lib/merchant_api_poll_payment.c +++ b/src/lib/merchant_api_poll_payment.c @@ -248,11 +248,6 @@ TALER_MERCHANT_poll_payment (struct GNUNET_CURL_Context *ctx, (0 != ts) ? "timeout" : NULL, timeout_s, NULL); - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Long poll timeout is %s/%llu, url is %s\n", - timeout_s, - (unsigned long long) timeout.rel_value_us, - cpo->url); GNUNET_free (h_contract_s); GNUNET_free (timeout_s); eh = curl_easy_init (); |