diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-11-24 14:12:09 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-11-24 14:12:09 +0000 |
commit | ee9b6d883dfab70149543c96f8d950374429876a (patch) | |
tree | 8bc3698abb62f33cb87da765b91f6e3832e32a2c /src/set | |
parent | 30a574dc8b01e16a6b70e384a8c4fe05a6ffd861 (diff) | |
download | gnunet-ee9b6d883dfab70149543c96f8d950374429876a.tar.gz gnunet-ee9b6d883dfab70149543c96f8d950374429876a.zip |
-inline
Diffstat (limited to 'src/set')
-rw-r--r-- | src/set/gnunet-service-set.c | 48 |
1 files changed, 21 insertions, 27 deletions
diff --git a/src/set/gnunet-service-set.c b/src/set/gnunet-service-set.c index 31676ba3a..db377bfcf 100644 --- a/src/set/gnunet-service-set.c +++ b/src/set/gnunet-service-set.c | |||
@@ -437,15 +437,17 @@ set_destroy (struct Set *set) | |||
437 | GNUNET_CONTAINER_multihashmap_iterator_destroy (set->iter); | 437 | GNUNET_CONTAINER_multihashmap_iterator_destroy (set->iter); |
438 | set->iter = NULL; | 438 | set->iter = NULL; |
439 | } | 439 | } |
440 | GNUNET_CONTAINER_DLL_remove (sets_head, sets_tail, set); | ||
441 | if (NULL != set->elements) | 440 | if (NULL != set->elements) |
442 | { | 441 | { |
443 | // free all elements in the hashtable, before destroying the table | ||
444 | GNUNET_CONTAINER_multihashmap_iterate (set->elements, | 442 | GNUNET_CONTAINER_multihashmap_iterate (set->elements, |
445 | destroy_elements_iterator, NULL); | 443 | &destroy_elements_iterator, |
444 | NULL); | ||
446 | GNUNET_CONTAINER_multihashmap_destroy (set->elements); | 445 | GNUNET_CONTAINER_multihashmap_destroy (set->elements); |
447 | set->elements = NULL; | 446 | set->elements = NULL; |
448 | } | 447 | } |
448 | GNUNET_CONTAINER_DLL_remove (sets_head, | ||
449 | sets_tail, | ||
450 | set); | ||
449 | GNUNET_free (set); | 451 | GNUNET_free (set); |
450 | } | 452 | } |
451 | 453 | ||
@@ -457,7 +459,8 @@ set_destroy (struct Set *set) | |||
457 | * @param client the client to clean up after | 459 | * @param client the client to clean up after |
458 | */ | 460 | */ |
459 | static void | 461 | static void |
460 | handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) | 462 | handle_client_disconnect (void *cls, |
463 | struct GNUNET_SERVER_Client *client) | ||
461 | { | 464 | { |
462 | struct Set *set; | 465 | struct Set *set; |
463 | struct Listener *listener; | 466 | struct Listener *listener; |
@@ -470,7 +473,7 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) | |||
470 | set->client = NULL; | 473 | set->client = NULL; |
471 | set_destroy (set); | 474 | set_destroy (set); |
472 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 475 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
473 | "(client's set destroyed)\n"); | 476 | "Client's set destroyed\n"); |
474 | } | 477 | } |
475 | listener = listener_get (client); | 478 | listener = listener_get (client); |
476 | if (NULL != listener) | 479 | if (NULL != listener) |
@@ -478,7 +481,7 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) | |||
478 | listener->client = NULL; | 481 | listener->client = NULL; |
479 | listener_destroy (listener); | 482 | listener_destroy (listener); |
480 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 483 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
481 | "(client's listener destroyed)\n"); | 484 | "Client's listener destroyed\n"); |
482 | } | 485 | } |
483 | } | 486 | } |
484 | 487 | ||
@@ -492,7 +495,9 @@ static void | |||
492 | incoming_destroy (struct Operation *incoming) | 495 | incoming_destroy (struct Operation *incoming) |
493 | { | 496 | { |
494 | GNUNET_assert (GNUNET_YES == incoming->is_incoming); | 497 | GNUNET_assert (GNUNET_YES == incoming->is_incoming); |
495 | GNUNET_CONTAINER_DLL_remove (incoming_head, incoming_tail, incoming); | 498 | GNUNET_CONTAINER_DLL_remove (incoming_head, |
499 | incoming_tail, | ||
500 | incoming); | ||
496 | if (GNUNET_SCHEDULER_NO_TASK != incoming->state->timeout_task) | 501 | if (GNUNET_SCHEDULER_NO_TASK != incoming->state->timeout_task) |
497 | { | 502 | { |
498 | GNUNET_SCHEDULER_cancel (incoming->state->timeout_task); | 503 | GNUNET_SCHEDULER_cancel (incoming->state->timeout_task); |
@@ -500,8 +505,7 @@ incoming_destroy (struct Operation *incoming) | |||
500 | } | 505 | } |
501 | GNUNET_assert (NULL != incoming->state); | 506 | GNUNET_assert (NULL != incoming->state); |
502 | GNUNET_free (incoming->state); | 507 | GNUNET_free (incoming->state); |
503 | // make sure that the tunnel end handler will not | 508 | /* make sure that the tunnel end handler will not destroy us again */ |
504 | // destroy us again | ||
505 | incoming->vt = NULL; | 509 | incoming->vt = NULL; |
506 | incoming->state = NULL; | 510 | incoming->state = NULL; |
507 | if (NULL != incoming->mq) | 511 | if (NULL != incoming->mq) |
@@ -518,23 +522,6 @@ incoming_destroy (struct Operation *incoming) | |||
518 | 522 | ||
519 | 523 | ||
520 | /** | 524 | /** |
521 | * remove & free state of the operation from the incoming list | ||
522 | * | ||
523 | * @param incoming the element to remove | ||
524 | */ | ||
525 | static void | ||
526 | incoming_retire (struct Operation *incoming) | ||
527 | { | ||
528 | GNUNET_assert (GNUNET_YES == incoming->is_incoming); | ||
529 | incoming->is_incoming = GNUNET_NO; | ||
530 | GNUNET_assert (NULL != incoming->state); | ||
531 | GNUNET_free (incoming->state); | ||
532 | incoming->state = NULL; | ||
533 | GNUNET_CONTAINER_DLL_remove (incoming_head, incoming_tail, incoming); | ||
534 | } | ||
535 | |||
536 | |||
537 | /** | ||
538 | * Find a listener that is interested in the given operation type | 525 | * Find a listener that is interested in the given operation type |
539 | * and application id. | 526 | * and application id. |
540 | * | 527 | * |
@@ -1186,7 +1173,14 @@ handle_client_accept (void *cls, | |||
1186 | 1173 | ||
1187 | op->spec->set = set; | 1174 | op->spec->set = set; |
1188 | 1175 | ||
1189 | incoming_retire (op); | 1176 | GNUNET_assert (GNUNET_YES == op->is_incoming); |
1177 | op->is_incoming = GNUNET_NO; | ||
1178 | GNUNET_assert (NULL != op->state); | ||
1179 | GNUNET_free (op->state); | ||
1180 | op->state = NULL; | ||
1181 | GNUNET_CONTAINER_DLL_remove (incoming_head, | ||
1182 | incoming_tail, | ||
1183 | op); | ||
1190 | 1184 | ||
1191 | GNUNET_assert (NULL != op->spec->set); | 1185 | GNUNET_assert (NULL != op->spec->set); |
1192 | GNUNET_assert (NULL != op->spec->set->vt); | 1186 | GNUNET_assert (NULL != op->spec->set->vt); |