diff options
author | Gabor X Toth <*@tg-x.net> | 2016-08-17 22:28:52 +0000 |
---|---|---|
committer | Gabor X Toth <*@tg-x.net> | 2016-08-17 22:28:52 +0000 |
commit | d226c5f08990628851ac0b61894727e3817f8ad7 (patch) | |
tree | 7dec7dd7500d38f7a83287ca1b6427557467d2bf /src/multicast/multicast_api.c | |
parent | 4f51ef196f6dff91fd83085462fd9c4624f7296b (diff) | |
download | gnunet-d226c5f08990628851ac0b61894727e3817f8ad7.tar.gz gnunet-d226c5f08990628851ac0b61894727e3817f8ad7.zip |
multicast, psyc, social: wait till last message sent before disconnect
Diffstat (limited to 'src/multicast/multicast_api.c')
-rw-r--r-- | src/multicast/multicast_api.c | 74 |
1 files changed, 39 insertions, 35 deletions
diff --git a/src/multicast/multicast_api.c b/src/multicast/multicast_api.c index 89a9bf5e1..ad9929dca 100644 --- a/src/multicast/multicast_api.c +++ b/src/multicast/multicast_api.c | |||
@@ -522,27 +522,51 @@ handle_member_join_decision (void *cls, | |||
522 | static void | 522 | static void |
523 | group_cleanup (struct GNUNET_MULTICAST_Group *grp) | 523 | group_cleanup (struct GNUNET_MULTICAST_Group *grp) |
524 | { | 524 | { |
525 | GNUNET_MQ_discard (grp->connect_env); | 525 | if (NULL != grp->connect_env) |
526 | { | ||
527 | GNUNET_MQ_discard (grp->connect_env); | ||
528 | grp->connect_env = NULL; | ||
529 | } | ||
530 | if (NULL != grp->mq) | ||
531 | { | ||
532 | GNUNET_MQ_destroy (grp->mq); | ||
533 | grp->mq = NULL; | ||
534 | } | ||
526 | if (NULL != grp->disconnect_cb) | 535 | if (NULL != grp->disconnect_cb) |
536 | { | ||
527 | grp->disconnect_cb (grp->disconnect_cls); | 537 | grp->disconnect_cb (grp->disconnect_cls); |
538 | grp->disconnect_cb = NULL; | ||
539 | } | ||
540 | GNUNET_free (grp); | ||
528 | } | 541 | } |
529 | 542 | ||
530 | 543 | ||
531 | static void | 544 | static void |
532 | origin_cleanup (void *cls) | 545 | group_disconnect (struct GNUNET_MULTICAST_Group *grp, |
546 | GNUNET_ContinuationCallback cb, | ||
547 | void *cls) | ||
533 | { | 548 | { |
534 | struct GNUNET_MULTICAST_Origin *orig = cls; | 549 | grp->is_disconnecting = GNUNET_YES; |
535 | group_cleanup (&orig->grp); | 550 | grp->disconnect_cb = cb; |
536 | GNUNET_free (orig); | 551 | grp->disconnect_cls = cls; |
537 | } | ||
538 | |||
539 | 552 | ||
540 | static void | 553 | if (NULL != grp->mq) |
541 | member_cleanup (void *cls) | 554 | { |
542 | { | 555 | struct GNUNET_MQ_Envelope *last = GNUNET_MQ_get_last_envelope (grp->mq); |
543 | struct GNUNET_MULTICAST_Member *mem = cls; | 556 | if (NULL != last) |
544 | group_cleanup (&mem->grp); | 557 | { |
545 | GNUNET_free (mem); | 558 | GNUNET_MQ_notify_sent (last, |
559 | (GNUNET_MQ_NotifyCallback) group_cleanup, grp); | ||
560 | } | ||
561 | else | ||
562 | { | ||
563 | group_cleanup (grp); | ||
564 | } | ||
565 | } | ||
566 | else | ||
567 | { | ||
568 | group_cleanup (grp); | ||
569 | } | ||
546 | } | 570 | } |
547 | 571 | ||
548 | 572 | ||
@@ -861,17 +885,7 @@ GNUNET_MULTICAST_origin_stop (struct GNUNET_MULTICAST_Origin *orig, | |||
861 | { | 885 | { |
862 | struct GNUNET_MULTICAST_Group *grp = &orig->grp; | 886 | struct GNUNET_MULTICAST_Group *grp = &orig->grp; |
863 | 887 | ||
864 | grp->is_disconnecting = GNUNET_YES; | 888 | group_disconnect (grp, stop_cb, stop_cls); |
865 | grp->disconnect_cb = stop_cb; | ||
866 | grp->disconnect_cls = stop_cls; | ||
867 | |||
868 | // FIXME: wait till queued messages are sent | ||
869 | if (NULL != grp->mq) | ||
870 | { | ||
871 | GNUNET_MQ_destroy (grp->mq); | ||
872 | grp->mq = NULL; | ||
873 | } | ||
874 | origin_cleanup (orig); | ||
875 | } | 889 | } |
876 | 890 | ||
877 | 891 | ||
@@ -1198,23 +1212,13 @@ GNUNET_MULTICAST_member_part (struct GNUNET_MULTICAST_Member *mem, | |||
1198 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%p Member parting.\n", mem); | 1212 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%p Member parting.\n", mem); |
1199 | struct GNUNET_MULTICAST_Group *grp = &mem->grp; | 1213 | struct GNUNET_MULTICAST_Group *grp = &mem->grp; |
1200 | 1214 | ||
1201 | grp->is_disconnecting = GNUNET_YES; | ||
1202 | grp->disconnect_cb = part_cb; | ||
1203 | grp->disconnect_cls = part_cls; | ||
1204 | |||
1205 | mem->join_dcsn_cb = NULL; | 1215 | mem->join_dcsn_cb = NULL; |
1206 | grp->join_req_cb = NULL; | 1216 | grp->join_req_cb = NULL; |
1207 | grp->message_cb = NULL; | 1217 | grp->message_cb = NULL; |
1208 | grp->replay_msg_cb = NULL; | 1218 | grp->replay_msg_cb = NULL; |
1209 | grp->replay_frag_cb = NULL; | 1219 | grp->replay_frag_cb = NULL; |
1210 | 1220 | ||
1211 | // FIXME: wait till queued messages are sent | 1221 | group_disconnect (grp, part_cb, part_cls); |
1212 | if (NULL != grp->mq) | ||
1213 | { | ||
1214 | GNUNET_MQ_destroy (grp->mq); | ||
1215 | grp->mq = NULL; | ||
1216 | } | ||
1217 | member_cleanup (mem); | ||
1218 | } | 1222 | } |
1219 | 1223 | ||
1220 | 1224 | ||