diff options
author | Christian Grothoff <christian@grothoff.org> | 2022-02-02 09:23:14 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2022-02-02 09:23:14 +0100 |
commit | 8b50f8e0e37f69a806822df83bc20c9e964dd6d8 (patch) | |
tree | 401f25659ccef32ce32bc96698089606399a9100 /src/backend/taler-merchant-httpd_private-post-reserves.c | |
parent | 152b9b98282419937af410f53837bb7d3590c9a0 (diff) | |
download | merchant-8b50f8e0e37f69a806822df83bc20c9e964dd6d8.tar.gz merchant-8b50f8e0e37f69a806822df83bc20c9e964dd6d8.tar.bz2 merchant-8b50f8e0e37f69a806822df83bc20c9e964dd6d8.zip |
fix various cases where shutdown did not work if long pollers were present (#7166)
Diffstat (limited to 'src/backend/taler-merchant-httpd_private-post-reserves.c')
-rw-r--r-- | src/backend/taler-merchant-httpd_private-post-reserves.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/backend/taler-merchant-httpd_private-post-reserves.c b/src/backend/taler-merchant-httpd_private-post-reserves.c index 37b887ef..0351ab10 100644 --- a/src/backend/taler-merchant-httpd_private-post-reserves.c +++ b/src/backend/taler-merchant-httpd_private-post-reserves.c @@ -1,6 +1,6 @@ /* This file is part of TALER - (C) 2021 Taler Systems SA + (C) 2021, 2022 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -109,9 +109,13 @@ struct PostReserveContext enum TALER_ErrorCode ec; /** - * Are we suspended? + * Did we suspend @a connection and are thus in + * the #rc_head DLL (#GNUNET_YES). Set to + * #GNUNET_NO if we are not suspended, and to + * #GNUNET_SYSERR if we should close the connection + * without a response due to shutdown. */ - bool suspended; + enum GNUNET_GenericReturnValue suspended; }; @@ -145,9 +149,9 @@ TMH_force_rc_resume () GNUNET_SCHEDULER_cancel (rc->timeout_task); rc->timeout_task = NULL; } - if (rc->suspended) + if (GNUNET_YES == rc->suspended) { - rc->suspended = false; + rc->suspended = GNUNET_SYSERR; MHD_resume_connection (rc->connection); GNUNET_CONTAINER_DLL_remove (rc_head, rc_tail, @@ -182,7 +186,7 @@ reserve_context_cleanup (void *cls) GNUNET_SCHEDULER_cancel (rc->timeout_task); rc->timeout_task = NULL; } - GNUNET_assert (! rc->suspended); + GNUNET_assert (GNUNET_YES != rc->suspended); GNUNET_free (rc->payto_uri); GNUNET_free (rc); } @@ -211,12 +215,12 @@ handle_exchange (void *cls, const struct TALER_EXCHANGE_Keys *keys; rc->fo = NULL; - rc->suspended = false; if (NULL != rc->timeout_task) { GNUNET_SCHEDULER_cancel (rc->timeout_task); rc->timeout_task = NULL; } + rc->suspended = GNUNET_NO; MHD_resume_connection (rc->connection); GNUNET_CONTAINER_DLL_remove (rc_head, rc_tail, @@ -275,7 +279,7 @@ handle_exchange_timeout (void *cls) TMH_EXCHANGES_find_exchange_cancel (rc->fo); rc->fo = NULL; } - rc->suspended = false; + rc->suspended = GNUNET_NO; MHD_resume_connection (rc->connection); GNUNET_CONTAINER_DLL_remove (rc_head, rc_tail, @@ -334,15 +338,17 @@ TMH_private_post_reserves (const struct TMH_RequestHandler *rh, = GNUNET_SCHEDULER_add_delayed (EXCHANGE_GENERIC_TIMEOUT, &handle_exchange_timeout, rc); - rc->suspended = true; + rc->suspended = GNUNET_YES; GNUNET_CONTAINER_DLL_insert (rc_head, rc_tail, rc); MHD_suspend_connection (connection); return MHD_YES; } + if (GNUNET_SYSERR == rc->suspended) + return MHD_NO; /* we are in shutdown */ - GNUNET_assert (! rc->suspended); + GNUNET_assert (GNUNET_NO == rc->suspended); if (NULL == rc->payto_uri) { return TALER_MHD_reply_with_error (connection, |