#define REOPEN 11
#define DESTROY 12
+/**
+ * Active peer listing operation.
+ */
+static struct GNUNET_CADET_PeersLister *plo;
+
+/*
+ * Task called to check for existing tunnel and depending on that reopen channel
+ */
+static struct GNUNET_SCHEDULER_Task *get_peers_task;
+
/**
* Which test are we running?
*/
send_test_message (outgoing_ch);
}
+static void
+peers_callback (void *cls, const struct GNUNET_CADET_PeerListEntry *ple);
+
+/**
+ * We ask the monitoring api for all the peers.
+ */
+static void
+get_peers(void *cls)
+{
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "requesting peers info!\n");
+ plo = GNUNET_CADET_list_peers (get_from_cadets(), &peers_callback, NULL);
+
+}
+
+/**
+ * Method called to retrieve information about all peers in CADET, called
+ * once per peer.
+ *
+ * After last peer has been reported, an additional call with NULL is done.
+ *
+ * We check the peer we are interested in, if we have a tunnel. If not, we
+ * reopen the channel
+ *
+ * @param cls Closure.
+ * @param ple information about peer, or NULL on "EOF".
+ */
+static void
+peers_callback (void *cls, const struct GNUNET_CADET_PeerListEntry *ple)
+{
+
+ const struct GNUNET_PeerIdentity *p_id;
+
+ if (NULL == ple)
+ {
+ plo = NULL;
+ return;
+ }
+ p_id = get_from_p_ids();
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "peer %s equal to peer %s?",
+ GNUNET_i2s_full (&ple->peer),
+ GNUNET_i2s_full (&ple->peer));
+
+ if (p_id == &ple->peer && ple->have_tunnel)
+ {
+
+ if (NULL != get_peers_task)
+ {
+ GNUNET_SCHEDULER_cancel (get_peers_task);
+ plo = NULL;
+ get_peers_task = GNUNET_SCHEDULER_add_now (&get_peers,
+ NULL);
+ }
+ }
+ else if (p_id == &ple->peer)
+ {
+
+ reopen_channel ();
+
+ }
+}
+
/**
* Function called whenever an MQ-channel is destroyed, unless the destruction
* was requested by #GNUNET_CADET_channel_destroy.
if ((NULL != disconnect_task) && (DESTROY == test) && (3 == ok))
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Reopen channel!\n");
- reopen_channel ();
+ "Reopen channel task!\n");
+ if (NULL == get_peers_task)
+ {
+ get_peers_task = GNUNET_SCHEDULER_add_now (&get_peers,
+ NULL);
+ }
return;
}
if (get_target_channel () == channel) /* Got "data" */
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO, " received data %u\n", data_received);
- if ((SPEED != test) || ( (ok_goal - 2) == ok) )
+ if ((DESTROY != test) && ((SPEED != test) || ( (ok_goal - 2) == ok)) )
{
/* Send ACK */
send_test_message (channel);
(long) cls);
GNUNET_assert (0);
}
- if ((NULL != disconnect_task) && (REOPEN != test))
+ if ((NULL != disconnect_task) && (REOPEN != test) && (DESTROY != test))
{
GNUNET_SCHEDULER_cancel (disconnect_task);
disconnect_task = GNUNET_SCHEDULER_add_delayed (short_time,
ch->ch = outgoing_ch;
- disconnect_task = GNUNET_SCHEDULER_add_delayed (short_time,
+ //if (DESTROY != test)
+ disconnect_task = GNUNET_SCHEDULER_add_delayed (short_time,
&gather_stats_and_exit,
(void *) __LINE__);
if (KEEPALIVE == test)
/**
* Callback to be called when the requested peer information is available
*
- * @param cls the closure from GNUNET_TESTBED_peer_get_information()
+ * @param cls the closure from GNUNET_TESTBED_peer_getinformation()
* @param op the operation this callback corresponds to
* @param pinfo the result; will be NULL if the operation has failed
* @param emsg error message if the operation has failed;