working version
[oweals/gnunet.git] / src / arm / gnunet-service-arm.c
index e85b2eb129bb51a7a24c20fa1138e67405c73966..718d902807a44a1104650d4a283c06239c812a9a 100644 (file)
@@ -103,12 +103,12 @@ struct ServiceList
   time_t mtime;
 
   /**
-   * Process exponential backoff time 
+   * Process exponential backoff time
    */
   struct GNUNET_TIME_Relative backoff;
 
   /**
-   * Absolute time at which the process is scheduled to restart in case of death 
+   * Absolute time at which the process is scheduled to restart in case of death
    */
   struct GNUNET_TIME_Absolute restartAt;
 
@@ -631,8 +631,8 @@ clean_up_running ()
 
 
 /**
- * We are done with everything.  Stop remaining 
- * tasks, signal handler and the server. 
+ * We are done with everything.  Stop remaining
+ * tasks, signal handler and the server.
  */
 static void
 do_shutdown ()
@@ -660,6 +660,7 @@ static void
 shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct ServiceList *pos;
+  struct ServiceList *nxt;
 
 #if DEBUG_ARM
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Stopping all services\n"));
@@ -674,13 +675,18 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   pos = running_head;
   while (NULL != pos)
   {
+    nxt = pos->next;
     if (pos->proc != NULL)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stopping service `%s'\n", pos->name);
       if (0 != GNUNET_OS_process_kill (pos->proc, SIGTERM))
         GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
     }
-    pos = pos->next;
+    else
+    {
+      free_service (pos);
+    }
+    pos = nxt;
   }
   if (running_head == NULL)
     do_shutdown ();
@@ -743,7 +749,7 @@ delayed_restart_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 
 /**
  * Task triggered whenever we receive a SIGCHLD (child
- * process died).  
+ * process died).
  *
  * @param cls closure, NULL if we need to self-restart
  * @param tc context