aboutsummaryrefslogtreecommitdiff
path: root/src/dht
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-01-16 18:34:17 +0100
committerChristian Grothoff <christian@grothoff.org>2022-02-19 12:41:01 +0100
commit7236e5f83a621ab972f9ae6eda5b9562aba3217b (patch)
tree282ac568f3b1affc919804098536eb39f023f5bd /src/dht
parent8ca9b2754d10419c9d8c041549d5747ec482b83a (diff)
downloadgnunet-7236e5f83a621ab972f9ae6eda5b9562aba3217b.tar.gz
gnunet-7236e5f83a621ab972f9ae6eda5b9562aba3217b.zip
-fix crashes on new DHT load/shutdown
Diffstat (limited to 'src/dht')
-rw-r--r--src/dht/gnunet-service-dht.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c
index ae2ff6f7a..6ae56d427 100644
--- a/src/dht/gnunet-service-dht.c
+++ b/src/dht/gnunet-service-dht.c
@@ -78,6 +78,11 @@ struct GDS_Underlay
78 * Name of the underlay (i.e. "gnunet" or "ip"). 78 * Name of the underlay (i.e. "gnunet" or "ip").
79 */ 79 */
80 char *name; 80 char *name;
81
82 /**
83 * Name of the library providing the underlay.
84 */
85 char *libname;
81}; 86};
82 87
83 88
@@ -191,7 +196,7 @@ update_network_size_estimate (void *cls,
191 u->network_size_estimate = pow (2.0, 196 u->network_size_estimate = pow (2.0,
192 GNUNET_MAX (0.5, 197 GNUNET_MAX (0.5,
193 logestimate)); 198 logestimate));
194 for (struct GDS_Underlay *p; NULL != p; p = p->next) 199 for (struct GDS_Underlay *p = u_head; NULL != p; p = p->next)
195 sum += p->network_size_estimate; 200 sum += p->network_size_estimate;
196 if (sum <= 2.0) 201 if (sum <= 2.0)
197 log_of_network_size_estimate = 0.5; 202 log_of_network_size_estimate = 0.5;
@@ -356,6 +361,19 @@ GDS_u_hold (struct GDS_Underlay *u,
356static void 361static void
357shutdown_task (void *cls) 362shutdown_task (void *cls)
358{ 363{
364 struct GDS_Underlay *u;
365
366 while (NULL != (u = u_head))
367 {
368 GNUNET_PLUGIN_unload (u->libname,
369 u->dhtu);
370 GNUNET_CONTAINER_DLL_remove (u_head,
371 u_tail,
372 u);
373 GNUNET_free (u->name);
374 GNUNET_free (u->libname);
375 GNUNET_free (u);
376 }
359 GDS_NEIGHBOURS_done (); 377 GDS_NEIGHBOURS_done ();
360 GDS_DATACACHE_done (); 378 GDS_DATACACHE_done ();
361 GDS_ROUTING_done (); 379 GDS_ROUTING_done ();
@@ -370,8 +388,11 @@ shutdown_task (void *cls)
370 GNUNET_YES); 388 GNUNET_YES);
371 GDS_stats = NULL; 389 GDS_stats = NULL;
372 } 390 }
373 GNUNET_HELLO_builder_free (GDS_my_hello); 391 if (NULL != GDS_my_hello)
374 GDS_my_hello = NULL; 392 {
393 GNUNET_HELLO_builder_free (GDS_my_hello);
394 GDS_my_hello = NULL;
395 }
375 GDS_CLIENTS_stop (); 396 GDS_CLIENTS_stop ();
376} 397}
377 398
@@ -403,6 +424,7 @@ load_underlay (void *cls,
403 section += strlen ("dhtu-"); 424 section += strlen ("dhtu-");
404 u = GNUNET_new (struct GDS_Underlay); 425 u = GNUNET_new (struct GDS_Underlay);
405 u->env.cls = u; 426 u->env.cls = u;
427 u->env.cfg = GDS_cfg;
406 u->env.address_add_cb = &u_address_add; 428 u->env.address_add_cb = &u_address_add;
407 u->env.address_del_cb = &u_address_del; 429 u->env.address_del_cb = &u_address_del;
408 u->env.network_size_cb = &update_network_size_estimate; 430 u->env.network_size_cb = &update_network_size_estimate;
@@ -420,6 +442,7 @@ load_underlay (void *cls,
420 GNUNET_free (u); 442 GNUNET_free (u);
421 return; 443 return;
422 } 444 }
445 u->libname = libname;
423 u->name = GNUNET_strdup (section); 446 u->name = GNUNET_strdup (section);
424 GNUNET_CONTAINER_DLL_insert (u_head, 447 GNUNET_CONTAINER_DLL_insert (u_head,
425 u_tail, 448 u_tail,
@@ -471,6 +494,7 @@ run (void *cls,
471 } 494 }
472 GNUNET_CRYPTO_eddsa_key_get_public (&GDS_my_private_key, 495 GNUNET_CRYPTO_eddsa_key_get_public (&GDS_my_private_key,
473 &GDS_my_identity.public_key); 496 &GDS_my_identity.public_key);
497 GDS_my_hello = GNUNET_HELLO_builder_new (&GDS_my_identity);
474 GNUNET_CRYPTO_hash (&GDS_my_identity, 498 GNUNET_CRYPTO_hash (&GDS_my_identity,
475 sizeof(struct GNUNET_PeerIdentity), 499 sizeof(struct GNUNET_PeerIdentity),
476 &GDS_my_identity_hash); 500 &GDS_my_identity_hash);