summaryrefslogtreecommitdiff
path: root/src/core/test_core_api_reliability.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
commit5746309cb4be2073d550ad7a6885e918631dbc38 (patch)
tree89455bc4aadf977816b38df13f990372cd81d71a /src/core/test_core_api_reliability.c
parent6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff)
downloadgnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz
gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip
indentation
Diffstat (limited to 'src/core/test_core_api_reliability.c')
-rw-r--r--src/core/test_core_api_reliability.c92
1 files changed, 33 insertions, 59 deletions
diff --git a/src/core/test_core_api_reliability.c b/src/core/test_core_api_reliability.c
index 1f82a0058..afe6ad269 100644
--- a/src/core/test_core_api_reliability.c
+++ b/src/core/test_core_api_reliability.c
@@ -132,8 +132,8 @@ terminate_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
132 GNUNET_TRANSPORT_disconnect (p2.th); 132 GNUNET_TRANSPORT_disconnect (p2.th);
133 p2.th = NULL; 133 p2.th = NULL;
134 delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value; 134 delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value;
135 fprintf (stderr, 135 fprintf (stderr, "\nThroughput was %llu kb/s\n",
136 "\nThroughput was %llu kb/s\n", total_bytes * 1000 / 1024 / delta); 136 total_bytes * 1000 / 1024 / delta);
137 GAUGER ("CORE", "Core throughput/s", total_bytes * 1000 / 1024 / delta, 137 GAUGER ("CORE", "Core throughput/s", total_bytes * 1000 / 1024 / delta,
138 "kb/s"); 138 "kb/s");
139 ok = 0; 139 ok = 0;
@@ -183,11 +183,8 @@ transmit_ready (void *cls, size_t size, void *buf)
183 { 183 {
184 if (p1.ch != NULL) 184 if (p1.ch != NULL)
185 GNUNET_break (NULL != 185 GNUNET_break (NULL !=
186 GNUNET_CORE_notify_transmit_ready (p1.ch, 186 GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO, 0,
187 GNUNET_NO, 187 FAST_TIMEOUT, &p2.id,
188 0,
189 FAST_TIMEOUT,
190 &p2.id,
191 get_size (tr_n), 188 get_size (tr_n),
192 &transmit_ready, &p1)); 189 &transmit_ready, &p1));
193 return 0; 190 return 0;
@@ -229,8 +226,7 @@ transmit_ready (void *cls, size_t size, void *buf)
229 226
230 227
231static void 228static void
232connect_notify (void *cls, 229connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer,
233 const struct GNUNET_PeerIdentity *peer,
234 const struct GNUNET_TRANSPORT_ATS_Information *atsi) 230 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
235{ 231{
236 struct PeerContext *pc = cls; 232 struct PeerContext *pc = cls;
@@ -252,11 +248,8 @@ connect_notify (void *cls,
252 GNUNET_SCHEDULER_add_delayed (TIMEOUT, &terminate_task_error, NULL); 248 GNUNET_SCHEDULER_add_delayed (TIMEOUT, &terminate_task_error, NULL);
253 start_time = GNUNET_TIME_absolute_get (); 249 start_time = GNUNET_TIME_absolute_get ();
254 GNUNET_break (NULL != 250 GNUNET_break (NULL !=
255 GNUNET_CORE_notify_transmit_ready (p1.ch, 251 GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO, 0,
256 GNUNET_NO, 252 TIMEOUT, &p2.id,
257 0,
258 TIMEOUT,
259 &p2.id,
260 get_size (0), 253 get_size (0),
261 &transmit_ready, &p1)); 254 &transmit_ready, &p1));
262 } 255 }
@@ -271,14 +264,13 @@ disconnect_notify (void *cls, const struct GNUNET_PeerIdentity *peer)
271 if (0 == memcmp (&pc->id, peer, sizeof (struct GNUNET_PeerIdentity))) 264 if (0 == memcmp (&pc->id, peer, sizeof (struct GNUNET_PeerIdentity)))
272 return; 265 return;
273 pc->connect_status = 0; 266 pc->connect_status = 0;
274 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 267 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypted connection to `%4s' cut\n",
275 "Encrypted connection to `%4s' cut\n", GNUNET_i2s (peer)); 268 GNUNET_i2s (peer));
276} 269}
277 270
278 271
279static int 272static int
280inbound_notify (void *cls, 273inbound_notify (void *cls, const struct GNUNET_PeerIdentity *other,
281 const struct GNUNET_PeerIdentity *other,
282 const struct GNUNET_MessageHeader *message, 274 const struct GNUNET_MessageHeader *message,
283 const struct GNUNET_TRANSPORT_ATS_Information *atsi) 275 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
284{ 276{
@@ -291,8 +283,7 @@ inbound_notify (void *cls,
291 283
292 284
293static int 285static int
294outbound_notify (void *cls, 286outbound_notify (void *cls, const struct GNUNET_PeerIdentity *other,
295 const struct GNUNET_PeerIdentity *other,
296 const struct GNUNET_MessageHeader *message, 287 const struct GNUNET_MessageHeader *message,
297 const struct GNUNET_TRANSPORT_ATS_Information *atsi) 288 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
298{ 289{
@@ -308,8 +299,7 @@ outbound_notify (void *cls,
308static size_t transmit_ready (void *cls, size_t size, void *buf); 299static size_t transmit_ready (void *cls, size_t size, void *buf);
309 300
310static int 301static int
311process_mtype (void *cls, 302process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer,
312 const struct GNUNET_PeerIdentity *peer,
313 const struct GNUNET_MessageHeader *message, 303 const struct GNUNET_MessageHeader *message,
314 const struct GNUNET_TRANSPORT_ATS_Information *atsi) 304 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
315{ 305{
@@ -340,8 +330,7 @@ process_mtype (void *cls,
340 return GNUNET_SYSERR; 330 return GNUNET_SYSERR;
341 } 331 }
342#if VERBOSE 332#if VERBOSE
343 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 333 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got message %u of size %u\n",
344 "Got message %u of size %u\n",
345 ntohl (hdr->num), ntohs (message->size)); 334 ntohl (hdr->num), ntohs (message->size));
346#endif 335#endif
347 n++; 336 n++;
@@ -356,11 +345,8 @@ process_mtype (void *cls,
356 { 345 {
357 if (n == tr_n) 346 if (n == tr_n)
358 GNUNET_break (NULL != 347 GNUNET_break (NULL !=
359 GNUNET_CORE_notify_transmit_ready (p1.ch, 348 GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO, 0,
360 GNUNET_NO, 349 FAST_TIMEOUT, &p2.id,
361 0,
362 FAST_TIMEOUT,
363 &p2.id,
364 get_size (tr_n), 350 get_size (tr_n),
365 &transmit_ready, &p1)); 351 &transmit_ready, &p1));
366 } 352 }
@@ -376,8 +362,7 @@ static struct GNUNET_CORE_MessageHandler handlers[] = {
376 362
377 363
378static void 364static void
379init_notify (void *cls, 365init_notify (void *cls, struct GNUNET_CORE_Handle *server,
380 struct GNUNET_CORE_Handle *server,
381 const struct GNUNET_PeerIdentity *my_identity, 366 const struct GNUNET_PeerIdentity *my_identity,
382 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) 367 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey)
383{ 368{
@@ -394,14 +379,9 @@ init_notify (void *cls,
394 GNUNET_assert (ok == 2); 379 GNUNET_assert (ok == 2);
395 OKPP; 380 OKPP;
396 /* connect p2 */ 381 /* connect p2 */
397 GNUNET_CORE_connect (p2.cfg, 1, 382 GNUNET_CORE_connect (p2.cfg, 1, &p2, &init_notify, &connect_notify,
398 &p2, 383 &disconnect_notify, NULL, &inbound_notify, GNUNET_YES,
399 &init_notify, 384 &outbound_notify, GNUNET_YES, handlers);
400 &connect_notify,
401 &disconnect_notify,
402 NULL,
403 &inbound_notify,
404 GNUNET_YES, &outbound_notify, GNUNET_YES, handlers);
405 } 385 }
406 else 386 else
407 { 387 {
@@ -444,12 +424,13 @@ setup_peer (struct PeerContext *p, const char *cfgname)
444{ 424{
445 p->cfg = GNUNET_CONFIGURATION_create (); 425 p->cfg = GNUNET_CONFIGURATION_create ();
446#if START_ARM 426#if START_ARM
447 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 427 p->arm_proc =
448 "gnunet-service-arm", 428 GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
429 "gnunet-service-arm",
449#if VERBOSE 430#if VERBOSE
450 "-L", "DEBUG", 431 "-L", "DEBUG",
451#endif 432#endif
452 "-c", cfgname, NULL); 433 "-c", cfgname, NULL);
453#endif 434#endif
454 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 435 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
455 p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL); 436 p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL);
@@ -459,9 +440,8 @@ setup_peer (struct PeerContext *p, const char *cfgname)
459 440
460 441
461static void 442static void
462run (void *cls, 443run (void *cls, char *const *args, const char *cfgfile,
463 char *const *args, 444 const struct GNUNET_CONFIGURATION_Handle *cfg)
464 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
465{ 445{
466 GNUNET_assert (ok == 1); 446 GNUNET_assert (ok == 1);
467 OKPP; 447 OKPP;
@@ -469,14 +449,9 @@ run (void *cls,
469 setup_peer (&p2, "test_core_api_peer2.conf"); 449 setup_peer (&p2, "test_core_api_peer2.conf");
470 err_task = 450 err_task =
471 GNUNET_SCHEDULER_add_delayed (TIMEOUT, &terminate_task_error, NULL); 451 GNUNET_SCHEDULER_add_delayed (TIMEOUT, &terminate_task_error, NULL);
472 GNUNET_CORE_connect (p1.cfg, 1, 452 GNUNET_CORE_connect (p1.cfg, 1, &p1, &init_notify, &connect_notify,
473 &p1, 453 &disconnect_notify, NULL, &inbound_notify, GNUNET_YES,
474 &init_notify, 454 &outbound_notify, GNUNET_YES, handlers);
475 &connect_notify,
476 &disconnect_notify,
477 NULL,
478 &inbound_notify,
479 GNUNET_YES, &outbound_notify, GNUNET_YES, handlers);
480} 455}
481 456
482 457
@@ -488,8 +463,7 @@ stop_arm (struct PeerContext *p)
488 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 463 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
489 if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) 464 if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK)
490 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); 465 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
491 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 466 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n",
492 "ARM process %u stopped\n",
493 GNUNET_OS_process_get_pid (p->arm_proc)); 467 GNUNET_OS_process_get_pid (p->arm_proc));
494 GNUNET_OS_process_close (p->arm_proc); 468 GNUNET_OS_process_close (p->arm_proc);
495 p->arm_proc = NULL; 469 p->arm_proc = NULL;
@@ -512,9 +486,9 @@ check ()
512 GNUNET_GETOPT_OPTION_END 486 GNUNET_GETOPT_OPTION_END
513 }; 487 };
514 ok = 1; 488 ok = 1;
515 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, 489 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv,
516 argv, "test-core-api-reliability", "nohelp", options, 490 "test-core-api-reliability", "nohelp", options, &run,
517 &run, &ok); 491 &ok);
518 stop_arm (&p1); 492 stop_arm (&p1);
519 stop_arm (&p2); 493 stop_arm (&p2);
520 return ok; 494 return ok;