summaryrefslogtreecommitdiff
path: root/src/transport/test_transport_api.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2011-10-06 11:06:42 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2011-10-06 11:06:42 +0000
commit9dac44e13d6b9093615ed2a0dd30c9f6d37d29ab (patch)
treed0b22ab82aa54a3e2f634e475045a148a8c7ce67 /src/transport/test_transport_api.c
parent60e84bc16ecf431bd6f7aa22b3adb48df70bf8cf (diff)
Diffstat (limited to 'src/transport/test_transport_api.c')
-rw-r--r--src/transport/test_transport_api.c51
1 files changed, 26 insertions, 25 deletions
diff --git a/src/transport/test_transport_api.c b/src/transport/test_transport_api.c
index 4f420f96a..c9068c47a 100644
--- a/src/transport/test_transport_api.c
+++ b/src/transport/test_transport_api.c
@@ -194,15 +194,41 @@ notify_ready (void *cls, size_t size, void *buf)
return sizeof (struct GNUNET_MessageHeader);
}
+struct PeerContext * sender;
+struct PeerContext * receiver;
+
+static void
+sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ send_task = GNUNET_SCHEDULER_NO_TASK;
+
+ if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
+ return;
+ char * receiver_s = strdup(GNUNET_i2s (&receiver->id));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Sending message from peer %u (`%4s') -> peer %u (`%s') !\n",
+ sender->no,
+ GNUNET_i2s (&sender->id), receiver->no, receiver_s);
+ GNUNET_free (receiver_s);
+
+ th = GNUNET_TRANSPORT_notify_transmit_ready (sender->th, &receiver->id, 256, 0,
+ TIMEOUT_TRANSMIT, &notify_ready,
+ receiver);
+}
+
static void
notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_TRANSPORT_ATS_Information *ats,
uint32_t ats_count)
{
+ static int c;
+ c++;
struct PeerContext *p = cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%4s') connected to us!\n",
p->no, GNUNET_i2s (peer));
+ if (c == 2)
+ send_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &sendtask, NULL);
}
@@ -217,27 +243,6 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
th = NULL;
}
-struct PeerContext * sender;
-struct PeerContext * receiver;
-
-static void
-sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- send_task = GNUNET_SCHEDULER_NO_TASK;
-
- if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
- return;
- char * receiver_s = strdup(GNUNET_i2s (&receiver->id));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Sending message from peer %u (`%4s') -> peer %u (`%s') !\n",
- sender->no,
- GNUNET_i2s (&sender->id), receiver->no, receiver_s);
- GNUNET_free (receiver_s);
-
- th = GNUNET_TRANSPORT_notify_transmit_ready (sender->th, &receiver->id, 256, 0,
- TIMEOUT_TRANSMIT, &notify_ready,
- receiver);
-}
static void
testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
@@ -249,10 +254,6 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
p1->no, p1_c,
p2->no, GNUNET_i2s (&p2->id));
GNUNET_free (p1_c);
-
- // FIXME: THIS IS REQUIRED! SEEMS TO BE A BUG!
- send_task =
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &sendtask, NULL);
}
static void