From: Christian Grothoff Date: Tue, 2 Feb 2010 10:26:01 +0000 (+0000) Subject: cleaning up code from debug session X-Git-Tag: initial-import-from-subversion-38251~22812 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=3c89be3fc4488ce13902dd1482c1eb668c1c3b7b;p=oweals%2Fgnunet.git cleaning up code from debug session --- diff --git a/src/arm/arm.h b/src/arm/arm.h index 2f107351c..562113068 100644 --- a/src/arm/arm.h +++ b/src/arm/arm.h @@ -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 diff --git a/src/arm/arm_api.c b/src/arm/arm_api.c index 256df3320..a29ec0da6 100644 --- a/src/arm/arm_api.c +++ b/src/arm/arm_api.c @@ -181,6 +181,8 @@ arm_service_report (void *cls, "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, diff --git a/src/arm/gnunet-service-arm.c b/src/arm/gnunet-service-arm.c index 22df8c7c0..4de34ea28 100644 --- a/src/arm/gnunet-service-arm.c +++ b/src/arm/gnunet-service-arm.c @@ -812,13 +812,20 @@ delayed_restart_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } } pos = pos->next; - } + } if (lowestRestartDelay.value != GNUNET_TIME_UNIT_FOREVER_REL.value) - child_restart_task - = GNUNET_SCHEDULER_add_delayed (sched, - lowestRestartDelay, - &delayed_restart_task, - NULL); + { +#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); + } } diff --git a/src/arm/mockup-service.c b/src/arm/mockup-service.c index 3fcac6219..2de957ba9 100644 --- a/src/arm/mockup-service.c +++ b/src/arm/mockup-service.c @@ -43,13 +43,11 @@ int main(int argc, char *const *argv) { 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; } diff --git a/src/arm/test_arm_api_data.conf b/src/arm/test_arm_api_data.conf index 92f7efb45..bdacfd476 100644 --- a/src/arm/test_arm_api_data.conf +++ b/src/arm/test_arm_api_data.conf @@ -5,6 +5,8 @@ DEFAULTCONFIG = test_arm_api_data.conf [arm] PORT = 23354 DEFAULTSERVICES = +BINARY = gnunet-service-arm +OPTIONS = -L ERROR #DEBUG = YES [resolver] diff --git a/src/arm/test_exponential_backoff.c b/src/arm/test_exponential_backoff.c index 0208cbafa..bbc794d65 100644 --- a/src/arm/test_exponential_backoff.c +++ b/src/arm/test_exponential_backoff.c @@ -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 @@ arm_notify_stop (void *cls, int success) } -<<<<<<< .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 @@ arm_notify (void *cls, int success) 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 @@ do_nothing_restarted_notify_task (void *cls, static int trialCount = 0; trialCount++; -<<<<<<< .mine if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) { fprintf(killLogFilePtr, "%d.Reason is shutdown!\n", trialCount); @@ -93,21 +95,21 @@ do_nothing_restarted_notify_task (void *cls, } 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); } +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 @@ kill_task (void *cbData, 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 @@ task (void *cls, 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