gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r10193 - gnunet/src/arm
Date: Tue, 2 Feb 2010 11:26:01 +0100

Author: grothoff
Date: 2010-02-02 11:26:01 +0100 (Tue, 02 Feb 2010)
New Revision: 10193

Modified:
   gnunet/src/arm/arm.h
   gnunet/src/arm/arm_api.c
   gnunet/src/arm/gnunet-service-arm.c
   gnunet/src/arm/mockup-service.c
   gnunet/src/arm/test_arm_api_data.conf
   gnunet/src/arm/test_exponential_backoff.c
Log:
cleaning up code from debug session

Modified: gnunet/src/arm/arm.h
===================================================================
--- gnunet/src/arm/arm.h        2010-02-02 10:25:43 UTC (rev 10192)
+++ gnunet/src/arm/arm.h        2010-02-02 10:26:01 UTC (rev 10193)
@@ -31,6 +31,6 @@
  * This option will turn on the DEBUG loglevel for
  * all processes controlled by this ARM!
  */
-#define DEBUG_ARM GNUNET_YES
+#define DEBUG_ARM GNUNET_NO
 
 #endif

Modified: gnunet/src/arm/arm_api.c
===================================================================
--- gnunet/src/arm/arm_api.c    2010-02-02 10:25:43 UTC (rev 10192)
+++ gnunet/src/arm/arm_api.c    2010-02-02 10:26:01 UTC (rev 10193)
@@ -181,6 +181,8 @@
              "gnunet-service-arm");
 #endif
   /* FIXME: should we check that HOSTNAME for 'arm' is localhost? */
+  /* FIXME: interpret 'PREFIX' and 'OPTIONS' configuration options
+     (as done by 'gnunet-service-arm.c::start_process') */
   /* start service */
   if (GNUNET_OK !=
       GNUNET_CONFIGURATION_get_value_string (pos->h->cfg,

Modified: gnunet/src/arm/gnunet-service-arm.c
===================================================================
--- gnunet/src/arm/gnunet-service-arm.c 2010-02-02 10:25:43 UTC (rev 10192)
+++ gnunet/src/arm/gnunet-service-arm.c 2010-02-02 10:26:01 UTC (rev 10193)
@@ -812,13 +812,20 @@
            }
        }
       pos = pos->next;
+    }  
+  if (lowestRestartDelay.value != GNUNET_TIME_UNIT_FOREVER_REL.value)
+    {
+#if DEBUG_ARM
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                 "Will restart process in %llums\n",
+                 (unsigned long long) lowestRestartDelay.value);
+#endif
+      child_restart_task
+       = GNUNET_SCHEDULER_add_delayed (sched,
+                                       lowestRestartDelay,
+                                       &delayed_restart_task,
+                                       NULL);
     }
-  if (lowestRestartDelay.value != GNUNET_TIME_UNIT_FOREVER_REL.value)
-    child_restart_task
-      = GNUNET_SCHEDULER_add_delayed (sched,
-                                     lowestRestartDelay,
-                                     &delayed_restart_task,
-                                     NULL);
 }
 
 

Modified: gnunet/src/arm/mockup-service.c
===================================================================
--- gnunet/src/arm/mockup-service.c     2010-02-02 10:25:43 UTC (rev 10192)
+++ gnunet/src/arm/mockup-service.c     2010-02-02 10:26:01 UTC (rev 10193)
@@ -43,13 +43,11 @@
 {
        int ret;
 
-       fprintf (stderr, "mockup starting\n");
        ret = (GNUNET_OK ==
           GNUNET_SERVICE_run (argc,
                              argv,
                              "do-nothing", GNUNET_SERVICE_OPTION_NONE,
                              &run, NULL)) ? 0 : 1;
        
-       fprintf (stderr, "mockup stopping\n");
        return ret;
 }

Modified: gnunet/src/arm/test_arm_api_data.conf
===================================================================
--- gnunet/src/arm/test_arm_api_data.conf       2010-02-02 10:25:43 UTC (rev 
10192)
+++ gnunet/src/arm/test_arm_api_data.conf       2010-02-02 10:26:01 UTC (rev 
10193)
@@ -5,6 +5,8 @@
 [arm]
 PORT = 23354
 DEFAULTSERVICES =
+BINARY = gnunet-service-arm
+OPTIONS = -L ERROR
 #DEBUG = YES
 
 [resolver]

Modified: gnunet/src/arm/test_exponential_backoff.c
===================================================================
--- gnunet/src/arm/test_exponential_backoff.c   2010-02-02 10:25:43 UTC (rev 
10192)
+++ gnunet/src/arm/test_exponential_backoff.c   2010-02-02 10:26:01 UTC (rev 
10193)
@@ -27,7 +27,7 @@
 #include "gnunet_configuration_lib.h"
 #include "gnunet_program_lib.h"
 
-#define VERBOSE GNUNET_YES
+#define VERBOSE GNUNET_NO
 #define START_ARM GNUNET_YES
 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
 #define SERVICE_TEST_TIMEOUT GNUNET_TIME_UNIT_FOREVER_REL
@@ -51,16 +51,17 @@
 }
 
 
-<<<<<<< .mine
 static void
-=======
+kill_task (void *cbData,
+          const struct GNUNET_SCHEDULER_TaskContext *tc);
 
