diff options
author | Christian Fuchs <christian.fuchs@cfuchs.net> | 2013-11-11 15:13:19 +0000 |
---|---|---|
committer | Christian Fuchs <christian.fuchs@cfuchs.net> | 2013-11-11 15:13:19 +0000 |
commit | 74d9e28db4e0e515ec17c5fdd1994f6f18377c7b (patch) | |
tree | 591673c786956346f4a7356676c3feab93309727 /src/set | |
parent | fda486b0c477b30ad181e8e986046e23dca7a086 (diff) | |
download | gnunet-74d9e28db4e0e515ec17c5fdd1994f6f18377c7b.tar.gz gnunet-74d9e28db4e0e515ec17c5fdd1994f6f18377c7b.zip |
updated some more dox
Diffstat (limited to 'src/set')
-rw-r--r-- | src/set/gnunet-service-set.c | 66 |
1 files changed, 34 insertions, 32 deletions
diff --git a/src/set/gnunet-service-set.c b/src/set/gnunet-service-set.c index 7338059fa..1a2b0cc31 100644 --- a/src/set/gnunet-service-set.c +++ b/src/set/gnunet-service-set.c | |||
@@ -234,32 +234,11 @@ listener_destroy (struct Listener *listener) | |||
234 | 234 | ||
235 | 235 | ||
236 | /** | 236 | /** |
237 | * Iterator over hash map entries to free | ||
238 | * element entries. | ||
239 | * | ||
240 | * @param cls closure | ||
241 | * @param key current key code | ||
242 | * @param value value in the hash map | ||
243 | * @return GNUNET_YES if we should continue to | ||
244 | * iterate, | ||
245 | * GNUNET_NO if not. | ||
246 | */ | ||
247 | static int | ||
248 | destroy_elements_iterator (void *cls, | ||
249 | const struct GNUNET_HashCode * key, | ||
250 | void *value) | ||
251 | { | ||
252 | struct ElementEntry *ee = value; | ||
253 | |||
254 | GNUNET_free (ee); | ||
255 | return GNUNET_YES; | ||
256 | } | ||
257 | |||
258 | |||
259 | /** | ||
260 | * Collect and destroy elements that are not needed anymore, because | 237 | * Collect and destroy elements that are not needed anymore, because |
261 | * their lifetime (as determined by their generation) does not overlap with any active | 238 | * their lifetime (as determined by their generation) does not overlap with any active |
262 | * set operation. | 239 | * set operation. |
240 | * | ||
241 | * We hereby replace the old element hashmap with a new one, instead of removing elements. | ||
263 | */ | 242 | */ |
264 | void | 243 | void |
265 | collect_generation_garbage (struct Set *set) | 244 | collect_generation_garbage (struct Set *set) |
@@ -273,20 +252,20 @@ collect_generation_garbage (struct Set *set) | |||
273 | new_elements = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO); | 252 | new_elements = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO); |
274 | iter = GNUNET_CONTAINER_multihashmap_iterator_create (set->elements); | 253 | iter = GNUNET_CONTAINER_multihashmap_iterator_create (set->elements); |
275 | while (GNUNET_OK == | 254 | while (GNUNET_OK == |
276 | (res = GNUNET_CONTAINER_multihashmap_iterator_next (iter, NULL, (const void **) &ee))) | 255 | (res = GNUNET_CONTAINER_multihashmap_iterator_next (iter, NULL, (const void **) &ee))) |
277 | { | 256 | { |
278 | if (GNUNET_NO == ee->removed) | 257 | if (GNUNET_NO == ee->removed) |
279 | goto still_needed; | 258 | goto still_needed; |
280 | for (op = set->ops_head; NULL != op; op = op->next) | 259 | for (op = set->ops_head; NULL != op; op = op->next) |
281 | if ( (op->generation_created >= ee->generation_added) && | 260 | if ((op->generation_created >= ee->generation_added) && |
282 | (op->generation_created < ee->generation_removed) ) | 261 | (op->generation_created < ee->generation_removed)) |
283 | goto still_needed; | 262 | goto still_needed; |
284 | GNUNET_free (ee); | 263 | GNUNET_free (ee); |
285 | continue; | 264 | continue; |
286 | still_needed: | 265 | still_needed: |
287 | // we don't expect collisions, thus the replace option | 266 | // we don't expect collisions, thus the replace option |
288 | GNUNET_CONTAINER_multihashmap_put (new_elements, &ee->element_hash, ee, | 267 | GNUNET_CONTAINER_multihashmap_put (new_elements, &ee->element_hash, ee, |
289 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE); | 268 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE); |
290 | } | 269 | } |
291 | GNUNET_CONTAINER_multihashmap_iterator_destroy (iter); | 270 | GNUNET_CONTAINER_multihashmap_iterator_destroy (iter); |
292 | GNUNET_CONTAINER_multihashmap_destroy (set->elements); | 271 | GNUNET_CONTAINER_multihashmap_destroy (set->elements); |
@@ -351,6 +330,29 @@ _GSS_operation_destroy (struct Operation *op) | |||
351 | 330 | ||
352 | 331 | ||
353 | /** | 332 | /** |
333 | * Iterator over hash map entries to free | ||
334 | * element entries. | ||
335 | * | ||
336 | * @param cls closure | ||
337 | * @param key current key code | ||
338 | * @param value value in the hash map | ||
339 | * @return GNUNET_YES if we should continue to | ||
340 | * iterate, | ||
341 | * GNUNET_NO if not. | ||
342 | */ | ||
343 | static int | ||
344 | destroy_elements_iterator (void *cls, | ||
345 | const struct GNUNET_HashCode * key, | ||
346 | void *value) | ||
347 | { | ||
348 | struct ElementEntry *ee = value; | ||
349 | |||
350 | GNUNET_free (ee); | ||
351 | return GNUNET_YES; | ||
352 | } | ||
353 | |||
354 | |||
355 | /** | ||
354 | * Destroy a set, and free all resources associated with it. | 356 | * Destroy a set, and free all resources associated with it. |
355 | * | 357 | * |
356 | * @param set the set to destroy | 358 | * @param set the set to destroy |
@@ -362,7 +364,6 @@ set_destroy (struct Set *set) | |||
362 | * The client's destroy callback will destroy the set again. | 364 | * The client's destroy callback will destroy the set again. |
363 | * We do this so that the tunnel end handler still has a valid set handle | 365 | * We do this so that the tunnel end handler still has a valid set handle |
364 | * to destroy. */ | 366 | * to destroy. */ |
365 | // TODO: use client context | ||
366 | if (NULL != set->client) | 367 | if (NULL != set->client) |
367 | { | 368 | { |
368 | struct GNUNET_SERVER_Client *client = set->client; | 369 | struct GNUNET_SERVER_Client *client = set->client; |
@@ -388,6 +389,7 @@ set_destroy (struct Set *set) | |||
388 | GNUNET_CONTAINER_DLL_remove (sets_head, sets_tail, set); | 389 | GNUNET_CONTAINER_DLL_remove (sets_head, sets_tail, set); |
389 | if (NULL != set->elements) | 390 | if (NULL != set->elements) |
390 | { | 391 | { |
392 | // free all elements in the hashtable, before destroying the table | ||
391 | GNUNET_CONTAINER_multihashmap_iterate (set->elements, | 393 | GNUNET_CONTAINER_multihashmap_iterate (set->elements, |
392 | destroy_elements_iterator, NULL); | 394 | destroy_elements_iterator, NULL); |
393 | GNUNET_CONTAINER_multihashmap_destroy (set->elements); | 395 | GNUNET_CONTAINER_multihashmap_destroy (set->elements); |
@@ -489,8 +491,8 @@ listener_get_by_target (enum GNUNET_SET_OperationType op, | |||
489 | 491 | ||
490 | 492 | ||
491 | /** | 493 | /** |
492 | * Suggest the given request to the listener, | 494 | * Suggest the given request to the listener. The listening client can then |
493 | * who can accept or reject the request. | 495 | * accept or reject the remote request. |
494 | * | 496 | * |
495 | * @param incoming the incoming peer with the request to suggest | 497 | * @param incoming the incoming peer with the request to suggest |
496 | * @param listener the listener to suggest the request to | 498 | * @param listener the listener to suggest the request to |