diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-10-25 23:22:33 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-10-25 23:22:33 +0000 |
commit | 124f3e77a5e022f5f7ab49df49023d0080bcbbb4 (patch) | |
tree | 2c88e59709c52594d2c98c6df52671419c957162 /src/fs/gnunet-service-fs_pr.c | |
parent | 8306257cfea6b5ca5d7cd0119b8d1369f422a07f (diff) | |
download | gnunet-124f3e77a5e022f5f7ab49df49023d0080bcbbb4.tar.gz gnunet-124f3e77a5e022f5f7ab49df49023d0080bcbbb4.zip |
-reduce calls in get_latest()
Diffstat (limited to 'src/fs/gnunet-service-fs_pr.c')
-rw-r--r-- | src/fs/gnunet-service-fs_pr.c | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/src/fs/gnunet-service-fs_pr.c b/src/fs/gnunet-service-fs_pr.c index 298532520..b507992b4 100644 --- a/src/fs/gnunet-service-fs_pr.c +++ b/src/fs/gnunet-service-fs_pr.c | |||
@@ -290,13 +290,16 @@ GSF_pending_request_create_ (enum GSF_PendingRequestOptions options, | |||
290 | const struct GNUNET_HashCode *query, | 290 | const struct GNUNET_HashCode *query, |
291 | const struct GNUNET_PeerIdentity *target, | 291 | const struct GNUNET_PeerIdentity *target, |
292 | const char *bf_data, size_t bf_size, | 292 | const char *bf_data, size_t bf_size, |
293 | uint32_t mingle, uint32_t anonymity_level, | 293 | uint32_t mingle, |
294 | uint32_t priority, int32_t ttl, | 294 | uint32_t anonymity_level, |
295 | uint32_t priority, | ||
296 | int32_t ttl, | ||
295 | GNUNET_PEER_Id sender_pid, | 297 | GNUNET_PEER_Id sender_pid, |
296 | GNUNET_PEER_Id origin_pid, | 298 | GNUNET_PEER_Id origin_pid, |
297 | const struct GNUNET_HashCode *replies_seen, | 299 | const struct GNUNET_HashCode *replies_seen, |
298 | unsigned int replies_seen_count, | 300 | unsigned int replies_seen_count, |
299 | GSF_PendingRequestReplyHandler rh, void *rh_cls) | 301 | GSF_PendingRequestReplyHandler rh, |
302 | void *rh_cls) | ||
300 | { | 303 | { |
301 | struct GSF_PendingRequest *pr; | 304 | struct GSF_PendingRequest *pr; |
302 | struct GSF_PendingRequest *dpr; | 305 | struct GSF_PendingRequest *dpr; |
@@ -351,14 +354,16 @@ GSF_pending_request_create_ (enum GSF_PendingRequestOptions options, | |||
351 | pr->replies_seen_size = replies_seen_count; | 354 | pr->replies_seen_size = replies_seen_count; |
352 | pr->replies_seen = | 355 | pr->replies_seen = |
353 | GNUNET_malloc (sizeof (struct GNUNET_HashCode) * pr->replies_seen_size); | 356 | GNUNET_malloc (sizeof (struct GNUNET_HashCode) * pr->replies_seen_size); |
354 | memcpy (pr->replies_seen, replies_seen, | 357 | memcpy (pr->replies_seen, |
358 | replies_seen, | ||
355 | replies_seen_count * sizeof (struct GNUNET_HashCode)); | 359 | replies_seen_count * sizeof (struct GNUNET_HashCode)); |
356 | pr->replies_seen_count = replies_seen_count; | 360 | pr->replies_seen_count = replies_seen_count; |
357 | } | 361 | } |
358 | if (NULL != bf_data) | 362 | if (NULL != bf_data) |
359 | { | 363 | { |
360 | pr->bf = | 364 | pr->bf = |
361 | GNUNET_CONTAINER_bloomfilter_init (bf_data, bf_size, | 365 | GNUNET_CONTAINER_bloomfilter_init (bf_data, |
366 | bf_size, | ||
362 | GNUNET_CONSTANTS_BLOOMFILTER_K); | 367 | GNUNET_CONSTANTS_BLOOMFILTER_K); |
363 | pr->mingle = mingle; | 368 | pr->mingle = mingle; |
364 | } | 369 | } |
@@ -368,26 +373,33 @@ GSF_pending_request_create_ (enum GSF_PendingRequestOptions options, | |||
368 | refresh_bloomfilter (pr); | 373 | refresh_bloomfilter (pr); |
369 | } | 374 | } |
370 | GNUNET_CONTAINER_multihashmap_put (pr_map, | 375 | GNUNET_CONTAINER_multihashmap_put (pr_map, |
371 | &pr->public_data.query, pr, | 376 | &pr->public_data.query, |
377 | pr, | ||
372 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 378 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
373 | if (0 == (options & GSF_PRO_REQUEST_NEVER_EXPIRES)) | 379 | if (0 == (options & GSF_PRO_REQUEST_NEVER_EXPIRES)) |
374 | { | 380 | { |
375 | pr->hnode = | 381 | pr->hnode = |
376 | GNUNET_CONTAINER_heap_insert (requests_by_expiration_heap, pr, | 382 | GNUNET_CONTAINER_heap_insert (requests_by_expiration_heap, |
383 | pr, | ||
377 | pr->public_data.ttl.abs_value_us); | 384 | pr->public_data.ttl.abs_value_us); |
378 | /* make sure we don't track too many requests */ | 385 | /* make sure we don't track too many requests */ |
379 | while (GNUNET_CONTAINER_heap_get_size (requests_by_expiration_heap) > | 386 | while (GNUNET_CONTAINER_heap_get_size (requests_by_expiration_heap) > |
380 | max_pending_requests) | 387 | max_pending_requests) |
381 | { | 388 | { |
382 | dpr = GNUNET_CONTAINER_heap_peek (requests_by_expiration_heap); | 389 | dpr = GNUNET_CONTAINER_heap_peek (requests_by_expiration_heap); |
383 | GNUNET_assert (dpr != NULL); | 390 | GNUNET_assert (NULL != dpr); |
384 | if (pr == dpr) | 391 | if (pr == dpr) |
385 | break; /* let the request live briefly... */ | 392 | break; /* let the request live briefly... */ |
386 | if (NULL != dpr->rh) | 393 | if (NULL != dpr->rh) |
387 | dpr->rh (dpr->rh_cls, GNUNET_BLOCK_EVALUATION_REQUEST_VALID, dpr, | 394 | dpr->rh (dpr->rh_cls, |
388 | UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_TIME_UNIT_FOREVER_ABS, | 395 | GNUNET_BLOCK_EVALUATION_REQUEST_VALID, |
396 | dpr, | ||
397 | UINT32_MAX, | ||
398 | GNUNET_TIME_UNIT_FOREVER_ABS, | ||
399 | GNUNET_TIME_UNIT_FOREVER_ABS, | ||
389 | GNUNET_BLOCK_TYPE_ANY, NULL, 0); | 400 | GNUNET_BLOCK_TYPE_ANY, NULL, 0); |
390 | GSF_pending_request_cancel_ (dpr, GNUNET_YES); | 401 | GSF_pending_request_cancel_ (dpr, |
402 | GNUNET_YES); | ||
391 | } | 403 | } |
392 | } | 404 | } |
393 | GNUNET_STATISTICS_update (GSF_stats, | 405 | GNUNET_STATISTICS_update (GSF_stats, |