/** S->C: slave join acknowledgement */
#define GNUNET_MESSAGE_TYPE_PSYC_SLAVE_JOIN_ACK 684
-/* 685-686 */
+/** C->S: request to part from a channel */
+#define GNUNET_MESSAGE_TYPE_PSYC_PART_REQUEST 685
+
+/** S->C: acknowledgement that a slave of master parted from a channel */
+#define GNUNET_MESSAGE_TYPE_PSYC_PART_ACK 686
/** M->S->C: incoming join request from multicast */
#define GNUNET_MESSAGE_TYPE_PSYC_JOIN_REQUEST 687
*
* Unicast message from a group member to the peer wanting to join.
*/
-#define GNUNET_MESSAGE_TYPE_MULTICAST_JOIN_DECISION 753
+//#define GNUNET_MESSAGE_TYPE_MULTICAST_JOIN_DECISION 753
/**
* A peer wants to part the group.
*/
-#define GNUNET_MESSAGE_TYPE_MULTICAST_PART_REQUEST 754
+//#define GNUNET_MESSAGE_TYPE_MULTICAST_PART_REQUEST 754
/**
* Acknowledgement sent in response to a part request.
{
struct Channel *chn = &mst->channel;
- if (NULL != mst->origin)
- GNUNET_MULTICAST_origin_stop (mst->origin, NULL, NULL); // FIXME
+ //if (NULL != mst->origin)
+ // GNUNET_MULTICAST_origin_stop (mst->origin, cleanup_cb, cleanup_cls);
GNUNET_CONTAINER_multihashmap_destroy (mst->join_reqs);
GNUNET_CONTAINER_multihashmap_remove (masters, &chn->pub_key_hash, mst);
}
GNUNET_free (slv->relays);
slv->relays = NULL;
}
- if (NULL != slv->member)
- {
- GNUNET_MULTICAST_member_part (slv->member, NULL, NULL); // FIXME
- slv->member = NULL;
- }
+ //if (NULL != slv->member)
+ //{
+ // GNUNET_MULTICAST_member_part (slv->member, cleanup_cb, cleanup_cls);
+ // slv->member = NULL;
+ //}
GNUNET_CONTAINER_multihashmap_remove (slaves, &chn->pub_key_hash, slv);
}
(GNUNET_YES == chn->is_master) ? "master" : "slave",
GNUNET_h2s (&chn->pub_key_hash));
chn->is_disconnected = GNUNET_YES;
- if (NULL != chn->tmit_head)
- { /* Send pending messages to multicast before cleanup. */
- transmit_message (chn);
- }
- else
- {
- cleanup_channel (chn);
- }
+ cleanup_channel (chn);
+ //if (NULL != chn->tmit_head)
+ //{ /* Send pending messages to multicast before cleanup. */
+ // transmit_message (chn);
+ //}
+ //else
+ //{
+ // cleanup_channel (chn);
+ //}
}
}
}
+static void
+channel_part_cb (void *cls)
+{
+ struct GNUNET_SERVICE_Client *client = cls;
+ struct GNUNET_MQ_Envelope *env;
+
+ env = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_PSYC_PART_ACK);
+ GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client),
+ env);
+}
+
+
+static void
+handle_client_part_request (void *cls,
+ const struct GNUNET_MessageHeader *msg)
+{
+ struct Client *c = cls;
+
+ if (GNUNET_YES == c->channel->is_master)
+ {
+ struct Master *mst = (struct Master *) c->channel;
+
+ GNUNET_assert (NULL != mst->origin);
+ GNUNET_MULTICAST_origin_stop (mst->origin, channel_part_cb, c->client);
+ mst->origin = NULL;
+ }
+ else
+ {
+ struct Slave *slv = (struct Slave *) c->channel;
+
+ GNUNET_assert (NULL != slv->member);
+ GNUNET_MULTICAST_member_part (slv->member, channel_part_cb, c->client);
+ slv->member = NULL;
+ }
+}
+
+
/**
* Send acknowledgement to a client.
*
GNUNET_MESSAGE_TYPE_PSYC_JOIN_DECISION,
struct GNUNET_PSYC_JoinDecisionMessage,
NULL),
+ GNUNET_MQ_hd_fixed_size (client_part_request,
+ GNUNET_MESSAGE_TYPE_PSYC_PART_REQUEST,
+ struct GNUNET_MessageHeader,
+ NULL),
GNUNET_MQ_hd_var_size (client_psyc_message,
GNUNET_MESSAGE_TYPE_PSYC_MESSAGE,
struct GNUNET_MessageHeader,
static void
channel_cleanup (struct GNUNET_PSYC_Channel *chn)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "cleaning up channel %p\n",
+ chn);
+ GNUNET_assert (0);
if (NULL != chn->tmit)
{
GNUNET_PSYC_transmit_destroy (chn->tmit);
static void
-channel_disconnect (struct GNUNET_PSYC_Channel *chn,
- GNUNET_ContinuationCallback cb,
- void *cls)
+handle_channel_part_ack (void *cls,
+ const struct GNUNET_MessageHeader *msg)
{
- chn->is_disconnecting = GNUNET_YES;
- chn->disconnect_cb = cb;
- chn->disconnect_cls = cls;
+ struct GNUNET_PSYC_Channel *chn = cls;
- if (NULL != chn->mq)
- {
- struct GNUNET_MQ_Envelope *env = GNUNET_MQ_get_last_envelope (chn->mq);
- if (NULL != env)
- {
- GNUNET_MQ_notify_sent (env, (GNUNET_SCHEDULER_TaskCallback) channel_cleanup, chn);
- }
- else
- {
- channel_cleanup (chn);
- }
- }
- else
- {
- channel_cleanup (chn);
- }
+ channel_cleanup (chn);
}
+//static void
+//channel_disconnect (struct GNUNET_PSYC_Channel *chn,
+// GNUNET_ContinuationCallback cb,
+// void *cls)
+//{
+// chn->is_disconnecting = GNUNET_YES;
+// chn->disconnect_cb = cb;
+// chn->disconnect_cls = cls;
+//
+// if (NULL != chn->mq)
+// {
+// struct GNUNET_MQ_Envelope *env = GNUNET_MQ_get_last_envelope (chn->mq);
+// if (NULL != env)
+// {
+// GNUNET_MQ_notify_sent (env, (GNUNET_SCHEDULER_TaskCallback) channel_cleanup, chn);
+// }
+// else
+// {
+// channel_cleanup (chn);
+// }
+// }
+// else
+// {
+// channel_cleanup (chn);
+// }
+//}
+
+
/*** MASTER ***/
GNUNET_MESSAGE_TYPE_PSYC_JOIN_REQUEST,
struct GNUNET_PSYC_JoinRequestMessage,
mst),
+ GNUNET_MQ_hd_fixed_size (channel_part_ack,
+ GNUNET_MESSAGE_TYPE_PSYC_PART_ACK,
+ struct GNUNET_MessageHeader,
+ chn),
GNUNET_MQ_hd_var_size (channel_message,
GNUNET_MESSAGE_TYPE_PSYC_MESSAGE,
struct GNUNET_PSYC_MessageHeader,
void *stop_cls)
{
struct GNUNET_PSYC_Channel *chn = &mst->chn;
+ struct GNUNET_MQ_Envelope *env;
- /* FIXME: send msg to service */
-
- channel_disconnect (chn, stop_cb, stop_cls);
+ chn->disconnect_cb = stop_cb;
+ chn->disconnect_cls = stop_cls;
+ env = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_PSYC_PART_REQUEST);
+ GNUNET_MQ_send (chn->mq, env);
}
GNUNET_MESSAGE_TYPE_PSYC_JOIN_DECISION,
struct GNUNET_PSYC_JoinDecisionMessage,
slv),
+ GNUNET_MQ_hd_fixed_size (channel_part_ack,
+ GNUNET_MESSAGE_TYPE_PSYC_PART_ACK,
+ struct GNUNET_MessageHeader,
+ chn),
GNUNET_MQ_hd_var_size (channel_message,
GNUNET_MESSAGE_TYPE_PSYC_MESSAGE,
struct GNUNET_PSYC_MessageHeader,
void *part_cls)
{
struct GNUNET_PSYC_Channel *chn = &slv->chn;
+ struct GNUNET_MQ_Envelope *env;
- /* FIXME: send msg to service */
-
- channel_disconnect (chn, part_cb, part_cls);
+ chn->disconnect_cb = part_cb;
+ chn->disconnect_cls = part_cls;
+ env = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_PSYC_PART_REQUEST);
+ GNUNET_MQ_send (chn->mq, env);
}