+
 static void
->>>>>>> .r10190
 do_nothing_notify (void *cls, int success)
 {
-       GNUNET_assert (success == GNUNET_YES);
-       ok = 1;
+  GNUNET_assert (success == GNUNET_YES);
+  ok = 1;
+  GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_UNIT_SECONDS, &kill_task, 
NULL);
 }
 
 
@@ -75,6 +76,8 @@
 static void
 kill_task (void *cbData,
                   const struct GNUNET_SCHEDULER_TaskContext *tc);
+
+
 static void
 do_nothing_restarted_notify_task (void *cls,
                   const struct GNUNET_SCHEDULER_TaskContext *tc)
@@ -83,7 +86,6 @@
        static int trialCount = 0;
 
        trialCount++;
-<<<<<<< .mine
        
        if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) { 
                fprintf(killLogFilePtr, "%d.Reason is shutdown!\n", trialCount);
@@ -93,15 +95,6 @@
        }
        else if ((tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE) != 0) {
                fprintf(killLogFilePtr, "%d.Service is running!\n", trialCount);
-=======
-       if (trialCount >= 11) {
-               if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) 
-                       fprintf(killLogFilePtr, "Reason is shutdown!\n");
-               else if ((tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT) != 0)
-                 fprintf(killLogFilePtr, "%d.Reason is timeout!\n", 
trialCount);
-               else if ((tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE) != 
0)
-                       fprintf(killLogFilePtr, "%d.Service is running!\n", 
trialCount);
->>>>>>> .r10190
        }
                
        GNUNET_SCHEDULER_add_now (sched, &kill_task, &a);
@@ -109,6 +102,15 @@
 
 
 static void
+do_test (void *cbData,
+                  const struct GNUNET_SCHEDULER_TaskContext *tc)
+{                                    
+       GNUNET_CLIENT_service_test(sched, "do-nothing", cfg, TIMEOUT,
+                                  &do_nothing_restarted_notify_task, NULL);
+}
+
+
+static void
 kill_task (void *cbData,
                   const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
@@ -117,42 +119,35 @@
        struct GNUNET_TIME_Relative waitedFor;
        static int trialCount = 0;
        
-<<<<<<< .mine
        if (NULL != cbData) {
-               waitedFor = GNUNET_TIME_absolute_get_duration 
(startedWaitingAt);
-               fprintf(killLogFilePtr, "Waited for: %lld milliseconds\n\n", 
waitedFor.value);
-=======
-       reason = cbData;
-       if (NULL != reason) {
-               waitedFor = GNUNET_TIME_absolute_get_duration(startedWaitingAt);
-               trialCount++;
-               if (trialCount >= 11) 
-                 fprintf(killLogFilePtr,
-                         "Trial no.%d, Started waiting at: %llu. Waited for: 
%llu\n", 
-                         trialCount, 
-                         (unsigned long long) startedWaitingAt.value, 
-                         (unsigned long long) waitedFor.value);
->>>>>>> .r10190
+         waitedFor = GNUNET_TIME_absolute_get_duration (startedWaitingAt);
+         fprintf(killLogFilePtr, "Waited for: %llu milliseconds\n\n", 
+                 (unsigned long long) waitedFor.value);
        }
-       
-        /* Connect to the doNothing task */
+       /* Connect to the doNothing task */
        doNothingConnection = GNUNET_CLIENT_connect (sched, "do-nothing", cfg);
        if (NULL == doNothingConnection)
                fprintf(killLogFilePtr, "Unable to connect to do-nothing 
process!\n");
        
-       if (trialCount == 20) {
-               GNUNET_ARM_stop_service (arm, "do-nothing", TIMEOUT, 
&arm_notify_stop, NULL);
+       if (trialCount == 12) {
+         GNUNET_ARM_stop_service (arm, "do-nothing", TIMEOUT, 
&arm_notify_stop, NULL);
+         ok = 0;
                return;
        }
        
        /* Use the created connection to kill the doNothingTask */
        GNUNET_CLIENT_service_shutdown(doNothingConnection);
        trialCount++;
+       if (startedWaitingAt.value == 0)
+         waitedFor.value = 0;  
        startedWaitingAt = GNUNET_TIME_absolute_get();
-       sleep(1);
-       GNUNET_CLIENT_service_test(sched, "do-nothing", cfg, 
GNUNET_TIME_UNIT_SECONDS, &do_nothing_restarted_notify_task, NULL);
+       GNUNET_SCHEDULER_add_delayed (sched,
+                                     waitedFor,
+                                     &do_test,
+                                     NULL);
 }
 
+       
 static void
 task (void *cls,
       struct GNUNET_SCHEDULER_Handle *s,
@@ -165,11 +160,10 @@
   
   arm = GNUNET_ARM_connect (cfg, sched, NULL);
 #if START_ARM
-  GNUNET_ARM_start_service (arm, "arm", TIMEOUT, &arm_notify, NULL);
+  GNUNET_ARM_start_service (arm, "arm", GNUNET_TIME_UNIT_ZERO, &arm_notify, 
NULL);
 #else
   arm_do_nothing (NULL, GNUNET_YES);
 #endif
-  GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_UNIT_SECONDS, &kill_task, 
NULL);
 }
 
 static int





reply via email to

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