diff options
author | Christian Grothoff <christian@grothoff.org> | 2023-04-23 22:57:55 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2023-04-23 22:57:55 +0200 |
commit | 154f964aab5df00cbadaa015474c2b323161aa96 (patch) | |
tree | 084f300e664fb96d0693baf73434ed245ef56641 /src/backend/taler-merchant-wirewatch.c | |
parent | 889595f986d922ffbcdcd746fdfad7f1a0e53595 (diff) | |
download | merchant-154f964aab5df00cbadaa015474c2b323161aa96.tar.gz merchant-154f964aab5df00cbadaa015474c2b323161aa96.tar.bz2 merchant-154f964aab5df00cbadaa015474c2b323161aa96.zip |
API change for #6363
Diffstat (limited to 'src/backend/taler-merchant-wirewatch.c')
-rw-r--r-- | src/backend/taler-merchant-wirewatch.c | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/src/backend/taler-merchant-wirewatch.c b/src/backend/taler-merchant-wirewatch.c index 380bcc11..03e317b0 100644 --- a/src/backend/taler-merchant-wirewatch.c +++ b/src/backend/taler-merchant-wirewatch.c @@ -22,6 +22,7 @@ #include <gnunet/gnunet_util_lib.h> #include <jansson.h> #include <pthread.h> +#include <taler/taler_dbevents.h> #include "taler_merchant_bank_lib.h" #include "taler_merchantdb_lib.h" #include "taler_merchantdb_plugin.h" @@ -123,6 +124,12 @@ static struct GNUNET_CURL_Context *ctx; static struct GNUNET_CURL_RescheduleContext *rc; /** + * Event handler to learn that the configuration changed + * and we should shutdown (to be restarted). + */ +static struct GNUNET_DB_EventHandler *eh; + +/** * Value to return from main(). 0 on success, non-zero on errors. */ static int global_ret; @@ -209,6 +216,11 @@ shutdown_task (void *cls) save (w); end_watch (w); } + if (NULL != eh) + { + db_plugin->event_listen_cancel (eh); + eh = NULL; + } TALER_MERCHANTDB_plugin_unload (db_plugin); db_plugin = NULL; cfg = NULL; @@ -457,6 +469,26 @@ start_watch ( /** + * Function called on configuration change events received from Postgres. We + * shutdown (and systemd should restart us). + * + * @param cls closure (NULL) + * @param extra additional event data provided + * @param extra_size number of bytes in @a extra + */ +static void +config_changed (void *cls, + const void *extra, + size_t extra_size) +{ + (void) cls; + (void) extra; + (void) extra_size; + GNUNET_SCHEDULER_shutdown (); +} + + +/** * First task. * * @param cls closure, NULL @@ -501,7 +533,18 @@ run (void *cls, GNUNET_SCHEDULER_shutdown (); return; } - // FIXME: also add notification job! + { + struct GNUNET_DB_EventHeaderP es = { + .size = htons (sizeof (es)), + .type = htons (TALER_DBEVENT_MERCHANT_ACCOUNTS_CHANGED) + }; + + eh = db_plugin->event_listen (db_plugin->cls, + &es, + GNUNET_TIME_UNIT_FOREVER_REL, + &config_changed, + NULL); + } { enum GNUNET_DB_QueryStatus qs; |