From: lurchi Date: Mon, 13 Nov 2017 17:21:14 +0000 (+0100) Subject: finalize protocol change (fixes message loss when leaving a place) X-Git-Tag: gnunet-0.11.0rc0~48^2~1^2~29 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=5d2fadf532f771a93f0c3873b5b47b73a0652b96;p=oweals%2Fgnunet.git finalize protocol change (fixes message loss when leaving a place) --- diff --git a/src/social/social_api.c b/src/social/social_api.c index 8c6629432..87b46821e 100644 --- a/src/social/social_api.c +++ b/src/social/social_api.c @@ -1598,32 +1598,6 @@ GNUNET_SOCIAL_host_disconnect (struct GNUNET_SOCIAL_Host *hst, } -/** - * Closure for #host_leave_cont. - */ -struct HostLeaveContext -{ - struct GNUNET_SOCIAL_Host *hst; - GNUNET_ContinuationCallback disconnect_cb; - void *disconnect_cb_cls; -}; - - -/** - * FIXME. - */ -static void -host_leave_cont (void *cls) -{ - struct HostLeaveContext *hlc = cls; - - GNUNET_SOCIAL_host_disconnect (hlc->hst, - hlc->disconnect_cb, - hlc->disconnect_cb_cls); - GNUNET_free (hlc); -} - - /** * Stop hosting the home. * @@ -1649,21 +1623,15 @@ GNUNET_SOCIAL_host_leave (struct GNUNET_SOCIAL_Host *hst, { struct GNUNET_MessageHeader *msg; struct GNUNET_MQ_Envelope *envelope; - struct HostLeaveContext *hlc; GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "GNUNET_SOCIAL_host_leave\n"); GNUNET_SOCIAL_host_announce (hst, "_notice_place_closing", env, NULL, NULL, GNUNET_SOCIAL_ANNOUNCE_NONE); + hst->plc.disconnect_cb = disconnect_cb; + hst->plc.disconnect_cls = cls; envelope = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE); - hlc = GNUNET_new (struct HostLeaveContext); - hlc->hst = hst; - hlc->disconnect_cb = disconnect_cb; - hlc->disconnect_cb_cls = cls; - GNUNET_MQ_notify_sent (envelope, - &host_leave_cont, - hlc); GNUNET_MQ_send (hst->plc.mq, envelope); } @@ -2100,37 +2068,6 @@ GNUNET_SOCIAL_guest_disconnect (struct GNUNET_SOCIAL_Guest *gst, } -/** - * Closure for #leave_done_cont. - */ -struct LeaveContext -{ - struct GNUNET_SOCIAL_Guest *gst; - GNUNET_ContinuationCallback disconnect_cb; - void *disconnect_cb_cls; -}; - - -/** - * The leave message was transmitted, now complete the - * disconnection process. - * - * @param cls a `struct LeaveContext` - */ -static void -leave_done_cont (void *cls) -{ - struct LeaveContext *lc = cls; - - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "social_api: guest's place_leave message sent!\n"); - GNUNET_SOCIAL_guest_disconnect (lc->gst, - lc->disconnect_cb, - lc->disconnect_cb_cls); - GNUNET_free (lc); -} - - /** * Leave a place temporarily or permanently. * @@ -2155,7 +2092,6 @@ GNUNET_SOCIAL_guest_leave (struct GNUNET_SOCIAL_Guest *gst, { struct GNUNET_MessageHeader *msg; struct GNUNET_MQ_Envelope *envelope; - struct LeaveContext *lc; GNUNET_SOCIAL_guest_talk (gst, "_notice_place_leave", env, NULL, NULL, GNUNET_SOCIAL_TALK_NONE); @@ -2163,15 +2099,10 @@ GNUNET_SOCIAL_guest_leave (struct GNUNET_SOCIAL_Guest *gst, GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "social_api: place_leave\n"); + gst->plc.disconnect_cb = disconnect_cb; + gst->plc.disconnect_cls = cls; envelope = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE); - lc = GNUNET_new (struct LeaveContext); - lc->gst = gst; - lc->disconnect_cb = disconnect_cb; - lc->disconnect_cb_cls = cls; - GNUNET_MQ_notify_sent (envelope, - &leave_done_cont, - lc); GNUNET_MQ_send (gst->plc.mq, envelope); }