aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-09-22 10:29:53 +0200
committerChristian Grothoff <christian@grothoff.org>2015-09-22 10:29:53 +0200
commitb022232a59f6b2acd1d183625089dba2b1ee5834 (patch)
tree3f8e5ea0d531f80dccd5b0670468f26e01defc3f /src
parent8aebcf283a4aecb1d058db8b4f021439e45d3685 (diff)
-fix leak
Diffstat (limited to 'src')
-rw-r--r--src/mint/taler-mint-httpd_keystate.c13
-rw-r--r--src/mint/taler-mint-httpd_keystate.h25
-rw-r--r--src/mint/taler-mint-httpd_reserve.c1
3 files changed, 32 insertions, 7 deletions
diff --git a/src/mint/taler-mint-httpd_keystate.c b/src/mint/taler-mint-httpd_keystate.c
index 6a0bad540..8b2e8a37f 100644
--- a/src/mint/taler-mint-httpd_keystate.c
+++ b/src/mint/taler-mint-httpd_keystate.c
@@ -545,7 +545,7 @@ free_denom_key (void *cls,
* @param key_state the key state to release
*/
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);
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).
*
+ * @param location name of the function in which the lock is acquired
* @param key_state the key state to release
*/
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));
- TMH_KS_release_ (key_state);
+ ks_release_ (key_state);
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
* to #TMH_KS_release() must be made.
*
+ * @param location name of the function in which the lock is acquired
* @return the key state
*/
struct TMH_KS_StateHandle *
-TMH_KS_acquire (void)
+TMH_KS_acquire_ (const char *location)
{
struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
struct TMH_KS_StateHandle *key_state;
@@ -609,7 +612,7 @@ TMH_KS_acquire (void)
if ( (NULL != internal_key_state) &&
(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;
}
if (NULL == internal_key_state)
diff --git a/src/mint/taler-mint-httpd_keystate.h b/src/mint/taler-mint-httpd_keystate.h
index 9529de8f3..0e20ef588 100644
--- a/src/mint/taler-mint-httpd_keystate.h
+++ b/src/mint/taler-mint-httpd_keystate.h
@@ -41,19 +41,40 @@ struct TMH_KS_StateHandle;
* For every call to #TMH_KS_acquire(), a matching call
* to #TMH_KS_release() must be made.
*
+ * @param location name of the function in which the lock is acquired
* @return the key state
*/
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 (struct TMH_KS_StateHandle *key_state);
+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__)
+
+
+/**
+ * Release key state, free if necessary (if reference count gets to zero).
+ *
+ * @param key_state the key state to release
+ */
+#define TMH_KS_release(key_state) TMH_KS_release_ (__FUNCTION__, key_state)
/**
diff --git a/src/mint/taler-mint-httpd_reserve.c b/src/mint/taler-mint-httpd_reserve.c
index 445278090..c887ee750 100644
--- a/src/mint/taler-mint-httpd_reserve.c
+++ b/src/mint/taler-mint-httpd_reserve.c
@@ -136,6 +136,7 @@ TMH_RESERVE_handler_reserve_withdraw (struct TMH_RequestHandler *rh,
if (NULL == dki)
{
TMH_PARSE_release_data (spec);
+ TMH_KS_release (ks);
return TMH_RESPONSE_reply_arg_unknown (connection,
"denom_pub");
}