diff options
author | Christian Grothoff <christian@grothoff.org> | 2018-05-09 17:45:28 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2018-05-09 17:45:28 +0200 |
commit | 2cac1c7df7a50fdf9a3861d3f095eff9cfadc34a (patch) | |
tree | 821ddc2508237f6a72fdb7c6407f825cc61e634d /src/namestore/test_namestore_api_monitoring_existing.c | |
parent | 8bb475af99260f1d107dbc8908268ae93960aa83 (diff) | |
download | gnunet-2cac1c7df7a50fdf9a3861d3f095eff9cfadc34a.tar.gz gnunet-2cac1c7df7a50fdf9a3861d3f095eff9cfadc34a.zip |
missed a few places
Diffstat (limited to 'src/namestore/test_namestore_api_monitoring_existing.c')
-rw-r--r-- | src/namestore/test_namestore_api_monitoring_existing.c | 81 |
1 files changed, 39 insertions, 42 deletions
diff --git a/src/namestore/test_namestore_api_monitoring_existing.c b/src/namestore/test_namestore_api_monitoring_existing.c index 25c098fe3..3e9e70923 100644 --- a/src/namestore/test_namestore_api_monitoring_existing.c +++ b/src/namestore/test_namestore_api_monitoring_existing.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2013 GNUnet e.V. | 3 | Copyright (C) 2013, 2018 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -18,7 +18,7 @@ | |||
18 | Boston, MA 02110-1301, USA. | 18 | Boston, MA 02110-1301, USA. |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @file namestore/test_namestore_api_monitoring.c | 21 | * @file namestore/test_namestore_api_monitoring_existing.c |
22 | * @brief testcase for zone monitoring functionality: add records first, then monitor | 22 | * @brief testcase for zone monitoring functionality: add records first, then monitor |
23 | */ | 23 | */ |
24 | #include "platform.h" | 24 | #include "platform.h" |
@@ -27,7 +27,7 @@ | |||
27 | #include "namestore.h" | 27 | #include "namestore.h" |
28 | 28 | ||
29 | 29 | ||
30 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 100) | 30 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) |
31 | 31 | ||
32 | static const struct GNUNET_CONFIGURATION_Handle *cfg; | 32 | static const struct GNUNET_CONFIGURATION_Handle *cfg; |
33 | 33 | ||
@@ -58,15 +58,29 @@ static struct GNUNET_GNSRECORD_Data *s_rd_3; | |||
58 | struct GNUNET_NAMESTORE_QueueEntry * ns_ops[3]; | 58 | struct GNUNET_NAMESTORE_QueueEntry * ns_ops[3]; |
59 | 59 | ||
60 | 60 | ||
61 | /** | ||
62 | * Re-establish the connection to the service. | ||
63 | * | ||
64 | * @param cls handle to use to re-connect. | ||
65 | */ | ||
66 | static void | ||
67 | endbadly (void *cls) | ||
68 | { | ||
69 | endbadly_task = NULL; | ||
70 | GNUNET_break (0); | ||
71 | GNUNET_SCHEDULER_shutdown (); | ||
72 | res = 1; | ||
73 | } | ||
74 | |||
75 | |||
61 | static void | 76 | static void |
62 | do_shutdown () | 77 | end (void *cls) |
63 | { | 78 | { |
64 | if (NULL != zm) | 79 | if (NULL != zm) |
65 | { | 80 | { |
66 | GNUNET_NAMESTORE_zone_monitor_stop (zm); | 81 | GNUNET_NAMESTORE_zone_monitor_stop (zm); |
67 | zm = NULL; | 82 | zm = NULL; |
68 | } | 83 | } |
69 | |||
70 | if (NULL != ns_ops[0]) | 84 | if (NULL != ns_ops[0]) |
71 | { | 85 | { |
72 | GNUNET_NAMESTORE_cancel(ns_ops[0]); | 86 | GNUNET_NAMESTORE_cancel(ns_ops[0]); |
@@ -82,7 +96,11 @@ do_shutdown () | |||
82 | GNUNET_NAMESTORE_cancel(ns_ops[2]); | 96 | GNUNET_NAMESTORE_cancel(ns_ops[2]); |
83 | ns_ops[2] = NULL; | 97 | ns_ops[2] = NULL; |
84 | } | 98 | } |
85 | 99 | if (NULL != endbadly_task) | |
100 | { | ||
101 | GNUNET_SCHEDULER_cancel (endbadly_task); | ||
102 | endbadly_task = NULL; | ||
103 | } | ||
86 | if (NULL != nsh) | 104 | if (NULL != nsh) |
87 | { | 105 | { |
88 | GNUNET_NAMESTORE_disconnect (nsh); | 106 | GNUNET_NAMESTORE_disconnect (nsh); |
@@ -122,27 +140,6 @@ do_shutdown () | |||
122 | } | 140 | } |
123 | 141 | ||
124 | 142 | ||
125 | /** | ||
126 | * Re-establish the connection to the service. | ||
127 | * | ||
128 | * @param cls handle to use to re-connect. | ||
129 | */ | ||
130 | static void | ||
131 | endbadly (void *cls) | ||
132 | { | ||
133 | do_shutdown (); | ||
134 | res = 1; | ||
135 | } | ||
136 | |||
137 | |||
138 | static void | ||
139 | end (void *cls) | ||
140 | { | ||
141 | do_shutdown (); | ||
142 | res = 0; | ||
143 | } | ||
144 | |||
145 | |||
146 | static void | 143 | static void |
147 | zone_proc (void *cls, | 144 | zone_proc (void *cls, |
148 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, | 145 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, |
@@ -164,9 +161,7 @@ zone_proc (void *cls, | |||
164 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 161 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
165 | "Monitoring returned wrong zone key\n"); | 162 | "Monitoring returned wrong zone key\n"); |
166 | GNUNET_break (0); | 163 | GNUNET_break (0); |
167 | GNUNET_SCHEDULER_cancel (endbadly_task); | 164 | GNUNET_SCHEDULER_shutdown (); |
168 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, | ||
169 | NULL); | ||
170 | return; | 165 | return; |
171 | } | 166 | } |
172 | 167 | ||
@@ -201,17 +196,16 @@ zone_proc (void *cls, | |||
201 | 1); | 196 | 1); |
202 | if (2 == ++returned_records) | 197 | if (2 == ++returned_records) |
203 | { | 198 | { |
204 | if (endbadly_task != NULL) | 199 | GNUNET_SCHEDULER_shutdown (); |
200 | if (GNUNET_YES == fail) | ||
205 | { | 201 | { |
206 | GNUNET_SCHEDULER_cancel (endbadly_task); | 202 | GNUNET_break (0); |
207 | endbadly_task = NULL; | 203 | res = 1; |
208 | } | 204 | } |
209 | if (GNUNET_YES == fail) | ||
210 | GNUNET_SCHEDULER_add_now (&endbadly, | ||
211 | NULL); | ||
212 | else | 205 | else |
213 | GNUNET_SCHEDULER_add_now (&end, | 206 | { |
214 | NULL); | 207 | res = 0; |
208 | } | ||
215 | } | 209 | } |
216 | } | 210 | } |
217 | 211 | ||
@@ -258,8 +252,9 @@ put_cont (void *cls, | |||
258 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 252 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
259 | "Failed to created records\n"); | 253 | "Failed to created records\n"); |
260 | GNUNET_break (0); | 254 | GNUNET_break (0); |
261 | GNUNET_SCHEDULER_cancel (endbadly_task); | 255 | res = 1; |
262 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); | 256 | GNUNET_SCHEDULER_shutdown (); |
257 | return; | ||
263 | } | 258 | } |
264 | 259 | ||
265 | if (3 == c) | 260 | if (3 == c) |
@@ -279,8 +274,8 @@ put_cont (void *cls, | |||
279 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 274 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
280 | "Failed to create zone monitor\n"); | 275 | "Failed to create zone monitor\n"); |
281 | GNUNET_break (0); | 276 | GNUNET_break (0); |
282 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, | 277 | res = 1; |
283 | NULL); | 278 | GNUNET_SCHEDULER_shutdown (); |
284 | return; | 279 | return; |
285 | } | 280 | } |
286 | } | 281 | } |
@@ -319,6 +314,8 @@ run (void *cls, | |||
319 | GNUNET_assert (privkey != NULL); | 314 | GNUNET_assert (privkey != NULL); |
320 | 315 | ||
321 | cfg = mycfg; | 316 | cfg = mycfg; |
317 | GNUNET_SCHEDULER_add_shutdown (&end, | ||
318 | NULL); | ||
322 | endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 319 | endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, |
323 | &endbadly, | 320 | &endbadly, |
324 | NULL); | 321 | NULL); |