diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-06-16 08:02:52 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-06-16 08:02:52 +0000 |
commit | 9a5c11fe129d8572c38e3739adcd218029c87a4e (patch) | |
tree | b067331ccc8c63209ec88dbb5d37ddfa56d499ac | |
parent | f42770d1f169be156a830be52669bd49cb600124 (diff) | |
download | gnunet-9a5c11fe129d8572c38e3739adcd218029c87a4e.tar.gz gnunet-9a5c11fe129d8572c38e3739adcd218029c87a4e.zip |
optimization: only iterate over mamultipeermap entries that match peer id
-rw-r--r-- | src/ats-tool/gnunet-ats.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/ats-tool/gnunet-ats.c b/src/ats-tool/gnunet-ats.c index 766f2fe2a..abba6abb3 100644 --- a/src/ats-tool/gnunet-ats.c +++ b/src/ats-tool/gnunet-ats.c | |||
@@ -341,13 +341,13 @@ find_address_it (void *cls, | |||
341 | * @param ats_count number of performance records in @a ats | 341 | * @param ats_count number of performance records in @a ats |
342 | */ | 342 | */ |
343 | static void | 343 | static void |
344 | ats_perf_mon_cb(void *cls, | 344 | ats_perf_mon_cb (void *cls, |
345 | const struct GNUNET_HELLO_Address *address, | 345 | const struct GNUNET_HELLO_Address *address, |
346 | int active, | 346 | int active, |
347 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, | 347 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, |
348 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | 348 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, |
349 | const struct GNUNET_ATS_Information *ats, | 349 | const struct GNUNET_ATS_Information *ats, |
350 | uint32_t ats_count) | 350 | uint32_t ats_count) |
351 | { | 351 | { |
352 | struct PendingResolutions *pr; | 352 | struct PendingResolutions *pr; |
353 | struct PendingResolutions *cur; | 353 | struct PendingResolutions *cur; |
@@ -366,7 +366,9 @@ ats_perf_mon_cb(void *cls, | |||
366 | GNUNET_free (cur); | 366 | GNUNET_free (cur); |
367 | } | 367 | } |
368 | 368 | ||
369 | GNUNET_CONTAINER_multipeermap_iterate(addresses, &free_addr_it, NULL); | 369 | GNUNET_CONTAINER_multipeermap_iterate (addresses, |
370 | &free_addr_it, | ||
371 | NULL); | ||
370 | return; | 372 | return; |
371 | } | 373 | } |
372 | 374 | ||
@@ -378,9 +380,10 @@ ats_perf_mon_cb(void *cls, | |||
378 | actx.src = address; | 380 | actx.src = address; |
379 | actx.res = NULL; | 381 | actx.res = NULL; |
380 | 382 | ||
381 | GNUNET_CONTAINER_multipeermap_iterate (addresses, | 383 | GNUNET_CONTAINER_multipeermap_get_multiple (addresses, |
382 | &find_address_it, | 384 | &address->peer, |
383 | &actx); | 385 | &find_address_it, |
386 | &actx); | ||
384 | if ((NULL != actx.res)) | 387 | if ((NULL != actx.res)) |
385 | { | 388 | { |
386 | if ((bandwidth_in.value__ == actx.res->bandwidth_in.value__) && | 389 | if ((bandwidth_in.value__ == actx.res->bandwidth_in.value__) && |
@@ -630,7 +633,9 @@ testservice_ats(void *cls, int result) | |||
630 | } | 633 | } |
631 | else if (op_monitor) | 634 | else if (op_monitor) |
632 | { | 635 | { |
633 | ph = GNUNET_ATS_performance_init (cfg, &ats_perf_mon_cb, NULL); | 636 | ph = GNUNET_ATS_performance_init (cfg, |
637 | &ats_perf_mon_cb, | ||
638 | NULL); | ||
634 | if (NULL == ph) | 639 | if (NULL == ph) |
635 | fprintf (stderr, | 640 | fprintf (stderr, |
636 | _("Cannot connect to ATS service, exiting...\n")); | 641 | _("Cannot connect to ATS service, exiting...\n")); |