- struct OverlayConnectContext *occ = cls;
-
- occ->tch = NULL;
- if (GNUNET_OK == result)
- {
- GNUNET_free_non_null (occ->emsg);
- occ->emsg = GNUNET_strdup ("Waiting for transport to connect");
- //return; FIXME: should return here
- }
- // GNUNET_break (0);
- occ->tch = GNUNET_TRANSPORT_try_connect (occ->p2th, &occ->peer_identity,
- &try_connect_cb, occ);
+ struct TryConnectContext *tcc = cls;
+
+ tcc->tch = NULL;
+ GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == tcc->task);
+ tcc->task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
+ (GNUNET_TIME_UNIT_MILLISECONDS,
+ pow (10, ++tcc->retries)),
+ &try_connect_task, tcc);
+}
+
+
+/**
+ * Task to ask transport of a peer to connect to another peer
+ *
+ * @param cls the TryConnectContext
+ * @param tc the scheduler task context
+ */
+static void
+try_connect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ struct TryConnectContext *tcc = cls;
+
+ tcc->task = GNUNET_SCHEDULER_NO_TASK;
+ if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason))
+ return;
+ GNUNET_assert (NULL == tcc->tch);
+ GNUNET_assert (NULL != tcc->pid);
+ GNUNET_assert (NULL != tcc->th);
+ tcc->tch = GNUNET_TRANSPORT_try_connect (tcc->th, tcc->pid, &try_connect_cb, tcc);