From 735f41d33d2cba35f3983dca4c102fece725873d Mon Sep 17 00:00:00 2001 From: Lukas Pukenis Date: Mon, 20 Jan 2025 16:29:30 +0200 Subject: [PATCH] Make a log before calling callback This might be useful to track down if the callback might be delayed. Sometimes the test logs report a difference of a few seconds between natlab receiving the event and telio emitting it. This commit will allow to narrow it down. Signed-off-by: Lukas Pukenis --- nat-lab/tests/test_events.py | 2 +- src/device.rs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/nat-lab/tests/test_events.py b/nat-lab/tests/test_events.py index b414b96de..54db3f945 100644 --- a/nat-lab/tests/test_events.py +++ b/nat-lab/tests/test_events.py @@ -186,7 +186,7 @@ async def test_event_content_meshnet( await client_alpha.set_meshnet_config(api.get_meshnet_config(alpha.id)) - # Telio and NatLab both have a sampling rate of 1 second. + # Telio and NatLab both have a sampling rate of 1 second. # As a result, in the worst case, an event could be delayed by up to 2 seconds. await client_alpha.wait_for_state_peer( beta.public_key, [NodeState.DISCONNECTED], [PathType.DIRECT], timeout=2 diff --git a/src/device.rs b/src/device.rs index ee4470a4e..56221d373 100644 --- a/src/device.rs +++ b/src/device.rs @@ -520,7 +520,10 @@ impl Device { .name("libtelio-events".to_owned()) .spawn(move || loop { match event_rx.blocking_recv() { - Ok(event) => event_cb(event), + Ok(event) => { + telio_log_debug!("EVENT: Just before event callback: {:?}", event); + event_cb(event); + } Err(RecvError::Lagged(n)) => { telio_log_warn!("Failed to receive new event, lagged: {n}") }