From 5e5c582c8338b9e231ea9c2f70d5bc83bd531496 Mon Sep 17 00:00:00 2001 From: jospaeth Date: Fri, 4 Sep 2020 20:02:39 +0200 Subject: don't maintain a plugin's ego list when cleaning up --- src/escrow/escrow.h | 5 +++++ src/escrow/escrow_plugin_helper.c | 10 +++++++--- src/escrow/plugin_escrow_anastasis.c | 2 ++ src/escrow/plugin_escrow_gns.c | 2 ++ src/escrow/plugin_escrow_plaintext.c | 2 ++ 5 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/escrow/escrow.h b/src/escrow/escrow.h index 1f5257970..a9e6e99e1 100644 --- a/src/escrow/escrow.h +++ b/src/escrow/escrow.h @@ -41,6 +41,11 @@ */ #define ESCROW_PLUGIN_STATE_POST_INIT 1 +/** + * State while cleaning up + */ +#define ESCROW_PLUGIN_STATE_CLEANUP 2 + /** * The ego list diff --git a/src/escrow/escrow_plugin_helper.c b/src/escrow/escrow_plugin_helper.c index f5f67d4bf..25648dfa1 100644 --- a/src/escrow/escrow_plugin_helper.c +++ b/src/escrow/escrow_plugin_helper.c @@ -75,7 +75,10 @@ ESCROW_list_ego (void *cls, struct EgoEntry *ego_entry; struct GNUNET_CRYPTO_EcdsaPublicKey pk; - // TODO: error when this method is called at cleanup if init is not yet finished + /* don't add/change/delete egos when we are already cleaning up */ + if (ESCROW_PLUGIN_STATE_CLEANUP == ph->state) + return; + if ((NULL == ego) && (ESCROW_PLUGIN_STATE_INIT == ph->state)) { ph->state = ESCROW_PLUGIN_STATE_POST_INIT; @@ -109,8 +112,9 @@ ESCROW_list_ego (void *cls, GNUNET_free (ego_entry->identifier); ego_entry->identifier = GNUNET_strdup (identifier); /* TODO: this handles an edge case when the user restores an ego - that already exists. In that case, @param ego is the same for the - new as for the existing ego and this method thinks it is a rename. */ + that already exists, i.e. with the same private key. In that case, + @param ego is the same for the new as for the existing ego and this + method thinks it is a rename. */ if (NULL != ph->ego_create_cont) ph->ego_create_cont (ego); break; diff --git a/src/escrow/plugin_escrow_anastasis.c b/src/escrow/plugin_escrow_anastasis.c index 5353b435a..8a5c05e24 100644 --- a/src/escrow/plugin_escrow_anastasis.c +++ b/src/escrow/plugin_escrow_anastasis.c @@ -218,6 +218,8 @@ libgnunet_plugin_escrow_anastasis_done (void *cls) { struct GNUNET_ESCROW_KeyPluginFunctions *api = cls; + ph.state = ESCROW_PLUGIN_STATE_CLEANUP; + GNUNET_free (api); GNUNET_IDENTITY_disconnect (identity_handle); ESCROW_cleanup_ego_list (&ph); diff --git a/src/escrow/plugin_escrow_gns.c b/src/escrow/plugin_escrow_gns.c index 422a3849e..2d419caaf 100644 --- a/src/escrow/plugin_escrow_gns.c +++ b/src/escrow/plugin_escrow_gns.c @@ -1729,6 +1729,8 @@ libgnunet_plugin_escrow_gns_done (void *cls) { struct GNUNET_ESCROW_KeyPluginFunctions *api = cls; + ph.state = ESCROW_PLUGIN_STATE_CLEANUP; + GNUNET_free (api); GNUNET_IDENTITY_disconnect (identity_handle); ESCROW_cleanup_ego_list (&ph); diff --git a/src/escrow/plugin_escrow_plaintext.c b/src/escrow/plugin_escrow_plaintext.c index 8e2c2204b..36c275a6b 100644 --- a/src/escrow/plugin_escrow_plaintext.c +++ b/src/escrow/plugin_escrow_plaintext.c @@ -540,6 +540,8 @@ libgnunet_plugin_escrow_plaintext_done (void *cls) { struct GNUNET_ESCROW_KeyPluginFunctions *api = cls; + ph.state = ESCROW_PLUGIN_STATE_CLEANUP; + GNUNET_free (api); GNUNET_IDENTITY_disconnect (identity_handle); ESCROW_cleanup_ego_list (&ph); -- cgit v1.2.3