aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-06-18 13:44:58 +0200
committerChristian Grothoff <christian@grothoff.org>2015-06-18 13:44:58 +0200
commitd15c654749c4195c66e4f8e46d2695c90ad7f8c2 (patch)
tree8f96ddc9e54ba8d629b17e90ee987404cbb29261
parent740d6cba04175f0227e633dff06f0232da31ac54 (diff)
fix locking issue, as the mutex we are using is not recursive we need to be a bit more careful
-rw-r--r--src/mint-lib/test_mint_api.c35
-rw-r--r--src/mint/taler-mint-httpd_keystate.c25
2 files changed, 41 insertions, 19 deletions
diff --git a/src/mint-lib/test_mint_api.c b/src/mint-lib/test_mint_api.c
index 8015d5c5a..2ea3be254 100644
--- a/src/mint-lib/test_mint_api.c
+++ b/src/mint-lib/test_mint_api.c
@@ -176,16 +176,14 @@ context_task (void *cls,
*/
static void
run (void *cls,
- char *const *args,
- const char *cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *config)
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
{
ctx = TALER_MINT_init ();
GNUNET_assert (NULL != ctx);
ctx_task = GNUNET_SCHEDULER_add_now (&context_task,
ctx);
mint = TALER_MINT_connect (ctx,
- "http://localhost:8080",
+ "http://localhost:8081",
&cert_cb, NULL,
TALER_MINT_OPTION_END);
GNUNET_assert (NULL != mint);
@@ -206,17 +204,26 @@ int
main (int argc,
char * const *argv)
{
- static struct GNUNET_GETOPT_CommandLineOption options[] = {
- GNUNET_GETOPT_OPTION_END
- };
-
+ struct GNUNET_OS_Process *mintd;
+
+ GNUNET_log_setup ("test-mint-api",
+ "WARNING",
+ NULL);
+ mintd = GNUNET_OS_start_process (GNUNET_NO,
+ GNUNET_OS_INHERIT_STD_ALL,
+ NULL, NULL, NULL,
+ "taler-mint-httpd",
+ "taler-mint-httpd",
+ "-d", "test-mint-home",
+ NULL);
+ sleep (1);
result = GNUNET_SYSERR;
- if (GNUNET_OK !=
- GNUNET_PROGRAM_run (argc, argv, "test-mint-api",
- gettext_noop ("Testcase to test mint's HTTP API interface"),
- options,
- &run, NULL))
- return 3;
+ GNUNET_SCHEDULER_run (&run, NULL);
+ sleep (60);
+ GNUNET_OS_process_kill (mintd,
+ SIGTERM);
+ GNUNET_OS_process_wait (mintd);
+ GNUNET_OS_process_destroy (mintd);
return (GNUNET_OK == result) ? 0 : 1;
}
diff --git a/src/mint/taler-mint-httpd_keystate.c b/src/mint/taler-mint-httpd_keystate.c
index 1d40b3103..2dc68390c 100644
--- a/src/mint/taler-mint-httpd_keystate.c
+++ b/src/mint/taler-mint-httpd_keystate.c
@@ -418,13 +418,13 @@ free_denom_key (void *cls,
/**
* Release key state, free if necessary (if reference count gets to zero).
+ * Internal method used when the mutex is already held.
*
* @param key_state the key state to release
*/
void
-TMH_KS_release (struct TMH_KS_StateHandle *key_state)
+TMH_KS_release_ (struct TMH_KS_StateHandle *key_state)
{
- GNUNET_assert (0 == pthread_mutex_lock (&internal_key_state_mutex));
GNUNET_assert (0 < key_state->refcnt);
key_state->refcnt--;
if (0 == key_state->refcnt)
@@ -438,6 +438,19 @@ TMH_KS_release (struct TMH_KS_StateHandle *key_state)
GNUNET_free (key_state->keys_json);
GNUNET_free (key_state);
}
+}
+
+
+/**
+ * Release key state, free if necessary (if reference count gets to zero).
+ *
+ * @param key_state the key state to release
+ */
+void
+TMH_KS_release (struct TMH_KS_StateHandle *key_state)
+{
+ GNUNET_assert (0 == pthread_mutex_lock (&internal_key_state_mutex));
+ TMH_KS_release_ (key_state);
GNUNET_assert (0 == pthread_mutex_unlock (&internal_key_state_mutex));
}
@@ -462,7 +475,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);
+ TMH_KS_release_ (internal_key_state);
internal_key_state = NULL;
}
if (NULL == internal_key_state)
@@ -488,8 +501,10 @@ TMH_KS_acquire (void)
GNUNET_CRYPTO_hash_context_finish (key_state->hash_context,
&ks.hc);
key_state->hash_context = NULL;
- TMH_KS_sign (&ks.purpose,
- &sig);
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_CRYPTO_eddsa_sign (&key_state->current_sign_key_issue.signkey_priv.eddsa_priv,
+ &ks.purpose,
+ &sig.eddsa_signature));
key_state->next_reload = GNUNET_TIME_absolute_ntoh (key_state->current_sign_key_issue.issue.expire);
if (0 == key_state->next_reload.abs_value_us)
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,