commit 9b2d42f4c528539a3b1ad4effdd457d8df9f47bc
parent 3a2ca390d9756f17f1c54e74bbc922cbbc38ccd0
Author: Jacki <jacki@thejackimonster.de>
Date: Tue, 4 Feb 2025 04:46:03 +0100
Add timeout as parameter to ping tool
Signed-off-by: Jacki <jacki@thejackimonster.de>
Diffstat:
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/tools/gnunet_messenger_ping.c b/tools/gnunet_messenger_ping.c
@@ -45,6 +45,7 @@ struct GNUNET_MESSENGER_PingTool
char *ego_name;
char *room_name;
uint count;
+ uint timeout;
int public_room;
int auto_pong;
int require_pong;
@@ -83,7 +84,8 @@ idle (void *cls)
if ((tool->auto_pong) && (!(tool->quit)))
{
tool->task = GNUNET_SCHEDULER_add_delayed_with_priority(
- GNUNET_TIME_relative_get_second_(),
+ GNUNET_TIME_relative_multiply(
+ GNUNET_TIME_relative_get_second_(), tool->timeout),
GNUNET_SCHEDULER_PRIORITY_IDLE,
idle,
tool
@@ -409,7 +411,8 @@ skip_ping:
GNUNET_SCHEDULER_cancel(tool->task);
tool->task = GNUNET_SCHEDULER_add_delayed_with_priority(
- GNUNET_TIME_relative_get_second_(),
+ GNUNET_TIME_relative_multiply(
+ GNUNET_TIME_relative_get_second_(), tool->timeout),
GNUNET_SCHEDULER_PRIORITY_IDLE,
idle,
tool
@@ -577,6 +580,13 @@ main (int argc,
"stop after a count of iterations",
&(tool.count)
),
+ GNUNET_GETOPT_option_uint(
+ 't',
+ "timeout",
+ "<timeout>",
+ "stop after a timeout in seconds",
+ &(tool.timeout)
+ ),
GNUNET_GETOPT_option_flag(
'p',
"public",