diff options
Diffstat (limited to 'src/regex/regex_internal_dht.c')
-rw-r--r-- | src/regex/regex_internal_dht.c | 662 |
1 files changed, 329 insertions, 333 deletions
diff --git a/src/regex/regex_internal_dht.c b/src/regex/regex_internal_dht.c index 7cfaea894..611fb0a23 100644 --- a/src/regex/regex_internal_dht.c +++ b/src/regex/regex_internal_dht.c | |||
@@ -11,12 +11,12 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @file src/regex/regex_internal_dht.c | 21 | * @file src/regex/regex_internal_dht.c |
22 | * @brief library to announce regexes in the network and match strings | 22 | * @brief library to announce regexes in the network and match strings |
@@ -32,7 +32,7 @@ | |||
32 | #include "gnunet_signatures.h" | 32 | #include "gnunet_signatures.h" |
33 | 33 | ||
34 | 34 | ||
35 | #define LOG(kind,...) GNUNET_log_from (kind,"regex-dht",__VA_ARGS__) | 35 | #define LOG(kind, ...) GNUNET_log_from(kind, "regex-dht", __VA_ARGS__) |
36 | 36 | ||
37 | /** | 37 | /** |
38 | * DHT replication level to use. | 38 | * DHT replication level to use. |
@@ -53,8 +53,7 @@ | |||
53 | /** | 53 | /** |
54 | * Handle to store cached data about a regex announce. | 54 | * Handle to store cached data about a regex announce. |
55 | */ | 55 | */ |
56 | struct REGEX_INTERNAL_Announcement | 56 | struct REGEX_INTERNAL_Announcement { |
57 | { | ||
58 | /** | 57 | /** |
59 | * DHT handle to use, must be initialized externally. | 58 | * DHT handle to use, must be initialized externally. |
60 | */ | 59 | */ |
@@ -93,92 +92,92 @@ struct REGEX_INTERNAL_Announcement | |||
93 | * @param edges edges leaving current state. | 92 | * @param edges edges leaving current state. |
94 | */ | 93 | */ |
95 | static void | 94 | static void |
96 | regex_iterator (void *cls, | 95 | regex_iterator(void *cls, |
97 | const struct GNUNET_HashCode *key, | 96 | const struct GNUNET_HashCode *key, |
98 | const char *proof, | 97 | const char *proof, |
99 | int accepting, | 98 | int accepting, |
100 | unsigned int num_edges, | 99 | unsigned int num_edges, |
101 | const struct REGEX_BLOCK_Edge *edges) | 100 | const struct REGEX_BLOCK_Edge *edges) |
102 | { | 101 | { |
103 | struct REGEX_INTERNAL_Announcement *h = cls; | 102 | struct REGEX_INTERNAL_Announcement *h = cls; |
104 | struct RegexBlock *block; | 103 | struct RegexBlock *block; |
105 | size_t size; | 104 | size_t size; |
106 | unsigned int i; | 105 | unsigned int i; |
107 | 106 | ||
108 | LOG (GNUNET_ERROR_TYPE_INFO, | 107 | LOG(GNUNET_ERROR_TYPE_INFO, |
109 | "DHT PUT for state %s with proof `%s' and %u edges:\n", | 108 | "DHT PUT for state %s with proof `%s' and %u edges:\n", |
110 | GNUNET_h2s (key), | 109 | GNUNET_h2s(key), |
111 | proof, | 110 | proof, |
112 | num_edges); | 111 | num_edges); |
113 | for (i = 0; i < num_edges; i++) | 112 | for (i = 0; i < num_edges; i++) |
114 | { | 113 | { |
115 | LOG (GNUNET_ERROR_TYPE_INFO, | 114 | LOG(GNUNET_ERROR_TYPE_INFO, |
116 | "Edge %u `%s' towards %s\n", | 115 | "Edge %u `%s' towards %s\n", |
117 | i, | 116 | i, |
118 | edges[i].label, | 117 | edges[i].label, |
119 | GNUNET_h2s (&edges[i].destination)); | 118 | GNUNET_h2s(&edges[i].destination)); |
120 | } | 119 | } |
121 | if (GNUNET_YES == accepting) | 120 | if (GNUNET_YES == accepting) |
122 | { | 121 | { |
123 | struct RegexAcceptBlock ab; | 122 | struct RegexAcceptBlock ab; |
124 | 123 | ||
125 | LOG (GNUNET_ERROR_TYPE_INFO, | 124 | LOG(GNUNET_ERROR_TYPE_INFO, |
126 | "State %s is accepting, putting own id\n", | 125 | "State %s is accepting, putting own id\n", |
127 | GNUNET_h2s (key)); | 126 | GNUNET_h2s(key)); |
128 | size = sizeof (struct RegexAcceptBlock); | 127 | size = sizeof(struct RegexAcceptBlock); |
129 | ab.purpose.size = ntohl (sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) + | 128 | ab.purpose.size = ntohl(sizeof(struct GNUNET_CRYPTO_EccSignaturePurpose) + |
130 | sizeof (struct GNUNET_TIME_AbsoluteNBO) + | 129 | sizeof(struct GNUNET_TIME_AbsoluteNBO) + |
131 | sizeof (struct GNUNET_HashCode)); | 130 | sizeof(struct GNUNET_HashCode)); |
132 | ab.purpose.purpose = ntohl (GNUNET_SIGNATURE_PURPOSE_REGEX_ACCEPT); | 131 | ab.purpose.purpose = ntohl(GNUNET_SIGNATURE_PURPOSE_REGEX_ACCEPT); |
133 | ab.expiration_time = GNUNET_TIME_absolute_hton (GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_DHT_MAX_EXPIRATION)); | 132 | ab.expiration_time = GNUNET_TIME_absolute_hton(GNUNET_TIME_relative_to_absolute(GNUNET_CONSTANTS_DHT_MAX_EXPIRATION)); |
134 | ab.key = *key; | 133 | ab.key = *key; |
135 | GNUNET_CRYPTO_eddsa_key_get_public (h->priv, | 134 | GNUNET_CRYPTO_eddsa_key_get_public(h->priv, |
136 | &ab.peer.public_key); | 135 | &ab.peer.public_key); |
137 | GNUNET_assert (GNUNET_OK == | 136 | GNUNET_assert(GNUNET_OK == |
138 | GNUNET_CRYPTO_eddsa_sign (h->priv, | 137 | GNUNET_CRYPTO_eddsa_sign(h->priv, |
139 | &ab.purpose, | 138 | &ab.purpose, |
140 | &ab.signature)); | 139 | &ab.signature)); |
141 | 140 | ||
142 | GNUNET_STATISTICS_update (h->stats, "# regex accepting blocks stored", | 141 | GNUNET_STATISTICS_update(h->stats, "# regex accepting blocks stored", |
143 | 1, GNUNET_NO); | 142 | 1, GNUNET_NO); |
144 | GNUNET_STATISTICS_update (h->stats, "# regex accepting block bytes stored", | 143 | GNUNET_STATISTICS_update(h->stats, "# regex accepting block bytes stored", |
145 | sizeof (struct RegexAcceptBlock), GNUNET_NO); | 144 | sizeof(struct RegexAcceptBlock), GNUNET_NO); |
146 | (void) | 145 | (void) |
147 | GNUNET_DHT_put (h->dht, key, | 146 | GNUNET_DHT_put(h->dht, key, |
148 | DHT_REPLICATION, | 147 | DHT_REPLICATION, |
149 | DHT_OPT | GNUNET_DHT_RO_RECORD_ROUTE, | 148 | DHT_OPT | GNUNET_DHT_RO_RECORD_ROUTE, |
150 | GNUNET_BLOCK_TYPE_REGEX_ACCEPT, | 149 | GNUNET_BLOCK_TYPE_REGEX_ACCEPT, |
151 | size, | 150 | size, |
152 | &ab, | 151 | &ab, |
153 | GNUNET_TIME_relative_to_absolute (DHT_TTL), | 152 | GNUNET_TIME_relative_to_absolute(DHT_TTL), |
154 | NULL, NULL); | 153 | NULL, NULL); |
155 | } | 154 | } |
156 | block = REGEX_BLOCK_create (proof, | 155 | block = REGEX_BLOCK_create(proof, |
157 | num_edges, | 156 | num_edges, |
158 | edges, | 157 | edges, |
159 | accepting, | 158 | accepting, |
160 | &size); | 159 | &size); |
161 | if (NULL == block) | 160 | if (NULL == block) |
162 | return; | 161 | return; |
163 | (void) GNUNET_DHT_put (h->dht, | 162 | (void)GNUNET_DHT_put(h->dht, |
164 | key, | 163 | key, |
165 | DHT_REPLICATION, | 164 | DHT_REPLICATION, |
166 | DHT_OPT, | 165 | DHT_OPT, |
167 | GNUNET_BLOCK_TYPE_REGEX, | 166 | GNUNET_BLOCK_TYPE_REGEX, |
168 | size, | 167 | size, |
169 | block, | 168 | block, |
170 | GNUNET_TIME_relative_to_absolute (DHT_TTL), | 169 | GNUNET_TIME_relative_to_absolute(DHT_TTL), |
171 | NULL, | 170 | NULL, |
172 | NULL); | 171 | NULL); |
173 | GNUNET_STATISTICS_update (h->stats, | 172 | GNUNET_STATISTICS_update(h->stats, |
174 | "# regex blocks stored", | 173 | "# regex blocks stored", |
175 | 1, | 174 | 1, |
176 | GNUNET_NO); | 175 | GNUNET_NO); |
177 | GNUNET_STATISTICS_update (h->stats, | 176 | GNUNET_STATISTICS_update(h->stats, |
178 | "# regex block bytes stored", | 177 | "# regex block bytes stored", |
179 | size, | 178 | size, |
180 | GNUNET_NO); | 179 | GNUNET_NO); |
181 | GNUNET_free (block); | 180 | GNUNET_free(block); |
182 | } | 181 | } |
183 | 182 | ||
184 | 183 | ||
@@ -195,22 +194,22 @@ regex_iterator (void *cls, | |||
195 | * Must be freed by calling #REGEX_INTERNAL_announce_cancel(). | 194 | * Must be freed by calling #REGEX_INTERNAL_announce_cancel(). |
196 | */ | 195 | */ |
197 | struct REGEX_INTERNAL_Announcement * | 196 | struct REGEX_INTERNAL_Announcement * |
198 | REGEX_INTERNAL_announce (struct GNUNET_DHT_Handle *dht, | 197 | REGEX_INTERNAL_announce(struct GNUNET_DHT_Handle *dht, |
199 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, | 198 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, |
200 | const char *regex, | 199 | const char *regex, |
201 | uint16_t compression, | 200 | uint16_t compression, |
202 | struct GNUNET_STATISTICS_Handle *stats) | 201 | struct GNUNET_STATISTICS_Handle *stats) |
203 | { | 202 | { |
204 | struct REGEX_INTERNAL_Announcement *h; | 203 | struct REGEX_INTERNAL_Announcement *h; |
205 | 204 | ||
206 | GNUNET_assert (NULL != dht); | 205 | GNUNET_assert(NULL != dht); |
207 | h = GNUNET_new (struct REGEX_INTERNAL_Announcement); | 206 | h = GNUNET_new(struct REGEX_INTERNAL_Announcement); |
208 | h->regex = regex; | 207 | h->regex = regex; |
209 | h->dht = dht; | 208 | h->dht = dht; |
210 | h->stats = stats; | 209 | h->stats = stats; |
211 | h->priv = priv; | 210 | h->priv = priv; |
212 | h->dfa = REGEX_INTERNAL_construct_dfa (regex, strlen (regex), compression); | 211 | h->dfa = REGEX_INTERNAL_construct_dfa(regex, strlen(regex), compression); |
213 | REGEX_INTERNAL_reannounce (h); | 212 | REGEX_INTERNAL_reannounce(h); |
214 | return h; | 213 | return h; |
215 | } | 214 | } |
216 | 215 | ||
@@ -222,15 +221,15 @@ REGEX_INTERNAL_announce (struct GNUNET_DHT_Handle *dht, | |||
222 | * @param h Handle returned by a previous #REGEX_INTERNAL_announce call(). | 221 | * @param h Handle returned by a previous #REGEX_INTERNAL_announce call(). |
223 | */ | 222 | */ |
224 | void | 223 | void |
225 | REGEX_INTERNAL_reannounce (struct REGEX_INTERNAL_Announcement *h) | 224 | REGEX_INTERNAL_reannounce(struct REGEX_INTERNAL_Announcement *h) |
226 | { | 225 | { |
227 | GNUNET_assert (NULL != h->dfa); /* make sure to call announce first */ | 226 | GNUNET_assert(NULL != h->dfa); /* make sure to call announce first */ |
228 | LOG (GNUNET_ERROR_TYPE_INFO, | 227 | LOG(GNUNET_ERROR_TYPE_INFO, |
229 | "REGEX_INTERNAL_reannounce: %s\n", | 228 | "REGEX_INTERNAL_reannounce: %s\n", |
230 | h->regex); | 229 | h->regex); |
231 | REGEX_INTERNAL_iterate_reachable_edges (h->dfa, | 230 | REGEX_INTERNAL_iterate_reachable_edges(h->dfa, |
232 | ®ex_iterator, | 231 | ®ex_iterator, |
233 | h); | 232 | h); |
234 | } | 233 | } |
235 | 234 | ||
236 | 235 | ||
@@ -241,10 +240,10 @@ REGEX_INTERNAL_reannounce (struct REGEX_INTERNAL_Announcement *h) | |||
241 | * @param h Handle returned by a previous #REGEX_INTERNAL_announce() call. | 240 | * @param h Handle returned by a previous #REGEX_INTERNAL_announce() call. |
242 | */ | 241 | */ |
243 | void | 242 | void |
244 | REGEX_INTERNAL_announce_cancel (struct REGEX_INTERNAL_Announcement *h) | 243 | REGEX_INTERNAL_announce_cancel(struct REGEX_INTERNAL_Announcement *h) |
245 | { | 244 | { |
246 | REGEX_INTERNAL_automaton_destroy (h->dfa); | 245 | REGEX_INTERNAL_automaton_destroy(h->dfa); |
247 | GNUNET_free (h); | 246 | GNUNET_free(h); |
248 | } | 247 | } |
249 | 248 | ||
250 | 249 | ||
@@ -255,8 +254,7 @@ REGEX_INTERNAL_announce_cancel (struct REGEX_INTERNAL_Announcement *h) | |||
255 | * Struct to keep state of running searches that have consumed a part of | 254 | * Struct to keep state of running searches that have consumed a part of |
256 | * the inital string. | 255 | * the inital string. |
257 | */ | 256 | */ |
258 | struct RegexSearchContext | 257 | struct RegexSearchContext { |
259 | { | ||
260 | /** | 258 | /** |
261 | * Part of the description already consumed by | 259 | * Part of the description already consumed by |
262 | * this particular search branch. | 260 | * this particular search branch. |
@@ -284,8 +282,7 @@ struct RegexSearchContext | |||
284 | /** | 282 | /** |
285 | * Type of values in `dht_get_results`. | 283 | * Type of values in `dht_get_results`. |
286 | */ | 284 | */ |
287 | struct Result | 285 | struct Result { |
288 | { | ||
289 | /** | 286 | /** |
290 | * Number of bytes in data. | 287 | * Number of bytes in data. |
291 | */ | 288 | */ |
@@ -302,8 +299,7 @@ struct Result | |||
302 | * Struct to keep information of searches of services described by a regex | 299 | * Struct to keep information of searches of services described by a regex |
303 | * using a user-provided string service description. | 300 | * using a user-provided string service description. |
304 | */ | 301 | */ |
305 | struct REGEX_INTERNAL_Search | 302 | struct REGEX_INTERNAL_Search { |
306 | { | ||
307 | /** | 303 | /** |
308 | * DHT handle to use, must be initialized externally. | 304 | * DHT handle to use, must be initialized externally. |
309 | */ | 305 | */ |
@@ -360,9 +356,9 @@ struct REGEX_INTERNAL_Search | |||
360 | * @param ctx Context of the search. | 356 | * @param ctx Context of the search. |
361 | */ | 357 | */ |
362 | static void | 358 | static void |
363 | regex_next_edge (const struct RegexBlock *block, | 359 | regex_next_edge(const struct RegexBlock *block, |
364 | size_t size, | 360 | size_t size, |
365 | struct RegexSearchContext *ctx); | 361 | struct RegexSearchContext *ctx); |
366 | 362 | ||
367 | 363 | ||
368 | /** | 364 | /** |
@@ -381,33 +377,33 @@ regex_next_edge (const struct RegexBlock *block, | |||
381 | * @param data Pointer to the result data. | 377 | * @param data Pointer to the result data. |
382 | */ | 378 | */ |
383 | static void | 379 | static void |
384 | dht_get_string_accept_handler (void *cls, struct GNUNET_TIME_Absolute exp, | 380 | dht_get_string_accept_handler(void *cls, struct GNUNET_TIME_Absolute exp, |
385 | const struct GNUNET_HashCode *key, | 381 | const struct GNUNET_HashCode *key, |
386 | const struct GNUNET_PeerIdentity *get_path, | 382 | const struct GNUNET_PeerIdentity *get_path, |
387 | unsigned int get_path_length, | 383 | unsigned int get_path_length, |
388 | const struct GNUNET_PeerIdentity *put_path, | 384 | const struct GNUNET_PeerIdentity *put_path, |
389 | unsigned int put_path_length, | 385 | unsigned int put_path_length, |
390 | enum GNUNET_BLOCK_Type type, | 386 | enum GNUNET_BLOCK_Type type, |
391 | size_t size, const void *data) | 387 | size_t size, const void *data) |
392 | { | 388 | { |
393 | const struct RegexAcceptBlock *block = data; | 389 | const struct RegexAcceptBlock *block = data; |
394 | struct RegexSearchContext *ctx = cls; | 390 | struct RegexSearchContext *ctx = cls; |
395 | struct REGEX_INTERNAL_Search *info = ctx->info; | 391 | struct REGEX_INTERNAL_Search *info = ctx->info; |
396 | 392 | ||
397 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 393 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
398 | "Regex result accept for %s (key %s)\n", | 394 | "Regex result accept for %s (key %s)\n", |
399 | info->description, GNUNET_h2s(key)); | 395 | info->description, GNUNET_h2s(key)); |
400 | 396 | ||
401 | GNUNET_STATISTICS_update (info->stats, | 397 | GNUNET_STATISTICS_update(info->stats, |
402 | "# regex accepting blocks found", | 398 | "# regex accepting blocks found", |
403 | 1, GNUNET_NO); | 399 | 1, GNUNET_NO); |
404 | GNUNET_STATISTICS_update (info->stats, | 400 | GNUNET_STATISTICS_update(info->stats, |
405 | "# regex accepting block bytes found", | 401 | "# regex accepting block bytes found", |
406 | size, GNUNET_NO); | 402 | size, GNUNET_NO); |
407 | info->callback (info->callback_cls, | 403 | info->callback(info->callback_cls, |
408 | &block->peer, | 404 | &block->peer, |
409 | get_path, get_path_length, | 405 | get_path, get_path_length, |
410 | put_path, put_path_length); | 406 | put_path, put_path_length); |
411 | } | 407 | } |
412 | 408 | ||
413 | 409 | ||
@@ -419,28 +415,28 @@ dht_get_string_accept_handler (void *cls, struct GNUNET_TIME_Absolute exp, | |||
419 | * @param ctx Context containing info about the string, tunnel, etc. | 415 | * @param ctx Context containing info about the string, tunnel, etc. |
420 | */ | 416 | */ |
421 | static void | 417 | static void |
422 | regex_find_path (const struct GNUNET_HashCode *key, | 418 | regex_find_path(const struct GNUNET_HashCode *key, |
423 | struct RegexSearchContext *ctx) | 419 | struct RegexSearchContext *ctx) |
424 | { | 420 | { |
425 | struct GNUNET_DHT_GetHandle *get_h; | 421 | struct GNUNET_DHT_GetHandle *get_h; |
426 | 422 | ||
427 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 423 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
428 | "Accept state found, now searching for paths to %s\n", | 424 | "Accept state found, now searching for paths to %s\n", |
429 | GNUNET_h2s (key), | 425 | GNUNET_h2s(key), |
430 | (unsigned int) ctx->position); | 426 | (unsigned int)ctx->position); |
431 | get_h = GNUNET_DHT_get_start (ctx->info->dht, /* handle */ | 427 | get_h = GNUNET_DHT_get_start(ctx->info->dht, /* handle */ |
432 | GNUNET_BLOCK_TYPE_REGEX_ACCEPT, /* type */ | 428 | GNUNET_BLOCK_TYPE_REGEX_ACCEPT, /* type */ |
433 | key, /* key to search */ | 429 | key, /* key to search */ |
434 | DHT_REPLICATION, /* replication level */ | 430 | DHT_REPLICATION, /* replication level */ |
435 | DHT_OPT | GNUNET_DHT_RO_RECORD_ROUTE, | 431 | DHT_OPT | GNUNET_DHT_RO_RECORD_ROUTE, |
436 | NULL, /* xquery */ // FIXME BLOOMFILTER | 432 | NULL, /* xquery */ // FIXME BLOOMFILTER |
437 | 0, /* xquery bits */ // FIXME BLOOMFILTER SIZE | 433 | 0, /* xquery bits */ // FIXME BLOOMFILTER SIZE |
438 | &dht_get_string_accept_handler, ctx); | 434 | &dht_get_string_accept_handler, ctx); |
439 | GNUNET_break (GNUNET_OK == | 435 | GNUNET_break(GNUNET_OK == |
440 | GNUNET_CONTAINER_multihashmap_put(ctx->info->dht_get_handles, | 436 | GNUNET_CONTAINER_multihashmap_put(ctx->info->dht_get_handles, |
441 | key, | 437 | key, |
442 | get_h, | 438 | get_h, |
443 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); | 439 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); |
444 | } | 440 | } |
445 | 441 | ||
446 | 442 | ||
@@ -462,14 +458,14 @@ regex_find_path (const struct GNUNET_HashCode *key, | |||
462 | * TODO: re-issue the request after certain time? cancel after X results? | 458 | * TODO: re-issue the request after certain time? cancel after X results? |
463 | */ | 459 | */ |
464 | static void | 460 | static void |
465 | dht_get_string_handler (void *cls, struct GNUNET_TIME_Absolute exp, | 461 | dht_get_string_handler(void *cls, struct GNUNET_TIME_Absolute exp, |
466 | const struct GNUNET_HashCode *key, | 462 | const struct GNUNET_HashCode *key, |
467 | const struct GNUNET_PeerIdentity *get_path, | 463 | const struct GNUNET_PeerIdentity *get_path, |
468 | unsigned int get_path_length, | 464 | unsigned int get_path_length, |
469 | const struct GNUNET_PeerIdentity *put_path, | 465 | const struct GNUNET_PeerIdentity *put_path, |
470 | unsigned int put_path_length, | 466 | unsigned int put_path_length, |
471 | enum GNUNET_BLOCK_Type type, | 467 | enum GNUNET_BLOCK_Type type, |
472 | size_t size, const void *data) | 468 | size_t size, const void *data) |
473 | { | 469 | { |
474 | const struct RegexBlock *block = data; | 470 | const struct RegexBlock *block = data; |
475 | struct RegexSearchContext *ctx = cls; | 471 | struct RegexSearchContext *ctx = cls; |
@@ -477,32 +473,32 @@ dht_get_string_handler (void *cls, struct GNUNET_TIME_Absolute exp, | |||
477 | size_t len; | 473 | size_t len; |
478 | struct Result *copy; | 474 | struct Result *copy; |
479 | 475 | ||
480 | LOG (GNUNET_ERROR_TYPE_INFO, | 476 | LOG(GNUNET_ERROR_TYPE_INFO, |
481 | "DHT GET result for %s (%s)\n", | 477 | "DHT GET result for %s (%s)\n", |
482 | GNUNET_h2s (key), ctx->info->description); | 478 | GNUNET_h2s(key), ctx->info->description); |
483 | copy = GNUNET_malloc (sizeof (struct Result) + size); | 479 | copy = GNUNET_malloc(sizeof(struct Result) + size); |
484 | copy->size = size; | 480 | copy->size = size; |
485 | copy->data = ©[1]; | 481 | copy->data = ©[1]; |
486 | GNUNET_memcpy (©[1], block, size); | 482 | GNUNET_memcpy(©[1], block, size); |
487 | GNUNET_break (GNUNET_OK == | 483 | GNUNET_break(GNUNET_OK == |
488 | GNUNET_CONTAINER_multihashmap_put (info->dht_get_results, | 484 | GNUNET_CONTAINER_multihashmap_put(info->dht_get_results, |
489 | key, copy, | 485 | key, copy, |
490 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); | 486 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); |
491 | len = strlen (info->description); | 487 | len = strlen(info->description); |
492 | if (len == ctx->position) // String processed | 488 | if (len == ctx->position) // String processed |
493 | { | ||
494 | if (GNUNET_YES == GNUNET_BLOCK_is_accepting (block, size)) | ||
495 | { | 489 | { |
496 | regex_find_path (key, ctx); | 490 | if (GNUNET_YES == GNUNET_BLOCK_is_accepting(block, size)) |
491 | { | ||
492 | regex_find_path(key, ctx); | ||
493 | } | ||
494 | else | ||
495 | { | ||
496 | LOG(GNUNET_ERROR_TYPE_INFO, "block not accepting!\n"); | ||
497 | /* FIXME REGEX this block not successful, wait for more? start timeout? */ | ||
498 | } | ||
499 | return; | ||
497 | } | 500 | } |
498 | else | 501 | regex_next_edge(block, size, ctx); |
499 | { | ||
500 | LOG (GNUNET_ERROR_TYPE_INFO, "block not accepting!\n"); | ||
501 | /* FIXME REGEX this block not successful, wait for more? start timeout? */ | ||
502 | } | ||
503 | return; | ||
504 | } | ||
505 | regex_next_edge (block, size, ctx); | ||
506 | } | 502 | } |
507 | 503 | ||
508 | 504 | ||
@@ -515,32 +511,32 @@ dht_get_string_handler (void *cls, struct GNUNET_TIME_Absolute exp, | |||
515 | * @return #GNUNET_YES: we should always continue to iterate. | 511 | * @return #GNUNET_YES: we should always continue to iterate. |
516 | */ | 512 | */ |
517 | static int | 513 | static int |
518 | regex_result_iterator (void *cls, | 514 | regex_result_iterator(void *cls, |
519 | const struct GNUNET_HashCode * key, | 515 | const struct GNUNET_HashCode * key, |
520 | void *value) | 516 | void *value) |
521 | { | 517 | { |
522 | struct Result *result = value; | 518 | struct Result *result = value; |
523 | const struct RegexBlock *block = result->data; | 519 | const struct RegexBlock *block = result->data; |
524 | struct RegexSearchContext *ctx = cls; | 520 | struct RegexSearchContext *ctx = cls; |
525 | 521 | ||
526 | if ( (GNUNET_YES == | 522 | if ((GNUNET_YES == |
527 | GNUNET_BLOCK_is_accepting (block, result->size)) && | 523 | GNUNET_BLOCK_is_accepting(block, result->size)) && |
528 | (ctx->position == strlen (ctx->info->description)) ) | 524 | (ctx->position == strlen(ctx->info->description))) |
529 | { | 525 | { |
530 | LOG (GNUNET_ERROR_TYPE_INFO, | 526 | LOG(GNUNET_ERROR_TYPE_INFO, |
531 | "Found accepting known block\n"); | 527 | "Found accepting known block\n"); |
532 | regex_find_path (key, ctx); | 528 | regex_find_path(key, ctx); |
533 | return GNUNET_YES; // We found an accept state! | 529 | return GNUNET_YES; // We found an accept state! |
534 | } | 530 | } |
535 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 531 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
536 | "* %u, %u, [%u]\n", | 532 | "* %u, %u, [%u]\n", |
537 | ctx->position, | 533 | ctx->position, |
538 | strlen (ctx->info->description), | 534 | strlen(ctx->info->description), |
539 | GNUNET_BLOCK_is_accepting (block, result->size)); | 535 | GNUNET_BLOCK_is_accepting(block, result->size)); |
540 | regex_next_edge (block, result->size, ctx); | 536 | regex_next_edge(block, result->size, ctx); |
541 | 537 | ||
542 | GNUNET_STATISTICS_update (ctx->info->stats, "# regex cadet blocks iterated", | 538 | GNUNET_STATISTICS_update(ctx->info->stats, "# regex cadet blocks iterated", |
543 | 1, GNUNET_NO); | 539 | 1, GNUNET_NO); |
544 | 540 | ||
545 | return GNUNET_YES; | 541 | return GNUNET_YES; |
546 | } | 542 | } |
@@ -556,43 +552,43 @@ regex_result_iterator (void *cls, | |||
556 | * @return #GNUNET_YES if should keep iterating, #GNUNET_NO otherwise. | 552 | * @return #GNUNET_YES if should keep iterating, #GNUNET_NO otherwise. |
557 | */ | 553 | */ |
558 | static int | 554 | static int |
559 | regex_edge_iterator (void *cls, | 555 | regex_edge_iterator(void *cls, |
560 | const char *token, | 556 | const char *token, |
561 | size_t len, | 557 | size_t len, |
562 | const struct GNUNET_HashCode *key) | 558 | const struct GNUNET_HashCode *key) |
563 | { | 559 | { |
564 | struct RegexSearchContext *ctx = cls; | 560 | struct RegexSearchContext *ctx = cls; |
565 | struct REGEX_INTERNAL_Search *info = ctx->info; | 561 | struct REGEX_INTERNAL_Search *info = ctx->info; |
566 | const char *current; | 562 | const char *current; |
567 | size_t current_len; | 563 | size_t current_len; |
568 | 564 | ||
569 | GNUNET_STATISTICS_update (info->stats, "# regex edges iterated", | 565 | GNUNET_STATISTICS_update(info->stats, "# regex edges iterated", |
570 | 1, GNUNET_NO); | 566 | 1, GNUNET_NO); |
571 | current = &info->description[ctx->position]; | 567 | current = &info->description[ctx->position]; |
572 | current_len = strlen (info->description) - ctx->position; | 568 | current_len = strlen(info->description) - ctx->position; |
573 | if (len > current_len) | 569 | if (len > current_len) |
574 | { | 570 | { |
575 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Token too long, END\n"); | 571 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Token too long, END\n"); |
576 | return GNUNET_YES; | 572 | return GNUNET_YES; |
577 | } | 573 | } |
578 | if (0 != strncmp (current, token, len)) | 574 | if (0 != strncmp(current, token, len)) |
579 | { | 575 | { |
580 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Token doesn't match, END\n"); | 576 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Token doesn't match, END\n"); |
581 | return GNUNET_YES; | 577 | return GNUNET_YES; |
582 | } | 578 | } |
583 | 579 | ||
584 | if (len > ctx->longest_match) | 580 | if (len > ctx->longest_match) |
585 | { | 581 | { |
586 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Token is longer, KEEP\n"); | 582 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Token is longer, KEEP\n"); |
587 | ctx->longest_match = len; | 583 | ctx->longest_match = len; |
588 | ctx->hash = *key; | 584 | ctx->hash = *key; |
589 | } | 585 | } |
590 | else | 586 | else |
591 | { | 587 | { |
592 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Token is not longer, IGNORE\n"); | 588 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Token is not longer, IGNORE\n"); |
593 | } | 589 | } |
594 | 590 | ||
595 | LOG (GNUNET_ERROR_TYPE_DEBUG, "* End of regex edge iterator\n"); | 591 | LOG(GNUNET_ERROR_TYPE_DEBUG, "* End of regex edge iterator\n"); |
596 | return GNUNET_YES; | 592 | return GNUNET_YES; |
597 | } | 593 | } |
598 | 594 | ||
@@ -605,9 +601,9 @@ regex_edge_iterator (void *cls, | |||
605 | * @param ctx Context of the search. | 601 | * @param ctx Context of the search. |
606 | */ | 602 | */ |
607 | static void | 603 | static void |
608 | regex_next_edge (const struct RegexBlock *block, | 604 | regex_next_edge(const struct RegexBlock *block, |
609 | size_t size, | 605 | size_t size, |
610 | struct RegexSearchContext *ctx) | 606 | struct RegexSearchContext *ctx) |
611 | { | 607 | { |
612 | struct RegexSearchContext *new_ctx; | 608 | struct RegexSearchContext *new_ctx; |
613 | struct REGEX_INTERNAL_Search *info = ctx->info; | 609 | struct REGEX_INTERNAL_Search *info = ctx->info; |
@@ -616,69 +612,69 @@ regex_next_edge (const struct RegexBlock *block, | |||
616 | const char *rest; | 612 | const char *rest; |
617 | int result; | 613 | int result; |
618 | 614 | ||
619 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Next edge\n"); | 615 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Next edge\n"); |
620 | /* Find the longest match for the current string position, | 616 | /* Find the longest match for the current string position, |
621 | * among tokens in the given block */ | 617 | * among tokens in the given block */ |
622 | ctx->longest_match = 0; | 618 | ctx->longest_match = 0; |
623 | result = REGEX_BLOCK_iterate (block, size, | 619 | result = REGEX_BLOCK_iterate(block, size, |
624 | ®ex_edge_iterator, ctx); | 620 | ®ex_edge_iterator, ctx); |
625 | GNUNET_break (GNUNET_OK == result); | 621 | GNUNET_break(GNUNET_OK == result); |
626 | 622 | ||
627 | /* Did anything match? */ | 623 | /* Did anything match? */ |
628 | if (0 == ctx->longest_match) | 624 | if (0 == ctx->longest_match) |
629 | { | 625 | { |
630 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 626 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
631 | "no match in block\n"); | 627 | "no match in block\n"); |
632 | return; | 628 | return; |
633 | } | 629 | } |
634 | 630 | ||
635 | hash = &ctx->hash; | 631 | hash = &ctx->hash; |
636 | new_ctx = GNUNET_new (struct RegexSearchContext); | 632 | new_ctx = GNUNET_new(struct RegexSearchContext); |
637 | new_ctx->info = info; | 633 | new_ctx->info = info; |
638 | new_ctx->position = ctx->position + ctx->longest_match; | 634 | new_ctx->position = ctx->position + ctx->longest_match; |
639 | GNUNET_array_append (info->contexts, info->n_contexts, new_ctx); | 635 | GNUNET_array_append(info->contexts, info->n_contexts, new_ctx); |
640 | 636 | ||
641 | /* Check whether we already have a DHT GET running for it */ | 637 | /* Check whether we already have a DHT GET running for it */ |
642 | if (GNUNET_YES == | 638 | if (GNUNET_YES == |
643 | GNUNET_CONTAINER_multihashmap_contains (info->dht_get_handles, hash)) | 639 | GNUNET_CONTAINER_multihashmap_contains(info->dht_get_handles, hash)) |
644 | { | 640 | { |
645 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 641 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
646 | "GET for %s running, END\n", | 642 | "GET for %s running, END\n", |
647 | GNUNET_h2s (hash)); | 643 | GNUNET_h2s(hash)); |
648 | GNUNET_CONTAINER_multihashmap_get_multiple (info->dht_get_results, | 644 | GNUNET_CONTAINER_multihashmap_get_multiple(info->dht_get_results, |
649 | hash, | 645 | hash, |
650 | ®ex_result_iterator, | 646 | ®ex_result_iterator, |
651 | new_ctx); | 647 | new_ctx); |
652 | return; /* We are already looking for it */ | 648 | return; /* We are already looking for it */ |
653 | } | 649 | } |
654 | 650 | ||
655 | GNUNET_STATISTICS_update (info->stats, "# regex nodes traversed", | 651 | GNUNET_STATISTICS_update(info->stats, "# regex nodes traversed", |
656 | 1, GNUNET_NO); | 652 | 1, GNUNET_NO); |
657 | 653 | ||
658 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 654 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
659 | "Following edges at %s for offset %u in `%s'\n", | 655 | "Following edges at %s for offset %u in `%s'\n", |
660 | GNUNET_h2s (hash), | 656 | GNUNET_h2s(hash), |
661 | (unsigned int) ctx->position, | 657 | (unsigned int)ctx->position, |
662 | info->description); | 658 | info->description); |
663 | rest = &new_ctx->info->description[new_ctx->position]; | 659 | rest = &new_ctx->info->description[new_ctx->position]; |
664 | get_h = | 660 | get_h = |
665 | GNUNET_DHT_get_start (info->dht, /* handle */ | 661 | GNUNET_DHT_get_start(info->dht, /* handle */ |
666 | GNUNET_BLOCK_TYPE_REGEX, /* type */ | 662 | GNUNET_BLOCK_TYPE_REGEX, /* type */ |
667 | hash, /* key to search */ | 663 | hash, /* key to search */ |
668 | DHT_REPLICATION, /* replication level */ | 664 | DHT_REPLICATION, /* replication level */ |
669 | DHT_OPT, | 665 | DHT_OPT, |
670 | rest, /* xquery */ | 666 | rest, /* xquery */ |
671 | strlen (rest) + 1, /* xquery bits */ | 667 | strlen(rest) + 1, /* xquery bits */ |
672 | &dht_get_string_handler, new_ctx); | 668 | &dht_get_string_handler, new_ctx); |
673 | if (GNUNET_OK != | 669 | if (GNUNET_OK != |
674 | GNUNET_CONTAINER_multihashmap_put(info->dht_get_handles, | 670 | GNUNET_CONTAINER_multihashmap_put(info->dht_get_handles, |
675 | hash, | 671 | hash, |
676 | get_h, | 672 | get_h, |
677 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)) | 673 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)) |
678 | { | 674 | { |
679 | GNUNET_break (0); | 675 | GNUNET_break(0); |
680 | return; | 676 | return; |
681 | } | 677 | } |
682 | } | 678 | } |
683 | 679 | ||
684 | 680 | ||
@@ -696,11 +692,11 @@ regex_next_edge (const struct RegexBlock *block, | |||
696 | * Must be freed by calling #REGEX_INTERNAL_search_cancel(). | 692 | * Must be freed by calling #REGEX_INTERNAL_search_cancel(). |
697 | */ | 693 | */ |
698 | struct REGEX_INTERNAL_Search * | 694 | struct REGEX_INTERNAL_Search * |
699 | REGEX_INTERNAL_search (struct GNUNET_DHT_Handle *dht, | 695 | REGEX_INTERNAL_search(struct GNUNET_DHT_Handle *dht, |
700 | const char *string, | 696 | const char *string, |
701 | REGEX_INTERNAL_Found callback, | 697 | REGEX_INTERNAL_Found callback, |
702 | void *callback_cls, | 698 | void *callback_cls, |
703 | struct GNUNET_STATISTICS_Handle *stats) | 699 | struct GNUNET_STATISTICS_Handle *stats) |
704 | { | 700 | { |
705 | struct REGEX_INTERNAL_Search *h; | 701 | struct REGEX_INTERNAL_Search *h; |
706 | struct GNUNET_DHT_GetHandle *get_h; | 702 | struct GNUNET_DHT_GetHandle *get_h; |
@@ -710,50 +706,50 @@ REGEX_INTERNAL_search (struct GNUNET_DHT_Handle *dht, | |||
710 | size_t len; | 706 | size_t len; |
711 | 707 | ||
712 | /* Initialize handle */ | 708 | /* Initialize handle */ |
713 | GNUNET_assert (NULL != dht); | 709 | GNUNET_assert(NULL != dht); |
714 | GNUNET_assert (NULL != callback); | 710 | GNUNET_assert(NULL != callback); |
715 | h = GNUNET_new (struct REGEX_INTERNAL_Search); | 711 | h = GNUNET_new(struct REGEX_INTERNAL_Search); |
716 | h->dht = dht; | 712 | h->dht = dht; |
717 | h->description = GNUNET_strdup (string); | 713 | h->description = GNUNET_strdup(string); |
718 | h->callback = callback; | 714 | h->callback = callback; |
719 | h->callback_cls = callback_cls; | 715 | h->callback_cls = callback_cls; |
720 | h->stats = stats; | 716 | h->stats = stats; |
721 | h->dht_get_handles = GNUNET_CONTAINER_multihashmap_create (32, GNUNET_NO); | 717 | h->dht_get_handles = GNUNET_CONTAINER_multihashmap_create(32, GNUNET_NO); |
722 | h->dht_get_results = GNUNET_CONTAINER_multihashmap_create (32, GNUNET_NO); | 718 | h->dht_get_results = GNUNET_CONTAINER_multihashmap_create(32, GNUNET_NO); |
723 | 719 | ||
724 | /* Initialize context */ | 720 | /* Initialize context */ |
725 | len = strlen (string); | 721 | len = strlen(string); |
726 | size = REGEX_INTERNAL_get_first_key (string, len, &key); | 722 | size = REGEX_INTERNAL_get_first_key(string, len, &key); |
727 | LOG (GNUNET_ERROR_TYPE_INFO, | 723 | LOG(GNUNET_ERROR_TYPE_INFO, |
728 | "Initial key for `%s' is %s (based on `%.*s')\n", | 724 | "Initial key for `%s' is %s (based on `%.*s')\n", |
729 | string, | 725 | string, |
730 | GNUNET_h2s (&key), | 726 | GNUNET_h2s(&key), |
731 | size, | 727 | size, |
732 | string); | 728 | string); |
733 | ctx = GNUNET_new (struct RegexSearchContext); | 729 | ctx = GNUNET_new(struct RegexSearchContext); |
734 | ctx->position = size; | 730 | ctx->position = size; |
735 | ctx->info = h; | 731 | ctx->info = h; |
736 | GNUNET_array_append (h->contexts, | 732 | GNUNET_array_append(h->contexts, |
737 | h->n_contexts, | 733 | h->n_contexts, |
738 | ctx); | 734 | ctx); |
739 | /* Start search in DHT */ | 735 | /* Start search in DHT */ |
740 | get_h = GNUNET_DHT_get_start (h->dht, /* handle */ | 736 | get_h = GNUNET_DHT_get_start(h->dht, /* handle */ |
741 | GNUNET_BLOCK_TYPE_REGEX, /* type */ | 737 | GNUNET_BLOCK_TYPE_REGEX, /* type */ |
742 | &key, /* key to search */ | 738 | &key, /* key to search */ |
743 | DHT_REPLICATION, /* replication level */ | 739 | DHT_REPLICATION, /* replication level */ |
744 | DHT_OPT, | 740 | DHT_OPT, |
745 | &h->description[size], /* xquery */ | 741 | &h->description[size], /* xquery */ |
746 | // FIXME add BLOOMFILTER to exclude filtered peers | 742 | // FIXME add BLOOMFILTER to exclude filtered peers |
747 | len + 1 - size, /* xquery bits */ | 743 | len + 1 - size, /* xquery bits */ |
748 | // FIXME add BLOOMFILTER SIZE | 744 | // FIXME add BLOOMFILTER SIZE |
749 | &dht_get_string_handler, ctx); | 745 | &dht_get_string_handler, ctx); |
750 | GNUNET_break ( | 746 | GNUNET_break( |
751 | GNUNET_OK == | 747 | GNUNET_OK == |
752 | GNUNET_CONTAINER_multihashmap_put (h->dht_get_handles, | 748 | GNUNET_CONTAINER_multihashmap_put(h->dht_get_handles, |
753 | &key, | 749 | &key, |
754 | get_h, | 750 | get_h, |
755 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST) | 751 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST) |
756 | ); | 752 | ); |
757 | 753 | ||
758 | return h; | 754 | return h; |
759 | } | 755 | } |
@@ -770,13 +766,13 @@ REGEX_INTERNAL_search (struct GNUNET_DHT_Handle *dht, | |||
770 | * #GNUNET_NO if not. | 766 | * #GNUNET_NO if not. |
771 | */ | 767 | */ |
772 | static int | 768 | static int |
773 | regex_cancel_dht_get (void *cls, | 769 | regex_cancel_dht_get(void *cls, |
774 | const struct GNUNET_HashCode * key, | 770 | const struct GNUNET_HashCode * key, |
775 | void *value) | 771 | void *value) |
776 | { | 772 | { |
777 | struct GNUNET_DHT_GetHandle *h = value; | 773 | struct GNUNET_DHT_GetHandle *h = value; |
778 | 774 | ||
779 | GNUNET_DHT_get_stop (h); | 775 | GNUNET_DHT_get_stop(h); |
780 | return GNUNET_YES; | 776 | return GNUNET_YES; |
781 | } | 777 | } |
782 | 778 | ||
@@ -792,11 +788,11 @@ regex_cancel_dht_get (void *cls, | |||
792 | * #GNUNET_NO if not. | 788 | * #GNUNET_NO if not. |
793 | */ | 789 | */ |
794 | static int | 790 | static int |
795 | regex_free_result (void *cls, | 791 | regex_free_result(void *cls, |
796 | const struct GNUNET_HashCode * key, | 792 | const struct GNUNET_HashCode * key, |
797 | void *value) | 793 | void *value) |
798 | { | 794 | { |
799 | GNUNET_free (value); | 795 | GNUNET_free(value); |
800 | return GNUNET_YES; | 796 | return GNUNET_YES; |
801 | } | 797 | } |
802 | 798 | ||
@@ -807,24 +803,24 @@ regex_free_result (void *cls, | |||
807 | * @param h the search context. | 803 | * @param h the search context. |
808 | */ | 804 | */ |
809 | void | 805 | void |
810 | REGEX_INTERNAL_search_cancel (struct REGEX_INTERNAL_Search *h) | 806 | REGEX_INTERNAL_search_cancel(struct REGEX_INTERNAL_Search *h) |
811 | { | 807 | { |
812 | unsigned int i; | 808 | unsigned int i; |
813 | 809 | ||
814 | GNUNET_free (h->description); | 810 | GNUNET_free(h->description); |
815 | GNUNET_CONTAINER_multihashmap_iterate (h->dht_get_handles, | 811 | GNUNET_CONTAINER_multihashmap_iterate(h->dht_get_handles, |
816 | ®ex_cancel_dht_get, NULL); | 812 | ®ex_cancel_dht_get, NULL); |
817 | GNUNET_CONTAINER_multihashmap_iterate (h->dht_get_results, | 813 | GNUNET_CONTAINER_multihashmap_iterate(h->dht_get_results, |
818 | ®ex_free_result, NULL); | 814 | ®ex_free_result, NULL); |
819 | GNUNET_CONTAINER_multihashmap_destroy (h->dht_get_results); | 815 | GNUNET_CONTAINER_multihashmap_destroy(h->dht_get_results); |
820 | GNUNET_CONTAINER_multihashmap_destroy (h->dht_get_handles); | 816 | GNUNET_CONTAINER_multihashmap_destroy(h->dht_get_handles); |
821 | if (0 < h->n_contexts) | 817 | if (0 < h->n_contexts) |
822 | { | 818 | { |
823 | for (i = 0; i < h->n_contexts; i++) | 819 | for (i = 0; i < h->n_contexts; i++) |
824 | GNUNET_free (h->contexts[i]); | 820 | GNUNET_free(h->contexts[i]); |
825 | GNUNET_free (h->contexts); | 821 | GNUNET_free(h->contexts); |
826 | } | 822 | } |
827 | GNUNET_free (h); | 823 | GNUNET_free(h); |
828 | } | 824 | } |
829 | 825 | ||
830 | 826 | ||