diff options
Diffstat (limited to 'src/transport/test_transport_api_timeout.c')
-rw-r--r-- | src/transport/test_transport_api_timeout.c | 43 |
1 files changed, 19 insertions, 24 deletions
diff --git a/src/transport/test_transport_api_timeout.c b/src/transport/test_transport_api_timeout.c index aff36853a..79a90ba0e 100644 --- a/src/transport/test_transport_api_timeout.c +++ b/src/transport/test_transport_api_timeout.c | |||
@@ -65,7 +65,7 @@ static GNUNET_SCHEDULER_TaskIdentifier die_task; | |||
65 | 65 | ||
66 | static GNUNET_SCHEDULER_TaskIdentifier timer_task; | 66 | static GNUNET_SCHEDULER_TaskIdentifier timer_task; |
67 | 67 | ||
68 | struct GNUNET_TRANSPORT_TESTING_handle * tth; | 68 | struct GNUNET_TRANSPORT_TESTING_handle *tth; |
69 | 69 | ||
70 | struct PeerContext *p1; | 70 | struct PeerContext *p1; |
71 | 71 | ||
@@ -161,8 +161,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
161 | static void | 161 | static void |
162 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | 162 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, |
163 | const struct GNUNET_MessageHeader *message, | 163 | const struct GNUNET_MessageHeader *message, |
164 | const struct GNUNET_ATS_Information *ats, | 164 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count) |
165 | uint32_t ats_count) | ||
166 | { | 165 | { |
167 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 166 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
168 | "Received message of type %d from peer %s!\n", | 167 | "Received message of type %d from peer %s!\n", |
@@ -171,8 +170,7 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
171 | 170 | ||
172 | static void | 171 | static void |
173 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, | 172 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, |
174 | const struct GNUNET_ATS_Information *ats, | 173 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count) |
175 | uint32_t ats_count) | ||
176 | { | 174 | { |
177 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' connected to us (%p)!\n", | 175 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' connected to us (%p)!\n", |
178 | GNUNET_i2s (peer), cls); | 176 | GNUNET_i2s (peer), cls); |
@@ -240,23 +238,24 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) | |||
240 | timer_task = GNUNET_SCHEDULER_add_now (&timer, NULL); | 238 | timer_task = GNUNET_SCHEDULER_add_now (&timer, NULL); |
241 | } | 239 | } |
242 | 240 | ||
243 | void start_cb (struct PeerContext * p, | 241 | void |
244 | void *cls) | 242 | start_cb (struct PeerContext *p, void *cls) |
245 | { | 243 | { |
246 | static int started; | 244 | static int started; |
245 | |||
247 | started++; | 246 | started++; |
248 | 247 | ||
249 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", | 248 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", p->no, |
250 | p->no, | 249 | GNUNET_i2s (&p->id)); |
251 | GNUNET_i2s (&p->id)); | ||
252 | 250 | ||
253 | if (started != 2) | 251 | if (started != 2) |
254 | return; | 252 | return; |
255 | 253 | ||
256 | char *sender_c = strdup (GNUNET_i2s (&p1->id)); | 254 | char *sender_c = strdup (GNUNET_i2s (&p1->id)); |
257 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test tries to connect peer %u (`%s') -> peer %u (`%s')\n", | 255 | |
258 | p1->no, sender_c, | 256 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
259 | p2->no, GNUNET_i2s (&p2->id)); | 257 | "Test tries to connect peer %u (`%s') -> peer %u (`%s')\n", |
258 | p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id)); | ||
260 | 259 | ||
261 | cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, | 260 | cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, |
262 | NULL); | 261 | NULL); |
@@ -269,17 +268,13 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
269 | { | 268 | { |
270 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); | 269 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); |
271 | 270 | ||
272 | p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1, | 271 | p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1, |
273 | ¬ify_receive, | 272 | ¬ify_receive, ¬ify_connect, |
274 | ¬ify_connect, | 273 | ¬ify_disconnect, &start_cb, |
275 | ¬ify_disconnect, | ||
276 | &start_cb, | ||
277 | NULL); | 274 | NULL); |
278 | p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2, | 275 | p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2, |
279 | ¬ify_receive, | 276 | ¬ify_receive, ¬ify_connect, |
280 | ¬ify_connect, | 277 | ¬ify_disconnect, &start_cb, |
281 | ¬ify_disconnect, | ||
282 | &start_cb, | ||
283 | NULL); | 278 | NULL); |
284 | 279 | ||
285 | if ((p1 == NULL) || (p2 == NULL)) | 280 | if ((p1 == NULL) || (p2 == NULL)) |
@@ -314,8 +309,8 @@ check () | |||
314 | 309 | ||
315 | ok = 1; | 310 | ok = 1; |
316 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, | 311 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, |
317 | "test-transport-api-timeout", "nohelp", options, | 312 | "test-transport-api-timeout", "nohelp", options, &run, |
318 | &run, &ok); | 313 | &ok); |
319 | 314 | ||
320 | return ok; | 315 | return ok; |
321 | } | 316 | } |