summaryrefslogtreecommitdiff
path: root/src/exchange/taler-exchange-httpd_keys.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-08-23 23:35:24 +0200
committerChristian Grothoff <christian@grothoff.org>2021-08-23 23:35:24 +0200
commit888895cb8c607de52966ac24545078e452432a96 (patch)
tree87be7374fe81f14c47aa02c9c55d71927043be2b /src/exchange/taler-exchange-httpd_keys.c
parentefbe04418e1699dcc1c3ab2d5e0df63710b92ecc (diff)
downloadexchange-888895cb8c607de52966ac24545078e452432a96.tar.gz
exchange-888895cb8c607de52966ac24545078e452432a96.tar.bz2
exchange-888895cb8c607de52966ac24545078e452432a96.zip
fix #6956 in exchangev0.8.4
Diffstat (limited to 'src/exchange/taler-exchange-httpd_keys.c')
-rw-r--r--src/exchange/taler-exchange-httpd_keys.c62
1 files changed, 60 insertions, 2 deletions
diff --git a/src/exchange/taler-exchange-httpd_keys.c b/src/exchange/taler-exchange-httpd_keys.c
index 3b5616345..5d25600c4 100644
--- a/src/exchange/taler-exchange-httpd_keys.c
+++ b/src/exchange/taler-exchange-httpd_keys.c
@@ -21,6 +21,7 @@
#include "platform.h"
#include "taler_json_lib.h"
#include "taler_mhd_lib.h"
+#include "taler_dbevents.h"
#include "taler-exchange-httpd.h"
#include "taler-exchange-httpd_keys.h"
#include "taler-exchange-httpd_responses.h"
@@ -350,6 +351,12 @@ static struct TEH_KeyStateHandle *key_state;
static uint64_t key_generation;
/**
+ * Handler listening for wire updates by other exchange
+ * services.
+ */
+static struct GNUNET_DB_EventHandler *keys_eh;
+
+/**
* Head of DLL of suspended /keys requests.
*/
static struct SuspendedKeysRequests *skr_head;
@@ -867,9 +874,35 @@ destroy_key_state (struct TEH_KeyStateHandle *ksh,
}
-int
+/**
+ * Function called whenever another exchange process has updated
+ * the keys data in the database.
+ *
+ * @param cls NULL
+ * @param extra unused
+ * @param extra_size number of bytes in @a extra unused
+ */
+static void
+keys_update_event_cb (void *cls,
+ const void *extra,
+ size_t extra_size)
+{
+ (void) cls;
+ (void) extra;
+ (void) extra_size;
+ key_generation++;
+ TEH_resume_keys_requests (false);
+}
+
+
+enum GNUNET_GenericReturnValue
TEH_keys_init ()
{
+ struct GNUNET_DB_EventHeaderP es = {
+ .size = htons (sizeof (es)),
+ .type = htons (TALER_DBEVENT_EXCHANGE_KEYS_UPDATED),
+ };
+
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_time (TEH_cfg,
"exchange",
@@ -881,6 +914,16 @@ TEH_keys_init ()
"SIGNKEY_LEGAL_DURATION");
return GNUNET_SYSERR;
}
+ keys_eh = TEH_plugin->event_listen (TEH_plugin->cls,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ &es,
+ &keys_update_event_cb,
+ NULL);
+ if (NULL == keys_eh)
+ {
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+ }
return GNUNET_OK;
}
@@ -888,12 +931,18 @@ TEH_keys_init ()
/**
* Fully clean up our state.
*/
-void __attribute__ ((destructor))
+void
TEH_keys_finished ()
{
if (NULL != key_state)
destroy_key_state (key_state,
true);
+ if (NULL != keys_eh)
+ {
+ TEH_plugin->event_listen_cancel (TEH_plugin->cls,
+ keys_eh);
+ keys_eh = NULL;
+ }
}
@@ -1719,6 +1768,15 @@ build_key_state (struct HelperState *hs,
void
TEH_keys_update_states ()
{
+ struct GNUNET_DB_EventHeaderP es = {
+ .size = htons (sizeof (es)),
+ .type = htons (TALER_DBEVENT_EXCHANGE_KEYS_UPDATED),
+ };
+
+ TEH_plugin->event_notify (TEH_plugin->cls,
+ &es,
+ NULL,
+ 0);
key_generation++;
TEH_resume_keys_requests (false);
}