aboutsummaryrefslogtreecommitdiff
path: root/src/arm/test_exponential_backoff.c
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2010-05-06 09:54:08 +0000
committerNathan S. Evans <evans@in.tum.de>2010-05-06 09:54:08 +0000
commit1948cedcb5e7c5017dcd18ef087f0f7e5aa5f27f (patch)
tree53048b78f1bec588db3c7f7d72a35e483ccf2795 /src/arm/test_exponential_backoff.c
parent031972ecd7ef2a767cbe8caf3c6fb649567a6b0d (diff)
downloadgnunet-1948cedcb5e7c5017dcd18ef087f0f7e5aa5f27f.tar.gz
gnunet-1948cedcb5e7c5017dcd18ef087f0f7e5aa5f27f.zip
main change for gnunet-arm is that gnunet-arm now gets proper confirmation when called to start or stop services. This means that calling gnunet-arm to stop/start a process will return 0 only if the process is stopped/started. For gnunet-service-arm, this is implemented by leaking the client connection socket on a shutdown request, so that it is only closed when the arm service actually shuts down (indicating everything is really down).
Diffstat (limited to 'src/arm/test_exponential_backoff.c')
-rw-r--r--src/arm/test_exponential_backoff.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/arm/test_exponential_backoff.c b/src/arm/test_exponential_backoff.c
index 425e6bd8d..357a5e71a 100644
--- a/src/arm/test_exponential_backoff.c
+++ b/src/arm/test_exponential_backoff.c
@@ -39,6 +39,10 @@ static const struct GNUNET_CONFIGURATION_Handle *cfg;
39static struct GNUNET_ARM_Handle *arm; 39static struct GNUNET_ARM_Handle *arm;
40static int ok = 1; 40static int ok = 1;
41 41
42static int trialCount;
43static struct GNUNET_TIME_Absolute startedWaitingAt;
44struct GNUNET_TIME_Relative waitedFor;
45
42#if LOG_BACKOFF 46#if LOG_BACKOFF
43static FILE *killLogFilePtr; 47static FILE *killLogFilePtr;
44static char *killLogFileName; 48static char *killLogFileName;
@@ -90,7 +94,6 @@ do_nothing_restarted_notify_task (void *cls,
90 const struct GNUNET_SCHEDULER_TaskContext *tc) 94 const struct GNUNET_SCHEDULER_TaskContext *tc)
91{ 95{
92 static char a; 96 static char a;
93 static int trialCount = 0;
94 97
95 trialCount++; 98 trialCount++;
96 99
@@ -129,16 +132,24 @@ do_test (void *cbData,
129 132
130 133
131static void 134static void
135shutdown_cont (void *cls, int reason)
136{
137 trialCount++;
138 startedWaitingAt = GNUNET_TIME_absolute_get();
139 GNUNET_SCHEDULER_add_delayed (sched,
140 waitedFor,
141 &do_test,
142 NULL);
143}
144static void
132kill_task (void *cbData, 145kill_task (void *cbData,
133 const struct GNUNET_SCHEDULER_TaskContext *tc) 146 const struct GNUNET_SCHEDULER_TaskContext *tc)
134{ 147{
135 static struct GNUNET_CLIENT_Connection * doNothingConnection = NULL; 148 static struct GNUNET_CLIENT_Connection * doNothingConnection = NULL;
136 static struct GNUNET_TIME_Absolute startedWaitingAt; 149
137 struct GNUNET_TIME_Relative waitedFor;
138 static int trialCount = 0;
139
140 if (NULL != cbData) { 150 if (NULL != cbData) {
141 waitedFor = GNUNET_TIME_absolute_get_duration (startedWaitingAt); 151 waitedFor = GNUNET_TIME_absolute_get_duration (startedWaitingAt);
152
142#if LOG_BACKOFF 153#if LOG_BACKOFF
143 fprintf(killLogFilePtr, 154 fprintf(killLogFilePtr,
144 "Waited for: %llu ms\n", 155 "Waited for: %llu ms\n",
@@ -164,13 +175,8 @@ kill_task (void *cbData,
164 } 175 }
165 176
166 /* Use the created connection to kill the doNothingTask */ 177 /* Use the created connection to kill the doNothingTask */
167 GNUNET_CLIENT_service_shutdown(doNothingConnection); 178 GNUNET_CLIENT_service_shutdown(sched, doNothingConnection, TIMEOUT, &shutdown_cont, NULL);
168 trialCount++; 179
169 startedWaitingAt = GNUNET_TIME_absolute_get();
170 GNUNET_SCHEDULER_add_delayed (sched,
171 waitedFor,
172 &do_test,
173 NULL);
174} 180}
175 181
176 182