fixing another minor leak, improving comments

This commit is contained in:
Christian Grothoff 2015-03-15 16:12:43 +01:00
parent 8077e0f21c
commit 76dda24c11

View File

@ -30,29 +30,39 @@
/** /**
* Snapshot of the (coin and signing) * Snapshot of the (coin and signing) keys (including private keys) of
* keys (including private keys) of the mint. * the mint. There can be multiple instances of this struct, as it is
* reference counted and only destroyed once the last user is done
* with it. The current instance is acquired using
* #TALER_MINT_key_state_acquire(). Using this function increases the
* reference count. The contents of this structure (except for the
* reference counter) should be considered READ-ONLY until it is
* ultimately destroyed (as there can be many concurrent users).
*/ */
struct MintKeyState struct MintKeyState
{ {
/** /**
* JSON array with denomination keys. * JSON array with denomination keys. (Currently not really used
* after initialization.)
*/ */
json_t *denom_keys_array; json_t *denom_keys_array;
/** /**
* JSON array with signing keys. * JSON array with signing keys. (Currently not really used
* after initialization.)
*/ */
json_t *sign_keys_array; json_t *sign_keys_array;
/** /**
* Cached JSON text that the mint will send for * Cached JSON text that the mint will send for a "/keys" request.
* a /keys request. * Includes our @e master_pub public key, the signing and
* denomination keys as well as the @e reload_time.
*/ */
char *keys_json; char *keys_json;
/** /**
* Mapping from denomination keys to denomination key issue struct. * Mapping from denomination keys to denomination key issue struct.
* Used to lookup the key by hash.
*/ */
struct GNUNET_CONTAINER_MultiHashMap *denomkey_map; struct GNUNET_CONTAINER_MultiHashMap *denomkey_map;
@ -62,7 +72,8 @@ struct MintKeyState
struct GNUNET_TIME_Absolute reload_time; struct GNUNET_TIME_Absolute reload_time;
/** /**
* When is the next key invalid and we have to reload? * When is the next key invalid and we have to reload? (We also
* reload on SIGUSR1.)
*/ */
struct GNUNET_TIME_Absolute next_reload; struct GNUNET_TIME_Absolute next_reload;
@ -72,7 +83,7 @@ struct MintKeyState
struct TALER_MINT_SignKeyIssuePriv current_sign_key_issue; struct TALER_MINT_SignKeyIssuePriv current_sign_key_issue;
/** /**
* Reference count. * Reference count. The struct is released when the RC hits zero.
*/ */
unsigned int refcnt; unsigned int refcnt;
}; };
@ -80,7 +91,7 @@ struct MintKeyState
/** /**
* Mint key state. Never use directly, instead access via * Mint key state. Never use directly, instead access via
* #TALER_MINT_key_state_acquire and #TALER_MINT_key_state_release. * #TALER_MINT_key_state_acquire() and #TALER_MINT_key_state_release().
*/ */
static struct MintKeyState *internal_key_state; static struct MintKeyState *internal_key_state;
@ -343,6 +354,7 @@ TALER_MINT_key_state_release (struct MintKeyState *key_state)
&free_denom_key, &free_denom_key,
key_state); key_state);
GNUNET_CONTAINER_multihashmap_destroy (key_state->denomkey_map); GNUNET_CONTAINER_multihashmap_destroy (key_state->denomkey_map);
GNUNET_free (key_state->keys_json);
GNUNET_free (key_state); GNUNET_free (key_state);
} }
GNUNET_assert (0 == pthread_mutex_unlock (&internal_key_state_mutex)); GNUNET_assert (0 == pthread_mutex_unlock (&internal_key_state_mutex));
@ -351,8 +363,8 @@ TALER_MINT_key_state_release (struct MintKeyState *key_state)
/** /**
* Acquire the key state of the mint. Updates keys if necessary. * Acquire the key state of the mint. Updates keys if necessary.
* For every call to #TALER_MINT_key_state_acquire, a matching call * For every call to #TALER_MINT_key_state_acquire(), a matching call
* to #TALER_MINT_key_state_release must be made. * to #TALER_MINT_key_state_release() must be made.
* *
* @return the key state * @return the key state
*/ */
@ -499,8 +511,8 @@ TALER_MINT_key_reload_loop (void)
"(re-)loading keys\n"); "(re-)loading keys\n");
if (NULL != internal_key_state) if (NULL != internal_key_state)
{ {
GNUNET_assert (0 != internal_key_state->refcnt);
TALER_MINT_key_state_release (internal_key_state); TALER_MINT_key_state_release (internal_key_state);
internal_key_state = NULL;
} }
/* This will re-initialize 'internal_key_state' with /* This will re-initialize 'internal_key_state' with
an initial refcnt of 1 */ an initial refcnt of 1 */