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/psyc/psyc_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/psyc/psyc_api.c')
-rw-r--r-- | src/psyc/psyc_api.c | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/src/psyc/psyc_api.c b/src/psyc/psyc_api.c index 2f6a15bab..8e960c7be 100644 --- a/src/psyc/psyc_api.c +++ b/src/psyc/psyc_api.c | |||
@@ -548,29 +548,17 @@ channel_cleanup (struct GNUNET_PSYC_Channel *chn) | |||
548 | GNUNET_MQ_discard (chn->connect_env); | 548 | GNUNET_MQ_discard (chn->connect_env); |
549 | chn->connect_env = NULL; | 549 | chn->connect_env = NULL; |
550 | } | 550 | } |
551 | if (NULL != chn->mq) | ||
552 | { | ||
553 | GNUNET_MQ_destroy (chn->mq); | ||
554 | chn->mq = NULL; | ||
555 | } | ||
551 | if (NULL != chn->disconnect_cb) | 556 | if (NULL != chn->disconnect_cb) |
552 | { | 557 | { |
553 | chn->disconnect_cb (chn->disconnect_cls); | 558 | chn->disconnect_cb (chn->disconnect_cls); |
554 | chn->disconnect_cb = NULL; | 559 | chn->disconnect_cb = NULL; |
555 | } | 560 | } |
556 | } | 561 | GNUNET_free (chn); |
557 | |||
558 | |||
559 | static void | ||
560 | master_cleanup (void *cls) | ||
561 | { | ||
562 | struct GNUNET_PSYC_Master *mst = cls; | ||
563 | channel_cleanup (&mst->chn); | ||
564 | GNUNET_free (mst); | ||
565 | } | ||
566 | |||
567 | |||
568 | static void | ||
569 | slave_cleanup (void *cls) | ||
570 | { | ||
571 | struct GNUNET_PSYC_Slave *slv = cls; | ||
572 | channel_cleanup (&slv->chn); | ||
573 | GNUNET_free (slv); | ||
574 | } | 562 | } |
575 | 563 | ||
576 | 564 | ||
@@ -583,11 +571,22 @@ channel_disconnect (struct GNUNET_PSYC_Channel *chn, | |||
583 | chn->disconnect_cb = cb; | 571 | chn->disconnect_cb = cb; |
584 | chn->disconnect_cls = cls; | 572 | chn->disconnect_cls = cls; |
585 | 573 | ||
586 | // FIXME: wait till queued messages are sent | ||
587 | if (NULL != chn->mq) | 574 | if (NULL != chn->mq) |
588 | { | 575 | { |
589 | GNUNET_MQ_destroy (chn->mq); | 576 | struct GNUNET_MQ_Envelope *last = GNUNET_MQ_get_last_envelope (chn->mq); |
590 | chn->mq = NULL; | 577 | if (NULL != last) |
578 | { | ||
579 | GNUNET_MQ_notify_sent (last, | ||
580 | (GNUNET_MQ_NotifyCallback) channel_cleanup, chn); | ||
581 | } | ||
582 | else | ||
583 | { | ||
584 | channel_cleanup (chn); | ||
585 | } | ||
586 | } | ||
587 | else | ||
588 | { | ||
589 | channel_cleanup (chn); | ||
591 | } | 590 | } |
592 | } | 591 | } |
593 | 592 | ||
@@ -772,7 +771,6 @@ GNUNET_PSYC_master_stop (struct GNUNET_PSYC_Master *mst, | |||
772 | /* FIXME: send msg to service */ | 771 | /* FIXME: send msg to service */ |
773 | 772 | ||
774 | channel_disconnect (chn, stop_cb, stop_cls); | 773 | channel_disconnect (chn, stop_cb, stop_cls); |
775 | master_cleanup (mst); | ||
776 | } | 774 | } |
777 | 775 | ||
778 | 776 | ||
@@ -1107,7 +1105,6 @@ GNUNET_PSYC_slave_part (struct GNUNET_PSYC_Slave *slv, | |||
1107 | /* FIXME: send msg to service */ | 1105 | /* FIXME: send msg to service */ |
1108 | 1106 | ||
1109 | channel_disconnect (chn, part_cb, part_cls); | 1107 | channel_disconnect (chn, part_cb, part_cls); |
1110 | slave_cleanup (slv); | ||
1111 | } | 1108 | } |
1112 | 1109 | ||
1113 | 1110 | ||