diff options
author | lurchi <lurchi@strangeplace.net> | 2017-11-13 18:21:14 +0100 |
---|---|---|
committer | lurchi <lurchi@strangeplace.net> | 2017-11-13 18:21:14 +0100 |
commit | 5d2fadf532f771a93f0c3873b5b47b73a0652b96 (patch) | |
tree | 309130637f77a4fe746f37b7af0bf416b14afe0f /src/social | |
parent | 2b9f858b1e38d80cc3f4c3fd48fba22e7a7e52a9 (diff) | |
download | gnunet-5d2fadf532f771a93f0c3873b5b47b73a0652b96.tar.gz gnunet-5d2fadf532f771a93f0c3873b5b47b73a0652b96.zip |
finalize protocol change (fixes message loss when leaving a place)
Diffstat (limited to 'src/social')
-rw-r--r-- | src/social/social_api.c | 77 |
1 files changed, 4 insertions, 73 deletions
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 | |||
@@ -1599,32 +1599,6 @@ GNUNET_SOCIAL_host_disconnect (struct GNUNET_SOCIAL_Host *hst, | |||
1599 | 1599 | ||
1600 | 1600 | ||
1601 | /** | 1601 | /** |
1602 | * Closure for #host_leave_cont. | ||
1603 | */ | ||
1604 | struct HostLeaveContext | ||
1605 | { | ||
1606 | struct GNUNET_SOCIAL_Host *hst; | ||
1607 | GNUNET_ContinuationCallback disconnect_cb; | ||
1608 | void *disconnect_cb_cls; | ||
1609 | }; | ||
1610 | |||
1611 | |||
1612 | /** | ||
1613 | * FIXME. | ||
1614 | */ | ||
1615 | static void | ||
1616 | host_leave_cont (void *cls) | ||
1617 | { | ||
1618 | struct HostLeaveContext *hlc = cls; | ||
1619 | |||
1620 | GNUNET_SOCIAL_host_disconnect (hlc->hst, | ||
1621 | hlc->disconnect_cb, | ||
1622 | hlc->disconnect_cb_cls); | ||
1623 | GNUNET_free (hlc); | ||
1624 | } | ||
1625 | |||
1626 | |||
1627 | /** | ||
1628 | * Stop hosting the home. | 1602 | * Stop hosting the home. |
1629 | * | 1603 | * |
1630 | * Sends a _notice_place_closing announcement to the home. | 1604 | * Sends a _notice_place_closing announcement to the home. |
@@ -1649,21 +1623,15 @@ GNUNET_SOCIAL_host_leave (struct GNUNET_SOCIAL_Host *hst, | |||
1649 | { | 1623 | { |
1650 | struct GNUNET_MessageHeader *msg; | 1624 | struct GNUNET_MessageHeader *msg; |
1651 | struct GNUNET_MQ_Envelope *envelope; | 1625 | struct GNUNET_MQ_Envelope *envelope; |
1652 | struct HostLeaveContext *hlc; | ||
1653 | 1626 | ||
1654 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1627 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1655 | "GNUNET_SOCIAL_host_leave\n"); | 1628 | "GNUNET_SOCIAL_host_leave\n"); |
1656 | GNUNET_SOCIAL_host_announce (hst, "_notice_place_closing", env, NULL, NULL, | 1629 | GNUNET_SOCIAL_host_announce (hst, "_notice_place_closing", env, NULL, NULL, |
1657 | GNUNET_SOCIAL_ANNOUNCE_NONE); | 1630 | GNUNET_SOCIAL_ANNOUNCE_NONE); |
1631 | hst->plc.disconnect_cb = disconnect_cb; | ||
1632 | hst->plc.disconnect_cls = cls; | ||
1658 | envelope = GNUNET_MQ_msg (msg, | 1633 | envelope = GNUNET_MQ_msg (msg, |
1659 | GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE); | 1634 | GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE); |
1660 | hlc = GNUNET_new (struct HostLeaveContext); | ||
1661 | hlc->hst = hst; | ||
1662 | hlc->disconnect_cb = disconnect_cb; | ||
1663 | hlc->disconnect_cb_cls = cls; | ||
1664 | GNUNET_MQ_notify_sent (envelope, | ||
1665 | &host_leave_cont, | ||
1666 | hlc); | ||
1667 | GNUNET_MQ_send (hst->plc.mq, | 1635 | GNUNET_MQ_send (hst->plc.mq, |
1668 | envelope); | 1636 | envelope); |
1669 | } | 1637 | } |
@@ -2101,37 +2069,6 @@ GNUNET_SOCIAL_guest_disconnect (struct GNUNET_SOCIAL_Guest *gst, | |||
2101 | 2069 | ||
2102 | 2070 | ||
2103 | /** | 2071 | /** |
2104 | * Closure for #leave_done_cont. | ||
2105 | */ | ||
2106 | struct LeaveContext | ||
2107 | { | ||
2108 | struct GNUNET_SOCIAL_Guest *gst; | ||
2109 | GNUNET_ContinuationCallback disconnect_cb; | ||
2110 | void *disconnect_cb_cls; | ||
2111 | }; | ||
2112 | |||
2113 | |||
2114 | /** | ||
2115 | * The leave message was transmitted, now complete the | ||
2116 | * disconnection process. | ||
2117 | * | ||
2118 | * @param cls a `struct LeaveContext` | ||
2119 | */ | ||
2120 | static void | ||
2121 | leave_done_cont (void *cls) | ||
2122 | { | ||
2123 | struct LeaveContext *lc = cls; | ||
2124 | |||
2125 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
2126 | "social_api: guest's place_leave message sent!\n"); | ||
2127 | GNUNET_SOCIAL_guest_disconnect (lc->gst, | ||
2128 | lc->disconnect_cb, | ||
2129 | lc->disconnect_cb_cls); | ||
2130 | GNUNET_free (lc); | ||
2131 | } | ||
2132 | |||
2133 | |||
2134 | /** | ||
2135 | * Leave a place temporarily or permanently. | 2072 | * Leave a place temporarily or permanently. |
2136 | * | 2073 | * |
2137 | * Notifies the owner of the place about leaving, and destroys the place handle. | 2074 | * Notifies the owner of the place about leaving, and destroys the place handle. |
@@ -2155,7 +2092,6 @@ GNUNET_SOCIAL_guest_leave (struct GNUNET_SOCIAL_Guest *gst, | |||
2155 | { | 2092 | { |
2156 | struct GNUNET_MessageHeader *msg; | 2093 | struct GNUNET_MessageHeader *msg; |
2157 | struct GNUNET_MQ_Envelope *envelope; | 2094 | struct GNUNET_MQ_Envelope *envelope; |
2158 | struct LeaveContext *lc; | ||
2159 | 2095 | ||
2160 | GNUNET_SOCIAL_guest_talk (gst, "_notice_place_leave", env, NULL, NULL, | 2096 | GNUNET_SOCIAL_guest_talk (gst, "_notice_place_leave", env, NULL, NULL, |
2161 | GNUNET_SOCIAL_TALK_NONE); | 2097 | GNUNET_SOCIAL_TALK_NONE); |
@@ -2163,15 +2099,10 @@ GNUNET_SOCIAL_guest_leave (struct GNUNET_SOCIAL_Guest *gst, | |||
2163 | 2099 | ||
2164 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 2100 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
2165 | "social_api: place_leave\n"); | 2101 | "social_api: place_leave\n"); |
2102 | gst->plc.disconnect_cb = disconnect_cb; | ||
2103 | gst->plc.disconnect_cls = cls; | ||
2166 | envelope = GNUNET_MQ_msg (msg, | 2104 | envelope = GNUNET_MQ_msg (msg, |
2167 | GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE); | 2105 | GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE); |
2168 | lc = GNUNET_new (struct LeaveContext); | ||
2169 | lc->gst = gst; | ||
2170 | lc->disconnect_cb = disconnect_cb; | ||
2171 | lc->disconnect_cb_cls = cls; | ||
2172 | GNUNET_MQ_notify_sent (envelope, | ||
2173 | &leave_done_cont, | ||
2174 | lc); | ||
2175 | GNUNET_MQ_send (gst->plc.mq, | 2106 | GNUNET_MQ_send (gst->plc.mq, |
2176 | envelope); | 2107 | envelope); |
2177 | } | 2108 | } |