misc bugfixes in reserves_in batch logic

This commit is contained in:
Christian Grothoff 2023-04-22 01:20:41 +02:00
parent 5290453e36
commit 2dab1fac1c
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
5 changed files with 1082 additions and 1328 deletions

View File

@ -147,18 +147,13 @@ db_event_cb (void *cls,
const void *extra,
size_t extra_size)
{
struct TEH_RequestContext *rc = cls;
struct ReservePoller *rp = rc->rh_ctx;
struct ReservePoller *rp = cls;
struct GNUNET_AsyncScopeSave old_scope;
(void) extra;
(void) extra_size;
if (! rp->suspended)
return; /* might get multiple wake-up events */
GNUNET_async_scope_enter (&rc->async_scope_id,
&old_scope);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Resuming from long-polling on reserve\n");
TEH_check_invariants ();
rp->suspended = false;
MHD_resume_connection (rp->connection);
@ -238,7 +233,8 @@ TEH_handler_reserves_get (struct TEH_RequestContext *rc,
};
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Starting DB event listening\n");
"Starting DB event listening until %s\n",
GNUNET_TIME_absolute2s (rp->timeout));
rp->eh = TEH_plugin->event_listen (
TEH_plugin->cls,
GNUNET_TIME_absolute_get_remaining (rp->timeout),
@ -256,49 +252,27 @@ TEH_handler_reserves_get (struct TEH_RequestContext *rc,
{
case GNUNET_DB_STATUS_SOFT_ERROR:
GNUNET_break (0); /* single-shot query should never have soft-errors */
if (NULL != rp->eh)
{
TEH_plugin->event_listen_cancel (TEH_plugin->cls,
rp->eh);
rp->eh = NULL;
}
return TALER_MHD_reply_with_error (rc->connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_GENERIC_DB_SOFT_FAILURE,
"get_reserve_balance");
case GNUNET_DB_STATUS_HARD_ERROR:
GNUNET_break (0);
if (NULL != rp->eh)
{
TEH_plugin->event_listen_cancel (TEH_plugin->cls,
rp->eh);
rp->eh = NULL;
}
return TALER_MHD_reply_with_error (rc->connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_GENERIC_DB_FETCH_FAILED,
"get_reserve_balance");
case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
if (NULL != rp->eh)
{
TEH_plugin->event_listen_cancel (TEH_plugin->cls,
rp->eh);
rp->eh = NULL;
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Got reserve balance of %s\n",
TALER_amount2s (&rp->balance));
return TALER_MHD_REPLY_JSON_PACK (rc->connection,
MHD_HTTP_OK,
TALER_JSON_pack_amount ("balance",
&rp->balance));
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
if ( (NULL != rp) ||
(GNUNET_TIME_absolute_is_future (rp->timeout)) )
if (! GNUNET_TIME_absolute_is_future (rp->timeout))
{
if (NULL != rp->eh)
{
TEH_plugin->event_listen_cancel (TEH_plugin->cls,
rp->eh);
rp->eh = NULL;
}
return TALER_MHD_reply_with_error (rc->connection,
MHD_HTTP_NOT_FOUND,
TALER_EC_EXCHANGE_RESERVES_STATUS_UNKNOWN,

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -34,7 +34,6 @@
*/
struct WirewatchState
{
/**
* Process for the wirewatcher.
*/

View File

@ -353,7 +353,7 @@ maint_child_death (void *cls)
while (TALER_TESTING_cmd_is_batch (cmd))
cmd = TALER_TESTING_cmd_batch_get_current (cmd);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Got SIGCHLD for `%s'.\n",
cmd->label);
is->child_death_task = NULL;