[pisa-src] r1505 - in trunk: libpisa/global.h libpisa/util.c pisacd/cdmain.c pisasd/sdmain.c

  • From: René Hummen <rene.hummen@xxxxxxxxxxxxxx>
  • To: pisa-src@xxxxxxxxxxxxx
  • Date: Tue, 03 Nov 2009 16:50:31 +0100

Author: hummen
Date: Tue Nov  3 16:50:30 2009
New Revision: 1505

Log:
Modified behavior of pisa*d when hipd is not started upfront.

The previous implementation would start a hipd from the path.
Thus, it would be unknown to the user, which hipd is running
at the moment. This is especially fatal, when different
versions are available on the host and the user wants to use
a specific one.

Modified:
   trunk/libpisa/global.h
   trunk/libpisa/util.c
   trunk/pisacd/cdmain.c
   trunk/pisasd/sdmain.c

Modified: trunk/libpisa/global.h
==============================================================================
--- trunk/libpisa/global.h      Tue Nov  3 15:11:34 2009        (r1504)
+++ trunk/libpisa/global.h      Tue Nov  3 16:50:30 2009        (r1505)
@@ -179,6 +179,11 @@
 #define PISA_CERT_LENGTH       992
 
 /**
+ * Timeout for checks, whether hipd is running or not.
+ */
+#define WAIT_FOR_HIPD_TIMEOUT 3
+
+/**
  * Types which are necessary for TLV(Type-Length-Value)
  */
 typedef uint16_t pisa_tlv_type;

Modified: trunk/libpisa/util.c
==============================================================================
--- trunk/libpisa/util.c        Tue Nov  3 15:11:34 2009        (r1504)
+++ trunk/libpisa/util.c        Tue Nov  3 16:50:30 2009        (r1505)
@@ -178,6 +178,11 @@
        if (pisa_check_if_hipd_runs())
                return 0;
 
+       /* This would start a hipd in the path. It would be unknown
+        * to the user, which hipd is running at the moment. This is
+        * especially fatal, when different versions are available
+        * on the host and the user wants to use a specific one.
+        */
        return system("hipd -bk") == 0 ? 0 : -1;
 }
 

Modified: trunk/pisacd/cdmain.c
==============================================================================
--- trunk/pisacd/cdmain.c       Tue Nov  3 15:11:34 2009        (r1504)
+++ trunk/pisacd/cdmain.c       Tue Nov  3 16:50:30 2009        (r1505)
@@ -13,6 +13,7 @@
 #include <signal.h>
 #include <getopt.h>
 #include <sys/utsname.h>
+#include <unistd.h>
 
 #include "libpisa/tunnel.h"
 #include "libpisa/util.h"
@@ -360,10 +361,18 @@
         * cdconf_* operations except for cdconf_init. */
        cd_get_cmdargs(argc, argv);
 
-       if (pisa_make_hipd_run() < 0) {
-               /* TODO: is there any other ways than stopping here? */
-               PISA_ERROR("hipd cannot be executed. stop.\n");
-               exit(EXIT_FAILURE);
+       /* Check, whether hipd is running. This is a requirement for
+        * using pisacd. The output will be written to stderr before
+        * pisacd is forking to background */
+       while (TRUE)
+       {
+               if (pisa_check_if_hipd_runs()) {
+                       break;
+               }
+               else {
+                       PISA_ERROR("hipd is not executed on this system. 
Waiting for it to start up...\n");
+                       sleep(WAIT_FOR_HIPD_TIMEOUT);
+               }
        }
 
        cd_perf_init();

Modified: trunk/pisasd/sdmain.c
==============================================================================
--- trunk/pisasd/sdmain.c       Tue Nov  3 15:11:34 2009        (r1504)
+++ trunk/pisasd/sdmain.c       Tue Nov  3 16:50:30 2009        (r1505)
@@ -371,10 +371,18 @@
         * sdconf_* operations except for sdconf_init. */
        sd_get_cmdargs(argc, argv);
 
-       if (pisa_make_hipd_run() < 0) {
-               /* TODO: is there any other ways than stopping here? */
-               PISA_ERROR("hipd cannot be executed. stop.\n");
-               exit(EXIT_FAILURE);
+       /* Check, whether hipd is running. This is a requirement for
+        * using pisasd. The output will be written to stderr before
+        * pisasd is forking to background */
+       while (TRUE)
+       {
+               if (pisa_check_if_hipd_runs()) {
+                       break;
+               }
+               else {
+                       PISA_ERROR("hipd is not executed on this system. 
Waiting for it to start up...\n");
+                       sleep(WAIT_FOR_HIPD_TIMEOUT);
+               }
        }
 
        sd_perf_init();

Other related posts: