commit e1018a55b85d2d699f3fe64cc7794c1778b7f130
parent d323e5cd2673dc0664623841463807ebde197b22
Author: Christian Grothoff <grothoff@gnunet.org>
Date: Fri, 14 Aug 2026 23:35:18 +0200
enforce sane timeouts on webhooks
Diffstat:
1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/src/backend/taler-merchant-webhook.c b/src/backend/taler-merchant-webhook.c
@@ -39,6 +39,20 @@
*/
#define CONCURRENCY_LIMIT 32
+/**
+ * How long (in seconds) may a single webhook request take before we give
+ * up on it? Without a limit a single unresponsive webhook target would
+ * occupy one of the #CONCURRENCY_LIMIT slots forever and (as we only
+ * SELECT() again once *all* requests of a batch completed) stall webhook
+ * processing entirely.
+ */
+#define WEBHOOK_TIMEOUT_SECONDS 60L
+
+/**
+ * How long (in seconds) may establishing the TCP/TLS connection take?
+ */
+#define WEBHOOK_CONNECT_TIMEOUT_SECONDS 15L
+
struct WorkResponse
{
@@ -370,11 +384,19 @@ pending_webhooks_cb (void *cls,
GNUNET_assert (CURLE_OK ==
curl_easy_setopt (eh,
CURLOPT_MAXREDIRS,
- 5));
+ 5L));
GNUNET_assert (CURLE_OK ==
curl_easy_setopt (eh,
CURLOPT_FOLLOWLOCATION,
- 1));
+ 1L));
+ GNUNET_assert (CURLE_OK ==
+ curl_easy_setopt (eh,
+ CURLOPT_CONNECTTIMEOUT,
+ WEBHOOK_CONNECT_TIMEOUT_SECONDS));
+ GNUNET_assert (CURLE_OK ==
+ curl_easy_setopt (eh,
+ CURLOPT_TIMEOUT,
+ WEBHOOK_TIMEOUT_SECONDS));
w->job = GNUNET_CURL_job_add_raw (ctx,
eh,