gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r13304 - gnunet/src/vpn


From: gnunet
Subject: [GNUnet-SVN] r13304 - gnunet/src/vpn
Date: Tue, 19 Oct 2010 23:16:47 +0200

Author: toelke
Date: 2010-10-19 23:16:47 +0200 (Tue, 19 Oct 2010)
New Revision: 13304

Modified:
   gnunet/src/vpn/gnunet-daemon-vpn.c
Log:
Ratelimit the starting of the vpn-helper

Modified: gnunet/src/vpn/gnunet-daemon-vpn.c
===================================================================
--- gnunet/src/vpn/gnunet-daemon-vpn.c  2010-10-19 21:16:46 UTC (rev 13303)
+++ gnunet/src/vpn/gnunet-daemon-vpn.c  2010-10-19 21:16:47 UTC (rev 13304)
@@ -80,8 +80,13 @@
 
 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 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 @@
        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 @@
   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);
 }
 
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]