send_test_message (outgoing_ch);
}
+void
+reopen_channel ()
+{
+ struct CadetTestChannelWrapper *ch;
+ static struct GNUNET_CADET_Handle *h1;
+ static struct GNUNET_PeerIdentity *p_id;
+ struct GNUNET_MQ_MessageHandler handlers[] = {
+ GNUNET_MQ_hd_var_size (data,
+ GNUNET_MESSAGE_TYPE_DUMMY,
+ struct GNUNET_MessageHeader,
+ NULL),
+ GNUNET_MQ_handler_end ()
+ };
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "creating channel again\n");
+ p_id = get_from_p_ids();
+ h1 = get_from_cadets();
+ ch = GNUNET_new (struct CadetTestChannelWrapper);
+ outgoing_ch = GNUNET_CADET_channel_create (h1,
+ ch,
+ p_id,
+ &port,
+ NULL,
+ &disconnect_handler,
+ handlers);
+ ch->ch = outgoing_ch;
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Sending second test data (after destroying the channel) on channel %p...\n",
+ outgoing_ch);
+ send_test_message (outgoing_ch);
+}
/**
* Function called whenever an MQ-channel is destroyed, unless the destruction
struct CadetTestChannelWrapper *ch_w = cls;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Channel disconnected at %d\n",
+ "Channel disconnected at ok=%d\n",
ok);
GNUNET_assert (ch_w->ch == channel);
+
+ if ((NULL != disconnect_task) && (DESTROY == test) && (3 == ok))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Reopen channel!\n");
+ reopen_channel ();
+ return;
+ }
+
if (channel == incoming_ch)
{
ok++;
uint32_t *data;
uint32_t payload;
int *counter;
- struct GNUNET_MQ_MessageHandler handlers[] = {
- GNUNET_MQ_hd_var_size (data,
- GNUNET_MESSAGE_TYPE_DUMMY,
- struct GNUNET_MessageHeader,
- NULL),
- GNUNET_MQ_handler_end ()
- };
- static struct GNUNET_CADET_Handle *h1;
- static struct GNUNET_PeerIdentity *p_id;
ok++;
GNUNET_CADET_receive_done (channel);
{
if (2 == ok)
{
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "dropping message\n");
- GNUNET_CADET_drop_message (GNUNET_CADET_get_mq (outgoing_ch),
- outgoing_ch->ccn,
- GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY);
- GNUNET_CADET_channel_destroy(outgoing_ch);
-
ok++;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
" ok: (%d/%d)\n",
ok,
ok_goal);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "creating channel again\n");
- p_id = get_from_p_ids();
- ch = GNUNET_new (struct CadetTestChannelWrapper);
- outgoing_ch = GNUNET_CADET_channel_create (h1,
- ch,
- p_id,
- &port,
- NULL,
- &disconnect_handler,
- handlers);
- ch->ch = outgoing_ch;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Sending second test data (after destroying the channel) on channel %p...\n",
- outgoing_ch);
- send_test_message (outgoing_ch);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "dropping message\n");
+ GNUNET_CADET_drop_message (GNUNET_CADET_get_mq (outgoing_ch),
+ outgoing_ch->ccn,
+ GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY);
+ GNUNET_CADET_channel_destroy(outgoing_ch);
}
- else if (3 == ok)
+ else if (4 == ok)
{
ok++;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
if (peer == get_peer_nr())
{
- if (NULL != incoming_ch)
+ if (DESTROY != test && NULL != incoming_ch)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Duplicate incoming channel for client %lu\n",
{
test = DESTROY;
test_name = "destroy";
- ok_goal = 4;
+ ok_goal = 5;
}
else
{