-fix leak
This commit is contained in:
parent
8aebcf283a
commit
b022232a59
@ -545,7 +545,7 @@ free_denom_key (void *cls,
|
|||||||
* @param key_state the key state to release
|
* @param key_state the key state to release
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
TMH_KS_release_ (struct TMH_KS_StateHandle *key_state)
|
ks_release_ (struct TMH_KS_StateHandle *key_state)
|
||||||
{
|
{
|
||||||
GNUNET_assert (0 < key_state->refcnt);
|
GNUNET_assert (0 < key_state->refcnt);
|
||||||
key_state->refcnt--;
|
key_state->refcnt--;
|
||||||
@ -578,13 +578,15 @@ TMH_KS_release_ (struct TMH_KS_StateHandle *key_state)
|
|||||||
/**
|
/**
|
||||||
* Release key state, free if necessary (if reference count gets to zero).
|
* Release key state, free if necessary (if reference count gets to zero).
|
||||||
*
|
*
|
||||||
|
* @param location name of the function in which the lock is acquired
|
||||||
* @param key_state the key state to release
|
* @param key_state the key state to release
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
TMH_KS_release (struct TMH_KS_StateHandle *key_state)
|
TMH_KS_release_ (const char *location,
|
||||||
|
struct TMH_KS_StateHandle *key_state)
|
||||||
{
|
{
|
||||||
GNUNET_assert (0 == pthread_mutex_lock (&internal_key_state_mutex));
|
GNUNET_assert (0 == pthread_mutex_lock (&internal_key_state_mutex));
|
||||||
TMH_KS_release_ (key_state);
|
ks_release_ (key_state);
|
||||||
GNUNET_assert (0 == pthread_mutex_unlock (&internal_key_state_mutex));
|
GNUNET_assert (0 == pthread_mutex_unlock (&internal_key_state_mutex));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -594,10 +596,11 @@ TMH_KS_release (struct TMH_KS_StateHandle *key_state)
|
|||||||
* For every call to #TMH_KS_acquire(), a matching call
|
* For every call to #TMH_KS_acquire(), a matching call
|
||||||
* to #TMH_KS_release() must be made.
|
* to #TMH_KS_release() must be made.
|
||||||
*
|
*
|
||||||
|
* @param location name of the function in which the lock is acquired
|
||||||
* @return the key state
|
* @return the key state
|
||||||
*/
|
*/
|
||||||
struct TMH_KS_StateHandle *
|
struct TMH_KS_StateHandle *
|
||||||
TMH_KS_acquire (void)
|
TMH_KS_acquire_ (const char *location)
|
||||||
{
|
{
|
||||||
struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
|
struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
|
||||||
struct TMH_KS_StateHandle *key_state;
|
struct TMH_KS_StateHandle *key_state;
|
||||||
@ -609,7 +612,7 @@ TMH_KS_acquire (void)
|
|||||||
if ( (NULL != internal_key_state) &&
|
if ( (NULL != internal_key_state) &&
|
||||||
(internal_key_state->next_reload.abs_value_us <= now.abs_value_us) )
|
(internal_key_state->next_reload.abs_value_us <= now.abs_value_us) )
|
||||||
{
|
{
|
||||||
TMH_KS_release_ (internal_key_state);
|
ks_release_ (internal_key_state);
|
||||||
internal_key_state = NULL;
|
internal_key_state = NULL;
|
||||||
}
|
}
|
||||||
if (NULL == internal_key_state)
|
if (NULL == internal_key_state)
|
||||||
|
@ -41,10 +41,32 @@ struct TMH_KS_StateHandle;
|
|||||||
* For every call to #TMH_KS_acquire(), a matching call
|
* For every call to #TMH_KS_acquire(), a matching call
|
||||||
* to #TMH_KS_release() must be made.
|
* to #TMH_KS_release() must be made.
|
||||||
*
|
*
|
||||||
|
* @param location name of the function in which the lock is acquired
|
||||||
* @return the key state
|
* @return the key state
|
||||||
*/
|
*/
|
||||||
struct TMH_KS_StateHandle *
|
struct TMH_KS_StateHandle *
|
||||||
TMH_KS_acquire (void);
|
TMH_KS_acquire_ (const char *location);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Release key state, free if necessary (if reference count gets to zero).
|
||||||
|
*
|
||||||
|
* @param location name of the function in which the lock is acquired
|
||||||
|
* @param key_state the key state to release
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
TMH_KS_release_ (const char *location,
|
||||||
|
struct TMH_KS_StateHandle *key_state);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Acquire the key state of the mint. Updates keys if necessary.
|
||||||
|
* For every call to #TMH_KS_acquire(), a matching call
|
||||||
|
* to #TMH_KS_release() must be made.
|
||||||
|
*
|
||||||
|
* @return the key state
|
||||||
|
*/
|
||||||
|
#define TMH_KS_acquire(void) TMH_KS_acquire_(__FUNCTION__)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -52,8 +74,7 @@ TMH_KS_acquire (void);
|
|||||||
*
|
*
|
||||||
* @param key_state the key state to release
|
* @param key_state the key state to release
|
||||||
*/
|
*/
|
||||||
void
|
#define TMH_KS_release(key_state) TMH_KS_release_ (__FUNCTION__, key_state)
|
||||||
TMH_KS_release (struct TMH_KS_StateHandle *key_state);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -136,6 +136,7 @@ TMH_RESERVE_handler_reserve_withdraw (struct TMH_RequestHandler *rh,
|
|||||||
if (NULL == dki)
|
if (NULL == dki)
|
||||||
{
|
{
|
||||||
TMH_PARSE_release_data (spec);
|
TMH_PARSE_release_data (spec);
|
||||||
|
TMH_KS_release (ks);
|
||||||
return TMH_RESPONSE_reply_arg_unknown (connection,
|
return TMH_RESPONSE_reply_arg_unknown (connection,
|
||||||
"denom_pub");
|
"denom_pub");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user