diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:54:06 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:54:06 +0000 |
commit | 5746309cb4be2073d550ad7a6885e918631dbc38 (patch) | |
tree | 89455bc4aadf977816b38df13f990372cd81d71a /src/transport/test_transport_api_reliability.c | |
parent | 6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff) | |
download | gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip |
indentation
Diffstat (limited to 'src/transport/test_transport_api_reliability.c')
-rw-r--r-- | src/transport/test_transport_api_reliability.c | 79 |
1 files changed, 34 insertions, 45 deletions
diff --git a/src/transport/test_transport_api_reliability.c b/src/transport/test_transport_api_reliability.c index 60191394d..008bb9019 100644 --- a/src/transport/test_transport_api_reliability.c +++ b/src/transport/test_transport_api_reliability.c | |||
@@ -114,8 +114,8 @@ end () | |||
114 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping peers\n"); | 114 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping peers\n"); |
115 | 115 | ||
116 | delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value; | 116 | delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value; |
117 | fprintf (stderr, | 117 | fprintf (stderr, "\nThroughput was %llu kb/s\n", |
118 | "\nThroughput was %llu kb/s\n", total_bytes * 1000 / 1024 / delta); | 118 | total_bytes * 1000 / 1024 / delta); |
119 | //GNUNET_asprintf(&value_name, "reliable_%s", test_name); | 119 | //GNUNET_asprintf(&value_name, "reliable_%s", test_name); |
120 | //GAUGER ("TRANSPORT", value_name, (int)(total_bytes * 1000 / 1024 /delta), "kb/s"); | 120 | //GAUGER ("TRANSPORT", value_name, (int)(total_bytes * 1000 / 1024 /delta), "kb/s"); |
121 | //GNUNET_free(value_name); | 121 | //GNUNET_free(value_name); |
@@ -161,8 +161,7 @@ get_size (unsigned int iter) | |||
161 | 161 | ||
162 | 162 | ||
163 | static void | 163 | static void |
164 | notify_receive (void *cls, | 164 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, |
165 | const struct GNUNET_PeerIdentity *peer, | ||
166 | const struct GNUNET_MessageHeader *message, | 165 | const struct GNUNET_MessageHeader *message, |
167 | const struct GNUNET_TRANSPORT_ATS_Information *ats, | 166 | const struct GNUNET_TRANSPORT_ATS_Information *ats, |
168 | uint32_t ats_count) | 167 | uint32_t ats_count) |
@@ -204,8 +203,8 @@ notify_receive (void *cls, | |||
204 | if (0 != memcmp (cbuf, &hdr[1], s - sizeof (struct TestMessage))) | 203 | if (0 != memcmp (cbuf, &hdr[1], s - sizeof (struct TestMessage))) |
205 | { | 204 | { |
206 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 205 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
207 | "Expected message %u with bits %u, but body did not match\n", | 206 | "Expected message %u with bits %u, but body did not match\n", n, |
208 | n, (unsigned char) n); | 207 | (unsigned char) n); |
209 | if (die_task != GNUNET_SCHEDULER_NO_TASK) | 208 | if (die_task != GNUNET_SCHEDULER_NO_TASK) |
210 | GNUNET_SCHEDULER_cancel (die_task); | 209 | GNUNET_SCHEDULER_cancel (die_task); |
211 | test_failed = GNUNET_YES; | 210 | test_failed = GNUNET_YES; |
@@ -215,8 +214,7 @@ notify_receive (void *cls, | |||
215 | #if VERBOSE | 214 | #if VERBOSE |
216 | if (ntohl (hdr->num) % 5000 == 0) | 215 | if (ntohl (hdr->num) % 5000 == 0) |
217 | { | 216 | { |
218 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 217 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got message %u of size %u\n", |
219 | "Got message %u of size %u\n", | ||
220 | ntohl (hdr->num), ntohs (message->size)); | 218 | ntohl (hdr->num), ntohs (message->size)); |
221 | } | 219 | } |
222 | #endif | 220 | #endif |
@@ -271,8 +269,8 @@ notify_ready (void *cls, size_t size, void *buf) | |||
271 | #if VERBOSE | 269 | #if VERBOSE |
272 | if (n % 5000 == 0) | 270 | if (n % 5000 == 0) |
273 | { | 271 | { |
274 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 272 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending message %u of size %u\n", n, |
275 | "Sending message %u of size %u\n", n, s); | 273 | s); |
276 | } | 274 | } |
277 | #endif | 275 | #endif |
278 | n++; | 276 | n++; |
@@ -284,10 +282,9 @@ notify_ready (void *cls, size_t size, void *buf) | |||
284 | if (n < TOTAL_MSGS) | 282 | if (n < TOTAL_MSGS) |
285 | { | 283 | { |
286 | if (th == NULL) | 284 | if (th == NULL) |
287 | th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th, | 285 | th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th, &p1->id, s, 0, |
288 | &p1->id, | 286 | TIMEOUT, ¬ify_ready, |
289 | s, 0, TIMEOUT, | 287 | NULL); |
290 | ¬ify_ready, NULL); | ||
291 | msg_scheduled = n; | 288 | msg_scheduled = n; |
292 | } | 289 | } |
293 | if (n % 5000 == 0) | 290 | if (n % 5000 == 0) |
@@ -305,19 +302,17 @@ notify_ready (void *cls, size_t size, void *buf) | |||
305 | 302 | ||
306 | 303 | ||
307 | static void | 304 | static void |
308 | notify_connect (void *cls, | 305 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, |
309 | const struct GNUNET_PeerIdentity *peer, | ||
310 | const struct GNUNET_TRANSPORT_ATS_Information *ats, | 306 | const struct GNUNET_TRANSPORT_ATS_Information *ats, |
311 | uint32_t ats_count) | 307 | uint32_t ats_count) |
312 | { | 308 | { |
313 | 309 | ||
314 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 310 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' connected to us (%p)!\n", |
315 | "Peer `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls); | 311 | GNUNET_i2s (peer), cls); |
316 | 312 | ||
317 | if (cls == p1) | 313 | if (cls == p1) |
318 | { | 314 | { |
319 | GNUNET_TRANSPORT_set_quota (p1->th, | 315 | GNUNET_TRANSPORT_set_quota (p1->th, &p2->id, |
320 | &p2->id, | ||
321 | GNUNET_BANDWIDTH_value_init (1024 * 1024 * | 316 | GNUNET_BANDWIDTH_value_init (1024 * 1024 * |
322 | 1024), | 317 | 1024), |
323 | GNUNET_BANDWIDTH_value_init (1024 * 1024 * | 318 | GNUNET_BANDWIDTH_value_init (1024 * 1024 * |
@@ -325,8 +320,7 @@ notify_connect (void *cls, | |||
325 | } | 320 | } |
326 | else if (cls == p2) | 321 | else if (cls == p2) |
327 | { | 322 | { |
328 | GNUNET_TRANSPORT_set_quota (p2->th, | 323 | GNUNET_TRANSPORT_set_quota (p2->th, &p1->id, |
329 | &p1->id, | ||
330 | GNUNET_BANDWIDTH_value_init (1024 * 1024 * | 324 | GNUNET_BANDWIDTH_value_init (1024 * 1024 * |
331 | 1024), | 325 | 1024), |
332 | GNUNET_BANDWIDTH_value_init (1024 * 1024 * | 326 | GNUNET_BANDWIDTH_value_init (1024 * 1024 * |
@@ -338,18 +332,16 @@ notify_connect (void *cls, | |||
338 | static void | 332 | static void |
339 | notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | 333 | notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) |
340 | { | 334 | { |
341 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 335 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' disconnected (%p)!\n", |
342 | "Peer `%4s' disconnected (%p)!\n", GNUNET_i2s (peer), cls); | 336 | GNUNET_i2s (peer), cls); |
343 | } | 337 | } |
344 | 338 | ||
345 | static void | 339 | static void |
346 | sendtask () | 340 | sendtask () |
347 | { | 341 | { |
348 | start_time = GNUNET_TIME_absolute_get (); | 342 | start_time = GNUNET_TIME_absolute_get (); |
349 | th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th, | 343 | th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th, &p1->id, get_size (0), 0, |
350 | &p1->id, | 344 | TIMEOUT, ¬ify_ready, NULL); |
351 | get_size (0), 0, TIMEOUT, | ||
352 | ¬ify_ready, NULL); | ||
353 | } | 345 | } |
354 | 346 | ||
355 | static void | 347 | static void |
@@ -357,8 +349,8 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) | |||
357 | { | 349 | { |
358 | char *p1_c = strdup (GNUNET_i2s (&p1->id)); | 350 | char *p1_c = strdup (GNUNET_i2s (&p1->id)); |
359 | 351 | ||
360 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %s <-> %s\n", | 352 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %s <-> %s\n", p1_c, |
361 | p1_c, GNUNET_i2s (&p2->id)); | 353 | GNUNET_i2s (&p2->id)); |
362 | GNUNET_free (p1_c); | 354 | GNUNET_free (p1_c); |
363 | 355 | ||
364 | // FIXME: THIS IS REQUIRED! SEEMS TO BE A BUG! | 356 | // FIXME: THIS IS REQUIRED! SEEMS TO BE A BUG! |
@@ -366,20 +358,17 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) | |||
366 | } | 358 | } |
367 | 359 | ||
368 | static void | 360 | static void |
369 | run (void *cls, | 361 | run (void *cls, char *const *args, const char *cfgfile, |
370 | char *const *args, | 362 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
371 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
372 | { | 363 | { |
373 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); | 364 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); |
374 | 365 | ||
375 | p1 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p1, | 366 | p1 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p1, ¬ify_receive, |
376 | ¬ify_receive, | 367 | ¬ify_connect, ¬ify_disconnect, |
377 | ¬ify_connect, | 368 | NULL); |
378 | ¬ify_disconnect, NULL); | 369 | p2 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p2, ¬ify_receive, |
379 | p2 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p2, | 370 | ¬ify_connect, ¬ify_disconnect, |
380 | ¬ify_receive, | 371 | NULL); |
381 | ¬ify_connect, | ||
382 | ¬ify_disconnect, NULL); | ||
383 | 372 | ||
384 | GNUNET_TRANSPORT_TESTING_connect_peers (p1, p2, &testing_connect_cb, NULL); | 373 | GNUNET_TRANSPORT_TESTING_connect_peers (p1, p2, &testing_connect_cb, NULL); |
385 | } | 374 | } |
@@ -403,8 +392,8 @@ check () | |||
403 | setTransportOptions ("test_transport_api_data.conf"); | 392 | setTransportOptions ("test_transport_api_data.conf"); |
404 | #endif | 393 | #endif |
405 | ok = 1; | 394 | ok = 1; |
406 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, | 395 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, |
407 | argv, "test-transport-api", "nohelp", options, &run, &ok); | 396 | "test-transport-api", "nohelp", options, &run, &ok); |
408 | 397 | ||
409 | return ok; | 398 | return ok; |
410 | } | 399 | } |
@@ -494,8 +483,8 @@ check_gnunet_nat_binary (char *binary) | |||
494 | } | 483 | } |
495 | if (0 != STAT (p, &statbuf)) | 484 | if (0 != STAT (p, &statbuf)) |
496 | { | 485 | { |
497 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 486 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("stat (%s) failed: %s\n"), p, |
498 | _("stat (%s) failed: %s\n"), p, STRERROR (errno)); | 487 | STRERROR (errno)); |
499 | GNUNET_free (p); | 488 | GNUNET_free (p); |
500 | return GNUNET_SYSERR; | 489 | return GNUNET_SYSERR; |
501 | } | 490 | } |