diff options
author | Christian Grothoff <christian@grothoff.org> | 2022-01-16 18:34:17 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2022-02-19 12:41:01 +0100 |
commit | 7236e5f83a621ab972f9ae6eda5b9562aba3217b (patch) | |
tree | 282ac568f3b1affc919804098536eb39f023f5bd /src | |
parent | 8ca9b2754d10419c9d8c041549d5747ec482b83a (diff) | |
download | gnunet-7236e5f83a621ab972f9ae6eda5b9562aba3217b.tar.gz gnunet-7236e5f83a621ab972f9ae6eda5b9562aba3217b.zip |
-fix crashes on new DHT load/shutdown
Diffstat (limited to 'src')
-rw-r--r-- | src/dht/gnunet-service-dht.c | 30 | ||||
-rw-r--r-- | src/dhtu/Makefile.am | 4 | ||||
-rw-r--r-- | src/dhtu/dhtu.conf | 5 | ||||
-rw-r--r-- | src/dhtu/plugin_dhtu_gnunet.c | 2 | ||||
-rw-r--r-- | src/util/plugin.c | 4 |
5 files changed, 39 insertions, 6 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, | |||
356 | static void | 361 | static void |
357 | shutdown_task (void *cls) | 362 | shutdown_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); |
diff --git a/src/dhtu/Makefile.am b/src/dhtu/Makefile.am index 0e10721cd..69b72db6e 100644 --- a/src/dhtu/Makefile.am +++ b/src/dhtu/Makefile.am | |||
@@ -10,6 +10,10 @@ if USE_COVERAGE | |||
10 | XLIBS = -lgcov | 10 | XLIBS = -lgcov |
11 | endif | 11 | endif |
12 | 12 | ||
13 | pkgcfg_DATA = \ | ||
14 | dhtu.conf | ||
15 | |||
16 | |||
13 | plugin_LTLIBRARIES = \ | 17 | plugin_LTLIBRARIES = \ |
14 | libgnunet_plugin_dhtu_gnunet.la \ | 18 | libgnunet_plugin_dhtu_gnunet.la \ |
15 | libgnunet_plugin_dhtu_ip.la | 19 | libgnunet_plugin_dhtu_ip.la |
diff --git a/src/dhtu/dhtu.conf b/src/dhtu/dhtu.conf new file mode 100644 index 000000000..438cd0955 --- /dev/null +++ b/src/dhtu/dhtu.conf | |||
@@ -0,0 +1,5 @@ | |||
1 | [dhtu-gnunet] | ||
2 | ENABLED = YES | ||
3 | |||
4 | [dhtu-ip] | ||
5 | ENABLED = NO | ||
diff --git a/src/dhtu/plugin_dhtu_gnunet.c b/src/dhtu/plugin_dhtu_gnunet.c index 14e16470c..493fd5119 100644 --- a/src/dhtu/plugin_dhtu_gnunet.c +++ b/src/dhtu/plugin_dhtu_gnunet.c | |||
@@ -590,7 +590,7 @@ libgnunet_plugin_dhtu_gnunet_done (void *cls) | |||
590 | * @return the plugin's API | 590 | * @return the plugin's API |
591 | */ | 591 | */ |
592 | void * | 592 | void * |
593 | libgnunet_plugin_dhtu_ip_init (void *cls) | 593 | libgnunet_plugin_dhtu_gnunet_init (void *cls) |
594 | { | 594 | { |
595 | struct GNUNET_DHTU_PluginEnvironment *env = cls; | 595 | struct GNUNET_DHTU_PluginEnvironment *env = cls; |
596 | struct GNUNET_DHTU_PluginFunctions *api; | 596 | struct GNUNET_DHTU_PluginFunctions *api; |
diff --git a/src/util/plugin.c b/src/util/plugin.c index 39874a588..6ee41eec9 100644 --- a/src/util/plugin.c +++ b/src/util/plugin.c | |||
@@ -289,12 +289,12 @@ GNUNET_PLUGIN_unload (const char *library_name, | |||
289 | done = resolve_function (pos, | 289 | done = resolve_function (pos, |
290 | "done"); | 290 | "done"); |
291 | ret = NULL; | 291 | ret = NULL; |
292 | if (NULL != done) | ||
293 | ret = done (arg); | ||
294 | if (NULL == prev) | 292 | if (NULL == prev) |
295 | plugins = pos->next; | 293 | plugins = pos->next; |
296 | else | 294 | else |
297 | prev->next = pos->next; | 295 | prev->next = pos->next; |
296 | if (NULL != done) | ||
297 | ret = done (arg); | ||
298 | lt_dlclose (pos->handle); | 298 | lt_dlclose (pos->handle); |
299 | GNUNET_free (pos->name); | 299 | GNUNET_free (pos->name); |
300 | GNUNET_free (pos); | 300 | GNUNET_free (pos); |