aboutsummaryrefslogtreecommitdiff
path: root/src/multicast/multicast_api.c
diff options
context:
space:
mode:
authorGabor X Toth <*@tg-x.net>2014-07-23 16:19:49 +0000
committerGabor X Toth <*@tg-x.net>2014-07-23 16:19:49 +0000
commit3cf8ba0b60f8495892fa76635e9c23555d0a304c (patch)
tree5f27648bdb3cf3409628e4e5edc26f811cbd03a5 /src/multicast/multicast_api.c
parent252b5599987b7ba03b879a8c2d1c455ad4c9834a (diff)
social: implement enter/leave/messaging; psyc: improvements and fixes
- social: implement enter/leave, send/receive messages, slicer - psyc, social: add struct GNUNET_PSYC_Message for single-fragment join messages - psyc: add message callback in addition to message part callback - client_manager, social, psyc, multicast: add disconnect callback
Diffstat (limited to 'src/multicast/multicast_api.c')
-rw-r--r--src/multicast/multicast_api.c76
1 files changed, 68 insertions, 8 deletions
diff --git a/src/multicast/multicast_api.c b/src/multicast/multicast_api.c
index d2a0412bb6..fb26300813 100644
--- a/src/multicast/multicast_api.c
+++ b/src/multicast/multicast_api.c
@@ -88,6 +88,16 @@ struct GNUNET_MULTICAST_Group
void *cb_cls;
/**
+ * Function called after disconnected from the service.
+ */
+ GNUNET_ContinuationCallback disconnect_cb;
+
+ /**
+ * Closure for @a disconnect_cb.
+ */
+ void *disconnect_cls;
+
+ /**
* Are we currently transmitting a message?
*/
uint8_t in_transmit;
@@ -96,6 +106,12 @@ struct GNUNET_MULTICAST_Group
* Is this the origin or a member?
*/
uint8_t is_origin;
+
+ /**
+ * Is this channel in the process of disconnecting from the service?
+ * #GNUNET_YES or #GNUNET_NO
+ */
+ uint8_t is_disconnecting;
};
@@ -320,8 +336,9 @@ member_recv_join_decision (void *cls,
mem->join_dcsn_cb (grp->cb_cls, is_admitted, &hdcsn->peer,
relay_count, relays, join_resp);
- if (GNUNET_YES != is_admitted)
- GNUNET_MULTICAST_member_part (mem);
+ // FIXME:
+ //if (GNUNET_YES != is_admitted)
+ // GNUNET_MULTICAST_member_part (mem);
}
@@ -371,6 +388,33 @@ static struct GNUNET_CLIENT_MANAGER_MessageHandler member_handlers[] =
};
+static void
+group_cleanup (struct GNUNET_MULTICAST_Group *grp)
+{
+ GNUNET_free (grp->connect_msg);
+ if (NULL != grp->disconnect_cb)
+ grp->disconnect_cb (grp->disconnect_cls);
+}
+
+
+static void
+origin_cleanup (void *cls)
+{
+ struct GNUNET_MULTICAST_Origin *orig = cls;
+ group_cleanup (&orig->grp);
+ GNUNET_free (orig);
+}
+
+
+static void
+member_cleanup (void *cls)
+{
+ struct GNUNET_MULTICAST_Member *mem = cls;
+ group_cleanup (&mem->grp);
+ GNUNET_free (mem);
+}
+
+
/**
* Function to call with the decision made for a join request.
*
@@ -565,10 +609,18 @@ GNUNET_MULTICAST_origin_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
* @param origin Multicast group to stop.
*/
void
-GNUNET_MULTICAST_origin_stop (struct GNUNET_MULTICAST_Origin *orig)
+GNUNET_MULTICAST_origin_stop (struct GNUNET_MULTICAST_Origin *orig,
+ GNUNET_ContinuationCallback stop_cb,
+ void *stop_cls)
{
- GNUNET_CLIENT_MANAGER_disconnect (orig->grp.client, GNUNET_YES);
- GNUNET_free (orig);
+ struct GNUNET_MULTICAST_Group *grp = &orig->grp;
+
+ grp->is_disconnecting = GNUNET_YES;
+ grp->disconnect_cb = stop_cb;
+ grp->disconnect_cls = stop_cls;
+
+ GNUNET_CLIENT_MANAGER_disconnect (orig->grp.client, GNUNET_YES,
+ &origin_cleanup, orig);
}
@@ -774,10 +826,18 @@ GNUNET_MULTICAST_member_join (const struct GNUNET_CONFIGURATION_Handle *cfg,
* @param member Membership handle.
*/
void
-GNUNET_MULTICAST_member_part (struct GNUNET_MULTICAST_Member *mem)
+GNUNET_MULTICAST_member_part (struct GNUNET_MULTICAST_Member *mem,
+ GNUNET_ContinuationCallback part_cb,
+ void *part_cls)
{
- GNUNET_CLIENT_MANAGER_disconnect (mem->grp.client, GNUNET_YES);
- GNUNET_free (mem);
+ struct GNUNET_MULTICAST_Group *grp = &mem->grp;
+
+ grp->is_disconnecting = GNUNET_YES;
+ grp->disconnect_cb = part_cb;
+ grp->disconnect_cls = part_cls;
+
+ GNUNET_CLIENT_MANAGER_disconnect (mem->grp.client, GNUNET_YES,
+ &member_cleanup, mem);
}