diff options
author | Bart Polot <bart@net.in.tum.de> | 2014-03-14 15:49:19 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2014-03-14 15:49:19 +0000 |
commit | 141f89d7b89449954cbd38b4930507fcdba5c607 (patch) | |
tree | ab93db614f67a8f8c44b442290d384ee8090e55b /src | |
parent | dad57038f070f1ec10f8ea51240adfaa44d5b458 (diff) | |
download | gnunet-141f89d7b89449954cbd38b4930507fcdba5c607.tar.gz gnunet-141f89d7b89449954cbd38b4930507fcdba5c607.zip |
- don't send duplicate pings when a pong is delayed
Diffstat (limited to 'src')
-rw-r--r-- | src/mesh/gnunet-mesh-profiler.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/mesh/gnunet-mesh-profiler.c b/src/mesh/gnunet-mesh-profiler.c index b26816f63..c0c0bfe30 100644 --- a/src/mesh/gnunet-mesh-profiler.c +++ b/src/mesh/gnunet-mesh-profiler.c | |||
@@ -376,8 +376,10 @@ ping (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
376 | struct MeshPeer *peer = (struct MeshPeer *) cls; | 376 | struct MeshPeer *peer = (struct MeshPeer *) cls; |
377 | 377 | ||
378 | peer->ping_task = GNUNET_SCHEDULER_NO_TASK; | 378 | peer->ping_task = GNUNET_SCHEDULER_NO_TASK; |
379 | |||
379 | if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0 | 380 | if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0 |
380 | || GNUNET_YES == test_finished) | 381 | || GNUNET_YES == test_finished |
382 | || 0 != peer->timestamp.abs_value_us) | ||
381 | return; | 383 | return; |
382 | 384 | ||
383 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%u -> %u\n", | 385 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%u -> %u\n", |
@@ -505,12 +507,21 @@ pong_handler (void *cls, struct GNUNET_MESH_Channel *channel, | |||
505 | GNUNET_MESH_receive_done (channel); | 507 | GNUNET_MESH_receive_done (channel); |
506 | peer = &peers[n]; | 508 | peer = &peers[n]; |
507 | 509 | ||
508 | GNUNET_assert (0 != peer->timestamp.abs_value_us); | 510 | GNUNET_break (0 != peer->timestamp.abs_value_us); |
509 | latency = GNUNET_TIME_absolute_get_duration (peer->incoming->timestamp); | 511 | latency = GNUNET_TIME_absolute_get_duration (peer->timestamp); |
510 | FPRINTF (stderr, "%u -> %ld latency: %s\n", | 512 | FPRINTF (stderr, "%ld latency: %s\n", |
511 | get_index (peer->incoming), n, | 513 | n, GNUNET_STRINGS_relative_time_to_string (latency, GNUNET_NO)); |
512 | GNUNET_STRINGS_relative_time_to_string (latency, GNUNET_NO)); | 514 | |
513 | peer->timestamp.abs_value_us = 0; | 515 | if (GNUNET_SCHEDULER_NO_TASK == peer->ping_task) |
516 | { | ||
517 | peer->timestamp = GNUNET_TIME_absolute_get (); | ||
518 | peer->ping_task = GNUNET_SCHEDULER_add_delayed (delay_ms_rnd (60 * 1000), | ||
519 | &ping, peer); | ||
520 | } | ||
521 | else | ||
522 | { | ||
523 | peer->timestamp.abs_value_us = 0; | ||
524 | } | ||
514 | 525 | ||
515 | return GNUNET_OK; | 526 | return GNUNET_OK; |
516 | } | 527 | } |