commit a17d68b21cac2e17f274c74020fd7b7c16fad8b6
parent 5a61d99315deb3aec66c6b342e66fea1b688defc
Author: William Casarin <jb55@jb55.com>
Date: Mon, 16 Dec 2024 16:43:38 -0800
monitor: lock monitor when we're freeing subscriptions
Signed-off-by: William Casarin <jb55@jb55.com>
Diffstat:
1 file changed, 8 insertions(+), 0 deletions(-)
diff --git a/src/nostrdb.c b/src/nostrdb.c
@@ -4821,9 +4821,17 @@ static void ndb_monitor_destroy(struct ndb_monitor *monitor)
{
int i;
+ ndb_monitor_lock(monitor);
+
for (i = 0; i < monitor->num_subscriptions; i++) {
ndb_subscription_destroy(&monitor->subscriptions[i]);
}
+
+ monitor->num_subscriptions = 0;
+
+ ndb_monitor_unlock(monitor);
+
+ pthread_mutex_destroy(&monitor->mutex);
}
int ndb_init(struct ndb **pndb, const char *filename, const struct ndb_config *config)