exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

commit 264c4a8eb49248723d9dd6cfa7b1be4eaa95c5e3
parent 5ee2aba9cce8bb1d90b251ad7d0dc95e74e74fe7
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sat, 10 Oct 2026 21:27:32 +0200

cap long-polling at 30 minutes

Diffstat:
Msrc/include/taler/taler_mhd_lib.h | 6++++--
Msrc/mhd/mhd_parsing.c | 17+++++++++++++++--
2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/src/include/taler/taler_mhd_lib.h b/src/include/taler/taler_mhd_lib.h @@ -534,7 +534,8 @@ TALER_MHD_parse_request_arg_rel_time (struct MHD_Connection *connection, * * @param connection the MHD connection * @param[out] expiration set to #GNUNET_TIME_UNIT_ZERO_ABS if there was no timeout, - * the current time plus the value given under "timeout_ms" otherwise + * the current time plus the value given under "timeout_ms" otherwise, + * where values above 30 minutes are treated as 30 minutes * @return #GNUNET_OK on success, #GNUNET_NO if an * error was returned on @a connection (caller should return #MHD_YES) and * #GNUNET_SYSERR if we failed to return an error (caller should return #MHD_NO) @@ -551,7 +552,8 @@ TALER_MHD_parse_request_arg_timeout (struct MHD_Connection *connection, * * @param connection the MHD connection * @param[out] expiration set to #GNUNET_TIME_UNIT_ZERO_ABS if there was no timeout, - * the current time plus the value given under "timeout_ms" otherwise + * the current time plus the value given under "timeout_ms" otherwise, + * where values above 30 minutes are treated as 30 minutes */ #define TALER_MHD_parse_request_timeout(connection,expiration) \ do { \ diff --git a/src/mhd/mhd_parsing.c b/src/mhd/mhd_parsing.c @@ -27,6 +27,16 @@ #include "taler/taler_mhd_lib.h" +/** + * Longest long-poll wait we grant a client, in milliseconds. While + * long-polling, the connection is suspended and thus not subject to + * MHD's connection timeout, so without a bound a client could pin the + * connection (with its file descriptor and database event handler) + * for the lifetime of the process. Clients simply poll again. + */ +#define MAX_TIMEOUT_MS (30LLU * 60 * 1000) + + enum GNUNET_GenericReturnValue TALER_MHD_parse_post_json (struct MHD_Connection *connection, void **con_cls, @@ -210,8 +220,9 @@ TALER_MHD_parse_request_arg_rel_time ( ? GNUNET_NO : GNUNET_SYSERR; } - *duration = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, - tms); + *duration = GNUNET_TIME_relative_saturating_multiply ( + GNUNET_TIME_UNIT_MILLISECONDS, + tms); return GNUNET_OK; } @@ -250,6 +261,8 @@ TALER_MHD_parse_request_arg_timeout ( ? GNUNET_NO : GNUNET_SYSERR; } + if (tms > MAX_TIMEOUT_MS) + tms = MAX_TIMEOUT_MS; *expiration = GNUNET_TIME_relative_to_absolute ( GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, tms));