aboutsummaryrefslogtreecommitdiff
path: root/src/integration-tests
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-04-11 16:03:28 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-04-11 16:03:28 +0000
commit49c651104a2b57579992050db0242a27ba9c6c4d (patch)
tree32c545721acfc46ae03f32f8379fa6ef9edb204c /src/integration-tests
parent9404025ec2ea2d44468c072a299a4d1e8f229ebb (diff)
downloadgnunet-49c651104a2b57579992050db0242a27ba9c6c4d.tar.gz
gnunet-49c651104a2b57579992050db0242a27ba9c6c4d.zip
- fixes
Diffstat (limited to 'src/integration-tests')
-rw-r--r--src/integration-tests/connection_watchdog.c140
1 files changed, 84 insertions, 56 deletions
diff --git a/src/integration-tests/connection_watchdog.c b/src/integration-tests/connection_watchdog.c
index 89ec25c7d..ef1023a41 100644
--- a/src/integration-tests/connection_watchdog.c
+++ b/src/integration-tests/connection_watchdog.c
@@ -378,34 +378,6 @@ int stats_check_cb (void *cls, const char *subsystem,
378 return GNUNET_OK; 378 return GNUNET_OK;
379} 379}
380 380
381
382static void
383stats_check (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
384{
385 statistics_task = GNUNET_SCHEDULER_NO_TASK;
386
387 if (GNUNET_YES == stat_check_running)
388 {
389 statistics_task = GNUNET_SCHEDULER_add_delayed(STATS_DELAY, &stats_check, NULL);
390 }
391
392 stat_check_running = GNUNET_YES;
393
394 statistics_transport_connections = 0 ;
395 statistics_core_entries_session_map = 0;
396 statistics_core_neighbour_entries = 0;
397
398 GNUNET_STATISTICS_get (stats, "transport", "# peers connected", GNUNET_TIME_UNIT_MINUTES, NULL, &stats_check_cb, &statistics_transport_connections);
399 GNUNET_STATISTICS_get (stats, "core", "# neighbour entries allocated", GNUNET_TIME_UNIT_MINUTES, NULL, &stats_check_cb, &statistics_core_neighbour_entries);
400 GNUNET_STATISTICS_get (stats, "core", "# entries in session map", GNUNET_TIME_UNIT_MINUTES, NULL, &stats_check_cb, &statistics_core_entries_session_map);
401
402 /* TCP plugin specific checks */
403 if (GNUNET_YES == have_tcp)
404 GNUNET_STATISTICS_get (stats, "transport", "# TCP sessions active", GNUNET_TIME_UNIT_MINUTES, NULL, &stats_check_cb, &statistics_transport_tcp_connections);
405
406
407}
408
409GNUNET_NETWORK_STRUCT_BEGIN 381GNUNET_NETWORK_STRUCT_BEGIN
410 382
411struct PING 383struct PING
@@ -424,31 +396,7 @@ struct PONG
424GNUNET_NETWORK_STRUCT_END 396GNUNET_NETWORK_STRUCT_END
425 397
426 398
427 size_t send_transport_ping_cb (void *cls, size_t size, void *buf) 399size_t send_transport_ping_cb (void *cls, size_t size, void *buf)
428{
429 struct PeerContainer * pc = cls;
430 struct PING ping;
431 size_t mlen = sizeof (struct PING);
432
433 if (size < mlen)
434 {
435 GNUNET_break (0);
436 return 0;
437 }
438
439 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
440 "Sending transport ping to `%s'\n", GNUNET_i2s (&pc->id));
441 ping.header.size = htons (mlen);
442 ping.header.type = htons (1234);
443 ping.src = htons (0);
444
445 pc->th_ping = NULL;
446
447 memcpy (buf, &ping, mlen);
448 return mlen;
449}
450
451size_t send_core_ping_cb (void *cls, size_t size, void *buf)
452{ 400{
453 struct PeerContainer * pc = cls; 401 struct PeerContainer * pc = cls;
454 struct PING ping; 402 struct PING ping;
@@ -461,17 +409,97 @@ size_t send_core_ping_cb (void *cls, size_t size, void *buf)
461 } 409 }
462 410
463 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 411 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
464 "Sending core ping to `%s'\n", GNUNET_i2s (&pc->id)); 412 "Sending transport ping to `%s'\n", GNUNET_i2s (&pc->id));
465 ping.header.size = htons (mlen); 413 ping.header.size = htons (mlen);
466 ping.header.type = htons (1234); 414 ping.header.type = htons (1234);
467 ping.src = htons (1); 415 ping.src = htons (0);
468 416
469 pc->ch_ping = NULL; 417 pc->th_ping = NULL;
470 418
471 memcpy (buf, &ping, mlen); 419 memcpy (buf, &ping, mlen);
472 return mlen; 420 return mlen;
473} 421}
474 422
423size_t send_core_ping_cb (void *cls, size_t size, void *buf)
424{
425struct PeerContainer * pc = cls;
426struct PING ping;
427size_t mlen = sizeof (struct PING);
428
429if (size < mlen)
430{
431 GNUNET_break (0);
432 return 0;
433}
434
435GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
436 "Sending core ping to `%s'\n", GNUNET_i2s (&pc->id));
437ping.header.size = htons (mlen);
438ping.header.type = htons (1234);
439ping.src = htons (1);
440
441pc->ch_ping = NULL;
442
443memcpy (buf, &ping, mlen);
444return mlen;
445}
446
447
448int map_ping_it (void *cls,
449 const GNUNET_HashCode * key,
450 void *value)
451{
452 struct PeerContainer *pc = value;
453
454 if ((GNUNET_YES == pc->transport_connected) && (NULL == pc->th_ping))
455 pc->th_ping = GNUNET_TRANSPORT_notify_transmit_ready(th, &pc->id,
456 sizeof (struct PING), UINT_MAX,
457 GNUNET_TIME_relative_get_forever(), &send_transport_ping_cb, pc);
458 else
459 GNUNET_break(0);
460
461 if ((GNUNET_YES == pc->core_connected) && (NULL == pc->ch_ping))
462 pc->ch_ping = GNUNET_CORE_notify_transmit_ready(ch,
463 GNUNET_NO, UINT_MAX,
464 GNUNET_TIME_relative_get_forever(),
465 &pc->id,
466 sizeof (struct PING),
467 send_core_ping_cb, pc);
468 else
469 GNUNET_break (0);
470
471 return GNUNET_OK;
472}
473
474
475static void
476stats_check (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
477{
478 statistics_task = GNUNET_SCHEDULER_NO_TASK;
479
480 if (GNUNET_YES == stat_check_running)
481 {
482 statistics_task = GNUNET_SCHEDULER_add_delayed(STATS_DELAY, &stats_check, NULL);
483 }
484
485 GNUNET_CONTAINER_multihashmap_iterate (peers, &map_ping_it, NULL);
486
487 stat_check_running = GNUNET_YES;
488
489 statistics_transport_connections = 0 ;
490 statistics_core_entries_session_map = 0;
491 statistics_core_neighbour_entries = 0;
492
493 GNUNET_STATISTICS_get (stats, "transport", "# peers connected", GNUNET_TIME_UNIT_MINUTES, NULL, &stats_check_cb, &statistics_transport_connections);
494 GNUNET_STATISTICS_get (stats, "core", "# neighbour entries allocated", GNUNET_TIME_UNIT_MINUTES, NULL, &stats_check_cb, &statistics_core_neighbour_entries);
495 GNUNET_STATISTICS_get (stats, "core", "# entries in session map", GNUNET_TIME_UNIT_MINUTES, NULL, &stats_check_cb, &statistics_core_entries_session_map);
496
497 /* TCP plugin specific checks */
498 if (GNUNET_YES == have_tcp)
499 GNUNET_STATISTICS_get (stats, "transport", "# TCP sessions active", GNUNET_TIME_UNIT_MINUTES, NULL, &stats_check_cb, &statistics_transport_tcp_connections);
500}
501
502
475 503
476size_t send_transport_pong_cb (void *cls, size_t size, void *buf) 504size_t send_transport_pong_cb (void *cls, size_t size, void *buf)
477{ 505{