gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r9719 - gnunet/src/arm


From: gnunet
Subject: [GNUnet-SVN] r9719 - gnunet/src/arm
Date: Tue, 8 Dec 2009 14:46:21 +0100

Author: grothoff
Date: 2009-12-08 14:46:21 +0100 (Tue, 08 Dec 2009)
New Revision: 9719

Modified:
   gnunet/src/arm/gnunet-service-arm.c
Log:
fix

Modified: gnunet/src/arm/gnunet-service-arm.c
===================================================================
--- gnunet/src/arm/gnunet-service-arm.c 2009-12-08 12:12:28 UTC (rev 9718)
+++ gnunet/src/arm/gnunet-service-arm.c 2009-12-08 13:46:21 UTC (rev 9719)
@@ -686,6 +686,52 @@
 
 
 /**
+ * Remove all entries for tasks that are not running
+ * (pid = 0) from the running list (they will no longer
+ * be restarted since we are shutting down).
+ */
+static void
+clean_up_running ()
+{
+  struct ServiceList *pos;
+  struct ServiceList *next;
+  struct ServiceList *prev;
+ 
+  pos = running;
+  prev = NULL;
+  while (NULL != pos)
+    {
+      next = pos->next;
+      if (pos->pid == 0)
+       {
+         if (prev == NULL)
+           running = next;
+         else
+           prev->next = next;
+         free_entry (pos);
+       }
+      pos = next;
+    }
+}
+
+
+/**
+ * We are done with everything.  Stop remaining 
+ * tasks, signal handler and the server. 
+ */
+static void
+do_shutdown ()
+{
+  GNUNET_SERVER_destroy (server);
+  server = NULL;
+  GNUNET_SIGNAL_handler_uninstall (shc_chld);
+  shc_chld = NULL;
+  GNUNET_SCHEDULER_cancel (sched, child_death_task);
+  child_death_task = GNUNET_SCHEDULER_NO_TASK;
+}
+
+
+/**
  * Task run for shutdown.
  *
  * @param cls closure, NULL if we need to self-restart
@@ -695,16 +741,12 @@
 shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct ServiceList *pos;
-  struct ServiceList *next;
-  struct ServiceList *prev;
  
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Stopping all services\n"));
   in_shutdown = GNUNET_YES;
   pos = running;
-  prev = NULL;
   while (NULL != pos)
     {
-      next = pos->next;
       if (pos->pid != 0)
        {
 #if DEBUG_ARM
@@ -713,27 +755,11 @@
 #endif
          if (0 != PLIBC_KILL (pos->pid, SIGTERM))
            GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
-         prev = pos;      
        }
-      else
-       {
-         if (prev == NULL)
-           running = next;
-         else
-           prev->next = next;
-         free_entry (pos);
-       }
-      pos = next;
+      pos = pos->next;
     }
   if (running == NULL)
-    {
-      GNUNET_SERVER_destroy (server);
-      server = NULL;
-      GNUNET_SIGNAL_handler_uninstall (shc_chld);
-      shc_chld = NULL;
-      GNUNET_SCHEDULER_cancel (sched, child_death_task);
-      child_death_task = GNUNET_SCHEDULER_NO_TASK;
-    }
+    do_shutdown ();
 }
 
 
@@ -751,7 +777,12 @@
 
   child_restart_task = GNUNET_SCHEDULER_NO_TASK;
   if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
-    return;
+    {
+      clean_up_running ();
+      if (NULL == running)
+       do_shutdown ();
+      return;
+    }
   lowestRestartDelay = GNUNET_TIME_UNIT_FOREVER_REL;
 
   /* check for services that need to be restarted due to
@@ -805,7 +836,7 @@
   char c;
 
   child_death_task = GNUNET_SCHEDULER_NO_TASK;
-  if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
+  if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY))
     {
       child_death_task =
        GNUNET_SCHEDULER_add_read_file (sched, GNUNET_TIME_UNIT_FOREVER_REL, pr,
@@ -879,9 +910,10 @@
          if (GNUNET_SCHEDULER_NO_TASK != child_restart_task)
            GNUNET_SCHEDULER_cancel (sched, child_restart_task);
          child_restart_task 
-           = GNUNET_SCHEDULER_add_now (sched,
-                                       &delayed_restart_task,
-                                       NULL);
+           = GNUNET_SCHEDULER_add_with_priority (sched,
+                                                 
GNUNET_SCHEDULER_PRIORITY_IDLE,
+                                                 &delayed_restart_task,
+                                                 NULL);
        }
 #if DEBUG_ARM
       else





reply via email to

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