fix arm termination on W32 by enabling signalling pipe to be used
[oweals/gnunet.git] / src / testing / testing.c
index b35f597bf0c895b2116d6c2ac79bd574be8c6204..31bea068cfe84836f6d643a87237cf0cf3ab2fba 100644 (file)
@@ -214,7 +214,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
         cb (d->cb_cls, NULL, d->cfg, d, _("`scp' did not complete cleanly.\n"));
       return;
     }
-    GNUNET_OS_process_close (d->proc_arm_copying);
+    GNUNET_OS_process_destroy (d->proc_arm_copying);
     d->proc_arm_copying = NULL;
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Successfully copied configuration file.\n");
@@ -362,7 +362,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
       d->pipe_stdout = NULL;
       (void) GNUNET_OS_process_kill (d->proc_arm_peerinfo, SIGKILL);      
       GNUNET_break (GNUNET_OK == GNUNET_OS_process_wait (d->proc_arm_peerinfo));
-      GNUNET_OS_process_close (d->proc_arm_peerinfo);      
+      GNUNET_OS_process_destroy (d->proc_arm_peerinfo);
       d->proc_arm_peerinfo = NULL;
       if (NULL != cb)
         cb (d->cb_cls, NULL, d->cfg, d, _("Failed to get hostkey!\n"));
@@ -373,7 +373,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
     d->pipe_stdout = NULL;
     (void) GNUNET_OS_process_kill (d->proc_arm_peerinfo, SIGKILL);
     GNUNET_break (GNUNET_OK == GNUNET_OS_process_wait (d->proc_arm_peerinfo));
-    GNUNET_OS_process_close (d->proc_arm_peerinfo);
+    GNUNET_OS_process_destroy (d->proc_arm_peerinfo);
     d->proc_arm_peerinfo = NULL;
     d->have_hostkey = GNUNET_YES;
     if (d->hostkey_callback != NULL)
@@ -410,13 +410,12 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
     if (NULL == d->hostname)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                  "Starting `%s', with command `%s %s %s %s %s %s'.\n",
-                  "gnunet-arm", "gnunet-arm", "-c", d->cfgfile, "-L", "DEBUG",
+                  "Starting `%s', with command `%s %s %s %s'.\n",
+                  "gnunet-arm", "gnunet-arm", "-c", d->cfgfile, 
                   "-s");
       d->proc_arm_start =
          GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-arm", "gnunet-arm", "-c",
                                    d->cfgfile,
-                                   "-L", "DEBUG",
                                    "-s", "-q", "-T",
                                    GNUNET_TIME_relative_to_string
                                    (GNUNET_TIME_absolute_get_remaining
@@ -430,9 +429,9 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
         dst = GNUNET_strdup (d->hostname);
 
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                  "Starting `%s', with command `%s %s %s %s %s %s %s %s'.\n",
+                  "Starting `%s', with command `%s %s %s %s %s %s %s'.\n",
                   "gnunet-arm", "ssh", dst, "gnunet-arm", "-c", d->cfgfile,
-                  "-L", "DEBUG", "-s", "-q");
+                  "-s", "-q");
       if (d->ssh_port_str == NULL)
       {
         d->proc_arm_start = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh",
@@ -479,6 +478,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
     d->task =
         GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm,
                                       d);
+        // FIXME: busy wait?
     break;
   case SP_START_ARMING:
     if (GNUNET_OK != GNUNET_OS_process_status (d->proc_arm_start, &type, &code))
@@ -504,8 +504,9 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
         }
         GNUNET_free_non_null (d->hostname);
         GNUNET_free_non_null (d->username);
-        GNUNET_free (d->proc_arm_start);
+        GNUNET_OS_process_destroy (d->proc_arm_start);
        d->proc_arm_start = NULL;
+       d->username = NULL;
         d->hostname = NULL;     // Quick hack to avoid crashing (testing need to be
         d->cfg = NULL;          // overhauled anyway, and the error managing is
        // GNUNET_free (d); // FIXME (could this leak)
@@ -516,11 +517,12 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
       d->task =
           GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm,
                                         d);
+          // FIXME: busy wait?
       return;
     }
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Successfully started `%s'.\n",
                 "gnunet-arm");
-    GNUNET_free (d->proc_arm_start);
+    GNUNET_OS_process_destroy (d->proc_arm_start);
     d->proc_arm_start = NULL;
     d->phase = SP_START_CORE;
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Calling CORE_connect\n");
@@ -626,7 +628,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
     d->phase = SP_START_DONE;
     if (NULL != cb)
       cb (d->cb_cls, &d->id, d->cfg, d, NULL);
-    GNUNET_free (d->proc_arm_srv_start);
+    GNUNET_OS_process_destroy (d->proc_arm_srv_start);
     d->proc_arm_srv_start = NULL;
     break;
   case SP_SERVICE_SHUTDOWN_START:
@@ -692,8 +694,8 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
         GNUNET_free_non_null (d->hostname);
         GNUNET_free_non_null (d->username);
         GNUNET_free_non_null (d->shortname);
-        // GNUNET_free_non_null (d->proc); // !? FIXME
-        // d->proc_arm_stop = NULL; 
+        GNUNET_OS_process_destroy (d->proc_arm_stop);
+        d->proc_arm_stop = NULL;
         GNUNET_free (d);
         return;
       }
@@ -728,8 +730,8 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
       GNUNET_free_non_null (d->hostname);
       GNUNET_free_non_null (d->username);
       GNUNET_free_non_null (d->shortname);
-      // GNUNET_free_non_null (d->proc); // !? FIXME!
-      // d->proc = NULL; // !? FIXME!
+      GNUNET_OS_process_destroy (d->proc_arm_stop);
+      d->proc_arm_stop = NULL;
       GNUNET_free (d);
       return;
     }
@@ -764,8 +766,8 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
     GNUNET_free_non_null (d->hello);
     d->hello = NULL;
     GNUNET_free_non_null (d->shortname);
-    // GNUNET_free_non_null (d->proc); // !? FIXME
-    // d->proc = NULL; // !? FIXME!
+    GNUNET_OS_process_destroy (d->proc_arm_stop);
+    d->proc_arm_stop = NULL;
     d->shortname = NULL;
     if (d->churn == GNUNET_NO)
       GNUNET_free (d);
@@ -1411,9 +1413,9 @@ GNUNET_TESTING_daemon_stop_service (struct GNUNET_TESTING_Daemon *d,
 static void
 kill_and_close_process (struct GNUNET_OS_Process *proc)
 {
-  (void) GNUNET_OS_process_kill (proc, SIGKILL);      
+  (void) GNUNET_OS_process_kill (proc, SIGKILL); 
   GNUNET_break (GNUNET_OK == GNUNET_OS_process_wait (proc));
-  GNUNET_OS_process_close (proc);
+  GNUNET_OS_process_destroy (proc);
 }
 
 
@@ -1473,9 +1475,10 @@ GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d,
     kill_and_close_process (d->proc_arm_peerinfo);
     d->proc_arm_peerinfo = NULL;
   }
-  if ((d->running == GNUNET_NO) && (d->churn == GNUNET_YES))    /* Peer has already been stopped in churn context! */
+  if ((d->running == GNUNET_NO) && (d->churn == GNUNET_YES))
   {
-    /* Free what was left from churning! */
+    /* Peer has already been stopped in churn context!
+     * Free what was left from churning! */
     GNUNET_assert (d->cfg != NULL);
     GNUNET_CONFIGURATION_destroy (d->cfg);
     if (delete_files == GNUNET_YES)