diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-02-02 10:26:01 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-02-02 10:26:01 +0000 |
commit | 3c89be3fc4488ce13902dd1482c1eb668c1c3b7b (patch) | |
tree | 01c39c416781d3fe2d26f6b0dd1a0d00d9751b10 /src | |
parent | ba5afc688c7bc8804524290830bd3e473b180b71 (diff) | |
download | gnunet-3c89be3fc4488ce13902dd1482c1eb668c1c3b7b.tar.gz gnunet-3c89be3fc4488ce13902dd1482c1eb668c1c3b7b.zip |
cleaning up code from debug session
Diffstat (limited to 'src')
-rw-r--r-- | src/arm/arm.h | 2 | ||||
-rw-r--r-- | src/arm/arm_api.c | 2 | ||||
-rw-r--r-- | src/arm/gnunet-service-arm.c | 19 | ||||
-rw-r--r-- | src/arm/mockup-service.c | 2 | ||||
-rw-r--r-- | src/arm/test_arm_api_data.conf | 2 | ||||
-rw-r--r-- | src/arm/test_exponential_backoff.c | 72 |
6 files changed, 51 insertions, 48 deletions
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 @@ | |||
31 | * This option will turn on the DEBUG loglevel for | 31 | * This option will turn on the DEBUG loglevel for |
32 | * all processes controlled by this ARM! | 32 | * all processes controlled by this ARM! |
33 | */ | 33 | */ |
34 | #define DEBUG_ARM GNUNET_YES | 34 | #define DEBUG_ARM GNUNET_NO |
35 | 35 | ||
36 | #endif | 36 | #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, | |||
181 | "gnunet-service-arm"); | 181 | "gnunet-service-arm"); |
182 | #endif | 182 | #endif |
183 | /* FIXME: should we check that HOSTNAME for 'arm' is localhost? */ | 183 | /* FIXME: should we check that HOSTNAME for 'arm' is localhost? */ |
184 | /* FIXME: interpret 'PREFIX' and 'OPTIONS' configuration options | ||
185 | (as done by 'gnunet-service-arm.c::start_process') */ | ||
184 | /* start service */ | 186 | /* start service */ |
185 | if (GNUNET_OK != | 187 | if (GNUNET_OK != |
186 | GNUNET_CONFIGURATION_get_value_string (pos->h->cfg, | 188 | 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) | |||
812 | } | 812 | } |
813 | } | 813 | } |
814 | pos = pos->next; | 814 | pos = pos->next; |
815 | } | 815 | } |
816 | if (lowestRestartDelay.value != GNUNET_TIME_UNIT_FOREVER_REL.value) | 816 | if (lowestRestartDelay.value != GNUNET_TIME_UNIT_FOREVER_REL.value) |
817 | child_restart_task | 817 | { |
818 | = GNUNET_SCHEDULER_add_delayed (sched, | 818 | #if DEBUG_ARM |
819 | lowestRestartDelay, | 819 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
820 | &delayed_restart_task, | 820 | "Will restart process in %llums\n", |
821 | NULL); | 821 | (unsigned long long) lowestRestartDelay.value); |
822 | #endif | ||
823 | child_restart_task | ||
824 | = GNUNET_SCHEDULER_add_delayed (sched, | ||
825 | lowestRestartDelay, | ||
826 | &delayed_restart_task, | ||
827 | NULL); | ||
828 | } | ||
822 | } | 829 | } |
823 | 830 | ||
824 | 831 | ||
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) | |||
43 | { | 43 | { |
44 | int ret; | 44 | int ret; |
45 | 45 | ||
46 | fprintf (stderr, "mockup starting\n"); | ||
47 | ret = (GNUNET_OK == | 46 | ret = (GNUNET_OK == |
48 | GNUNET_SERVICE_run (argc, | 47 | GNUNET_SERVICE_run (argc, |
49 | argv, | 48 | argv, |
50 | "do-nothing", GNUNET_SERVICE_OPTION_NONE, | 49 | "do-nothing", GNUNET_SERVICE_OPTION_NONE, |
51 | &run, NULL)) ? 0 : 1; | 50 | &run, NULL)) ? 0 : 1; |
52 | 51 | ||
53 | fprintf (stderr, "mockup stopping\n"); | ||
54 | return ret; | 52 | return ret; |
55 | } | 53 | } |
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 | |||
5 | [arm] | 5 | [arm] |
6 | PORT = 23354 | 6 | PORT = 23354 |
7 | DEFAULTSERVICES = | 7 | DEFAULTSERVICES = |
8 | BINARY = gnunet-service-arm | ||
9 | OPTIONS = -L ERROR | ||
8 | #DEBUG = YES | 10 | #DEBUG = YES |
9 | 11 | ||
10 | [resolver] | 12 | [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 @@ | |||
27 | #include "gnunet_configuration_lib.h" | 27 | #include "gnunet_configuration_lib.h" |
28 | #include "gnunet_program_lib.h" | 28 | #include "gnunet_program_lib.h" |
29 | 29 | ||
30 | #define VERBOSE GNUNET_YES | 30 | #define VERBOSE GNUNET_NO |
31 | #define START_ARM GNUNET_YES | 31 | #define START_ARM GNUNET_YES |
32 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) | 32 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) |
33 | #define SERVICE_TEST_TIMEOUT GNUNET_TIME_UNIT_FOREVER_REL | 33 | #define SERVICE_TEST_TIMEOUT GNUNET_TIME_UNIT_FOREVER_REL |
@@ -51,16 +51,17 @@ arm_notify_stop (void *cls, int success) | |||
51 | } | 51 | } |
52 | 52 | ||
53 | 53 | ||
54 | <<<<<<< .mine | ||
55 | static void | 54 | static void |
56 | ======= | 55 | kill_task (void *cbData, |
56 | const struct GNUNET_SCHEDULER_TaskContext *tc); | ||
57 | |||
57 | 58 | ||
58 | static void | 59 | static void |
59 | >>>>>>> .r10190 | ||
60 | do_nothing_notify (void *cls, int success) | 60 | do_nothing_notify (void *cls, int success) |
61 | { | 61 | { |
62 | GNUNET_assert (success == GNUNET_YES); | 62 | GNUNET_assert (success == GNUNET_YES); |
63 | ok = 1; | 63 | ok = 1; |
64 | GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_UNIT_SECONDS, &kill_task, NULL); | ||
64 | } | 65 | } |
65 | 66 | ||
66 | 67 | ||
@@ -75,6 +76,8 @@ arm_notify (void *cls, int success) | |||
75 | static void | 76 | static void |
76 | kill_task (void *cbData, | 77 | kill_task (void *cbData, |
77 | const struct GNUNET_SCHEDULER_TaskContext *tc); | 78 | const struct GNUNET_SCHEDULER_TaskContext *tc); |
79 | |||
80 | |||
78 | static void | 81 | static void |
79 | do_nothing_restarted_notify_task (void *cls, | 82 | do_nothing_restarted_notify_task (void *cls, |
80 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 83 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
@@ -83,7 +86,6 @@ do_nothing_restarted_notify_task (void *cls, | |||
83 | static int trialCount = 0; | 86 | static int trialCount = 0; |
84 | 87 | ||
85 | trialCount++; | 88 | trialCount++; |
86 | <<<<<<< .mine | ||
87 | 89 | ||
88 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) { | 90 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) { |
89 | fprintf(killLogFilePtr, "%d.Reason is shutdown!\n", trialCount); | 91 | fprintf(killLogFilePtr, "%d.Reason is shutdown!\n", trialCount); |
@@ -93,15 +95,6 @@ do_nothing_restarted_notify_task (void *cls, | |||
93 | } | 95 | } |
94 | else if ((tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE) != 0) { | 96 | else if ((tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE) != 0) { |
95 | fprintf(killLogFilePtr, "%d.Service is running!\n", trialCount); | 97 | fprintf(killLogFilePtr, "%d.Service is running!\n", trialCount); |
96 | ======= | ||
97 | if (trialCount >= 11) { | ||
98 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | ||
99 | fprintf(killLogFilePtr, "Reason is shutdown!\n"); | ||
100 | else if ((tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT) != 0) | ||
101 | fprintf(killLogFilePtr, "%d.Reason is timeout!\n", trialCount); | ||
102 | else if ((tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE) != 0) | ||
103 | fprintf(killLogFilePtr, "%d.Service is running!\n", trialCount); | ||
104 | >>>>>>> .r10190 | ||
105 | } | 98 | } |
106 | 99 | ||
107 | GNUNET_SCHEDULER_add_now (sched, &kill_task, &a); | 100 | GNUNET_SCHEDULER_add_now (sched, &kill_task, &a); |
@@ -109,6 +102,15 @@ do_nothing_restarted_notify_task (void *cls, | |||
109 | 102 | ||
110 | 103 | ||
111 | static void | 104 | static void |
105 | do_test (void *cbData, | ||
106 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
107 | { | ||
108 | GNUNET_CLIENT_service_test(sched, "do-nothing", cfg, TIMEOUT, | ||
109 | &do_nothing_restarted_notify_task, NULL); | ||
110 | } | ||
111 | |||
112 | |||
113 | static void | ||
112 | kill_task (void *cbData, | 114 | kill_task (void *cbData, |
113 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 115 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
114 | { | 116 | { |
@@ -117,42 +119,35 @@ kill_task (void *cbData, | |||
117 | struct GNUNET_TIME_Relative waitedFor; | 119 | struct GNUNET_TIME_Relative waitedFor; |
118 | static int trialCount = 0; | 120 | static int trialCount = 0; |
119 | 121 | ||
120 | <<<<<<< .mine | ||
121 | if (NULL != cbData) { | 122 | if (NULL != cbData) { |
122 | waitedFor = GNUNET_TIME_absolute_get_duration (startedWaitingAt); | 123 | waitedFor = GNUNET_TIME_absolute_get_duration (startedWaitingAt); |
123 | fprintf(killLogFilePtr, "Waited for: %lld milliseconds\n\n", waitedFor.value); | 124 | fprintf(killLogFilePtr, "Waited for: %llu milliseconds\n\n", |
124 | ======= | 125 | (unsigned long long) waitedFor.value); |
125 | reason = cbData; | ||
126 | if (NULL != reason) { | ||
127 | waitedFor = GNUNET_TIME_absolute_get_duration(startedWaitingAt); | ||
128 | trialCount++; | ||
129 | if (trialCount >= 11) | ||
130 | fprintf(killLogFilePtr, | ||
131 | "Trial no.%d, Started waiting at: %llu. Waited for: %llu\n", | ||
132 | trialCount, | ||
133 | (unsigned long long) startedWaitingAt.value, | ||
134 | (unsigned long long) waitedFor.value); | ||
135 | >>>>>>> .r10190 | ||
136 | } | 126 | } |
137 | 127 | /* Connect to the doNothing task */ | |
138 | /* Connect to the doNothing task */ | ||
139 | doNothingConnection = GNUNET_CLIENT_connect (sched, "do-nothing", cfg); | 128 | doNothingConnection = GNUNET_CLIENT_connect (sched, "do-nothing", cfg); |
140 | if (NULL == doNothingConnection) | 129 | if (NULL == doNothingConnection) |
141 | fprintf(killLogFilePtr, "Unable to connect to do-nothing process!\n"); | 130 | fprintf(killLogFilePtr, "Unable to connect to do-nothing process!\n"); |
142 | 131 | ||
143 | if (trialCount == 20) { | 132 | if (trialCount == 12) { |
144 | GNUNET_ARM_stop_service (arm, "do-nothing", TIMEOUT, &arm_notify_stop, NULL); | 133 | GNUNET_ARM_stop_service (arm, "do-nothing", TIMEOUT, &arm_notify_stop, NULL); |
134 | ok = 0; | ||
145 | return; | 135 | return; |
146 | } | 136 | } |
147 | 137 | ||
148 | /* Use the created connection to kill the doNothingTask */ | 138 | /* Use the created connection to kill the doNothingTask */ |
149 | GNUNET_CLIENT_service_shutdown(doNothingConnection); | 139 | GNUNET_CLIENT_service_shutdown(doNothingConnection); |
150 | trialCount++; | 140 | trialCount++; |
141 | if (startedWaitingAt.value == 0) | ||
142 | waitedFor.value = 0; | ||
151 | startedWaitingAt = GNUNET_TIME_absolute_get(); | 143 | startedWaitingAt = GNUNET_TIME_absolute_get(); |
152 | sleep(1); | 144 | GNUNET_SCHEDULER_add_delayed (sched, |
153 | GNUNET_CLIENT_service_test(sched, "do-nothing", cfg, GNUNET_TIME_UNIT_SECONDS, &do_nothing_restarted_notify_task, NULL); | 145 | waitedFor, |
146 | &do_test, | ||
147 | NULL); | ||
154 | } | 148 | } |
155 | 149 | ||
150 | |||
156 | static void | 151 | static void |
157 | task (void *cls, | 152 | task (void *cls, |
158 | struct GNUNET_SCHEDULER_Handle *s, | 153 | struct GNUNET_SCHEDULER_Handle *s, |
@@ -165,11 +160,10 @@ task (void *cls, | |||
165 | 160 | ||
166 | arm = GNUNET_ARM_connect (cfg, sched, NULL); | 161 | arm = GNUNET_ARM_connect (cfg, sched, NULL); |
167 | #if START_ARM | 162 | #if START_ARM |
168 | GNUNET_ARM_start_service (arm, "arm", TIMEOUT, &arm_notify, NULL); | 163 | GNUNET_ARM_start_service (arm, "arm", GNUNET_TIME_UNIT_ZERO, &arm_notify, NULL); |
169 | #else | 164 | #else |
170 | arm_do_nothing (NULL, GNUNET_YES); | 165 | arm_do_nothing (NULL, GNUNET_YES); |
171 | #endif | 166 | #endif |
172 | GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_UNIT_SECONDS, &kill_task, NULL); | ||
173 | } | 167 | } |
174 | 168 | ||
175 | static int | 169 | static int |