finalize protocol change (fixes message loss when leaving a place)
authorlurchi <lurchi@strangeplace.net>
Mon, 13 Nov 2017 17:21:14 +0000 (18:21 +0100)
committerlurchi <lurchi@strangeplace.net>
Mon, 13 Nov 2017 17:21:14 +0000 (18:21 +0100)
src/social/social_api.c

index 8c6629432064a40819332fd4955533826c32719c..87b46821e2c9486bc7739981203ae55e11c390aa 100644 (file)
@@ -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);
 }