gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r23455 - gnunet-gtk/src/setup


From: gnunet
Subject: [GNUnet-SVN] r23455 - gnunet-gtk/src/setup
Date: Mon, 27 Aug 2012 20:52:56 +0200

Author: grothoff
Date: 2012-08-27 20:52:56 +0200 (Mon, 27 Aug 2012)
New Revision: 23455

Modified:
   gnunet-gtk/src/setup/gnunet-setup.c
Log:
detect if resolver/namestore are already running before starting them

Modified: gnunet-gtk/src/setup/gnunet-setup.c
===================================================================
--- gnunet-gtk/src/setup/gnunet-setup.c 2012-08-27 18:52:39 UTC (rev 23454)
+++ gnunet-gtk/src/setup/gnunet-setup.c 2012-08-27 18:52:56 UTC (rev 23455)
@@ -29,6 +29,7 @@
 #include "gnunet-setup.h"
 #include "gnunet-setup-options.h"
 #include "gnunet-setup-gns.h"
+#include <gnunet/gnunet_constants.h>
 #include <regex.h>
 
 /**
@@ -380,6 +381,50 @@
 
 
 /**
+ * If the test failed, start the resolver process.
+ *
+ * @param cls closure, NULL
+ * @param tc task context, reason is TIMEOUT if we need to
+ *                start the process
+ */
+static void
+start_resolver (void *cls,
+               const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT))
+    return;
+  resolver =
+    GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_ALL,
+                             NULL,NULL,
+                             "gnunet-service-resolver",
+                            "gnunet-service-resolver", NULL);
+}
+
+
+/**
+ * If the test failed, start the namestore process.
+ *
+ * @param cls closure, NULL
+ * @param tc task context, reason is TIMEOUT if we need to
+ *                start the process
+ */
+static void
+start_namestore (void *cls,
+                const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT))
+    return;
+  if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
+    return;
+  namestore =
+    GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_ALL,
+                             NULL, NULL,
+                             "gnunet-service-namestore",
+                            "gnunet-service-namestore", NULL);
+}
+
+
+/**
  * Actual main method that sets up the configuration window.
  *
  * @param cls the main loop handle
@@ -401,16 +446,14 @@
   cfg = GNUNET_CONFIGURATION_create ();
   (void) GNUNET_CONFIGURATION_load (cfg, cfgName);
   main_window = GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_dialog"));
-  resolver =
-    GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_ALL,
-                             NULL,NULL,
-                             "gnunet-service-resolver",
-                            "gnunet-service-resolver", NULL);
-  namestore =
-    GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_ALL,
-                             NULL, NULL,
-                             "gnunet-service-namestore",
-                            "gnunet-service-namestore", NULL);
+  GNUNET_CLIENT_service_test ("resolver",
+                             cfg,
+                             GNUNET_CONSTANTS_SERVICE_RETRY,
+                             &start_resolver, NULL);
+  GNUNET_CLIENT_service_test ("resolver",
+                             cfg,
+                             GNUNET_CONSTANTS_SERVICE_RETRY,
+                             &start_namestore, NULL);
   load_options ();
   GNUNET_SETUP_gns_init ();
   gtk_widget_show (main_window);




reply via email to

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