From 38c3b94819bbd273d930ada8107a1345d7b3a9f5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Philipp=20T=C3=B6lke?= Date: Tue, 19 Oct 2010 21:16:47 +0000 Subject: [PATCH] Ratelimit the starting of the vpn-helper --- src/vpn/gnunet-daemon-vpn.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/vpn/gnunet-daemon-vpn.c b/src/vpn/gnunet-daemon-vpn.c index 43fe356ff..35dc32f1f 100644 --- a/src/vpn/gnunet-daemon-vpn.c +++ b/src/vpn/gnunet-daemon-vpn.c @@ -80,8 +80,13 @@ static void cleanup(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tskctx static void helper_read(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tsdkctx); -static void start_helper_and_schedule() { - mycls.helper_in = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_YES, GNUNET_NO);; +static void start_helper_and_schedule(void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc) { + + if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) + return; + + mycls.helper_in = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_YES, GNUNET_NO); mycls.helper_out = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_NO, GNUNET_YES); if (mycls.helper_in == NULL || mycls.helper_out == NULL) return; @@ -99,8 +104,6 @@ static void start_helper_and_schedule() { static void restart_helper(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tskctx) { - // FIXME: Ratelimit this! - // Kill the helper PLIBC_KILL(mycls.helper_pid, SIGKILL); GNUNET_OS_process_wait(mycls.helper_pid); @@ -111,7 +114,7 @@ static void restart_helper(void* cls, const struct GNUNET_SCHEDULER_TaskContext* GNUNET_DISK_pipe_close(mycls.helper_out); // Restart the helper - start_helper_and_schedule(mycls); + GNUNET_SCHEDULER_add_delayed (mycls.sched, GNUNET_TIME_UNIT_SECONDS, start_helper_and_schedule, NULL); } @@ -333,7 +336,7 @@ run (void *cls, mycls.cfg = cfg; GNUNET_SCHEDULER_add_now (sched, &reconnect_to_service_dns, NULL); GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_UNIT_FOREVER_REL, &cleanup, cls); - start_helper_and_schedule(mycls); + GNUNET_SCHEDULER_add_now (sched, start_helper_and_schedule, NULL); } -- 2.25.1