exchange

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

commit e4ab7c5243209d9f64c6bfd47f22041cad46260d
parent 791b12be20177766493e376575b1358441358c7e
Author: Christian Grothoff <grothoff@gnunet.org>
Date:   Sat, 11 Jul 2026 19:45:19 +0200

fix cleanup logic to make it more robust

Diffstat:
Msrc/bank-lib/fakebank_stop.c | 20+++++++++++++-------
Msrc/bank-lib/fakebank_tbi_post_withdrawal_operation.c | 63+++++++++++++++++++++++++++++++++++----------------------------
Msrc/bank-lib/taler-exchange-wire-gateway-client.c | 14+++-----------
3 files changed, 51 insertions(+), 46 deletions(-)

diff --git a/src/bank-lib/fakebank_stop.c b/src/bank-lib/fakebank_stop.c @@ -139,7 +139,7 @@ TALER_FAKEBANK_stop (struct TALER_FAKEBANK_Handle *h) h->lp_event_out = -1; #endif } - else + else if (NULL != h->lp_heap) { struct LongPoller *lp; @@ -170,9 +170,12 @@ TALER_FAKEBANK_stop (struct TALER_FAKEBANK_Handle *h) NULL); GNUNET_CONTAINER_multishortmap_destroy (h->wops); } - GNUNET_CONTAINER_multihashmap_destroy (h->uuid_map); - GNUNET_CONTAINER_multipeermap_destroy (h->rpubs); - GNUNET_CONTAINER_heap_destroy (h->lp_heap); + if (NULL != h->uuid_map) + GNUNET_CONTAINER_multihashmap_destroy (h->uuid_map); + if (NULL != h->rpubs) + GNUNET_CONTAINER_multipeermap_destroy (h->rpubs); + if (NULL != h->lp_heap) + GNUNET_CONTAINER_heap_destroy (h->lp_heap); GNUNET_assert (0 == pthread_mutex_destroy (&h->big_lock)); GNUNET_assert (0 == @@ -181,9 +184,12 @@ TALER_FAKEBANK_stop (struct TALER_FAKEBANK_Handle *h) pthread_mutex_destroy (&h->accounts_lock)); GNUNET_assert (0 == pthread_mutex_destroy (&h->rpubs_lock)); - for (uint64_t i = 0; i<h->ram_limit; i++) - GNUNET_free (h->transactions[i]); - GNUNET_free (h->transactions); + if (NULL != h->transactions) + { + for (uint64_t i = 0; i<h->ram_limit; i++) + GNUNET_free (h->transactions[i]); + GNUNET_free (h->transactions); + } GNUNET_free (h->my_baseurl); GNUNET_free (h->currency); GNUNET_free (h->exchange_url); diff --git a/src/bank-lib/fakebank_tbi_post_withdrawal_operation.c b/src/bank-lib/fakebank_tbi_post_withdrawal_operation.c @@ -66,19 +66,21 @@ do_post_withdrawal ( { GNUNET_assert (0 == pthread_mutex_unlock (&h->big_lock)); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_NOT_FOUND, - TALER_EC_BANK_TRANSACTION_NOT_FOUND, - wopid); + return TALER_MHD_reply_with_error ( + connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_BANK_TRANSACTION_NOT_FOUND, + wopid); } if (wo->aborted) { GNUNET_assert (0 == pthread_mutex_unlock (&h->big_lock)); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_CONFLICT, - TALER_EC_BANK_UPDATE_ABORT_CONFLICT, - wopid); + return TALER_MHD_reply_with_error ( + connection, + MHD_HTTP_CONFLICT, + TALER_EC_BANK_UPDATE_ABORT_CONFLICT, + wopid); } if ( (wo->selection_done) && (0 != GNUNET_memcmp (&wo->reserve_pub, @@ -86,16 +88,17 @@ do_post_withdrawal ( { GNUNET_assert (0 == pthread_mutex_unlock (&h->big_lock)); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_CONFLICT, - TALER_EC_BANK_WITHDRAWAL_OPERATION_RESERVE_SELECTION_CONFLICT, - "reserve public key changed"); + return TALER_MHD_reply_with_error ( + connection, + MHD_HTTP_CONFLICT, + TALER_EC_BANK_WITHDRAWAL_OPERATION_RESERVE_SELECTION_CONFLICT, + "reserve public key changed"); } { /* check if reserve_pub is already in use */ const struct GNUNET_PeerIdentity *pid; - pid = (const struct GNUNET_PeerIdentity *) &wo->reserve_pub; + pid = (const struct GNUNET_PeerIdentity *) reserve_pub; if (GNUNET_CONTAINER_multipeermap_contains (h->rpubs, pid)) { @@ -141,21 +144,24 @@ do_post_withdrawal ( { GNUNET_assert (0 == pthread_mutex_unlock (&h->big_lock)); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_CONFLICT, - TALER_EC_BANK_WITHDRAWAL_OPERATION_RESERVE_SELECTION_CONFLICT, - "exchange account changed"); + return TALER_MHD_reply_with_error ( + connection, + MHD_HTTP_CONFLICT, + TALER_EC_BANK_WITHDRAWAL_OPERATION_RESERVE_SELECTION_CONFLICT, + "exchange account changed"); } - if ( (NULL != wo->amount) && (NULL != amount) && (0 != TALER_amount_cmp (wo-> - amount, - amount)) ) + if ( (NULL != wo->amount) && + (NULL != amount) && + (0 != TALER_amount_cmp (wo->amount, + amount)) ) { GNUNET_assert (0 == pthread_mutex_unlock (&h->big_lock)); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_CONFLICT, - TALER_EC_BANK_WITHDRAWAL_OPERATION_RESERVE_SELECTION_CONFLICT, - "amount changed"); + return TALER_MHD_reply_with_error ( + connection, + MHD_HTTP_CONFLICT, + TALER_EC_BANK_WITHDRAWAL_OPERATION_RESERVE_SELECTION_CONFLICT, + "amount changed"); } if (NULL == wo->amount) { @@ -163,10 +169,11 @@ do_post_withdrawal ( { GNUNET_assert (0 == pthread_mutex_unlock (&h->big_lock)); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_BANK_POST_WITHDRAWAL_OPERATION_REQUIRED, - "amount missing"); + return TALER_MHD_reply_with_error ( + connection, + MHD_HTTP_BAD_REQUEST, + TALER_EC_BANK_POST_WITHDRAWAL_OPERATION_REQUIRED, + "amount missing"); } else { diff --git a/src/bank-lib/taler-exchange-wire-gateway-client.c b/src/bank-lib/taler-exchange-wire-gateway-client.c @@ -706,25 +706,17 @@ run (void *cls, { auth.method = TALER_BANK_AUTH_BASIC; } - else if ( (NULL != auth.wire_gateway_url) && - (NULL != auth.details.bearer.token) ) - { - auth.method = TALER_BANK_AUTH_BEARER; - } - - else if (NULL == auth.wire_gateway_url) + else if (NULL != auth.wire_gateway_url) { fprintf (stderr, - "Error: No account specified (use -b or -s options).\n"); + "Error: No account specified (use -u and -p options).\n"); GNUNET_SCHEDULER_shutdown (); return; } } if ( (NULL == auth.wire_gateway_url) || (0 == strlen (auth.wire_gateway_url)) || - (0 != strncasecmp ("http", - auth.wire_gateway_url, - strlen ("http"))) ) + (! TALER_is_web_url (auth.wire_gateway_url)) ) { fprintf (stderr, "Error: Invalid wire gateway URL `%s' configured.\n",