aboutsummaryrefslogtreecommitdiff
path: root/src/ats/ats_api.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2011-09-09 15:06:53 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2011-09-09 15:06:53 +0000
commit572e6cfded2bece750dc1a0e35432112e89f4467 (patch)
tree6b1ece186d66c4bf321f1a781be2f0f370a9307a /src/ats/ats_api.c
parente58f3d1bc8729c6557b7cad0c04746ae21822364 (diff)
downloadgnunet-572e6cfded2bece750dc1a0e35432112e89f4467.tar.gz
gnunet-572e6cfded2bece750dc1a0e35432112e89f4467.zip
fix in address update + testcase
Diffstat (limited to 'src/ats/ats_api.c')
-rw-r--r--src/ats/ats_api.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/src/ats/ats_api.c b/src/ats/ats_api.c
index e6013a84c..a411d4dcb 100644
--- a/src/ats/ats_api.c
+++ b/src/ats/ats_api.c
@@ -343,13 +343,6 @@ GNUNET_ATS_suggest_address (struct GNUNET_ATS_Handle *atc,
343 GNUNET_CONTAINER_multihashmap_get_multiple (atc->peers, &peer->hashPubKey, 343 GNUNET_CONTAINER_multihashmap_get_multiple (atc->peers, &peer->hashPubKey,
344 &suggest_address, asc); 344 &suggest_address, asc);
345 345
346#if DEBUG_ATS
347 GNUNET_CONTAINER_multihashmap_iterate (atc->peers, &map_it, (void *) peer);
348 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "ats-api",
349 "Addresses %u (of %i) processed, \n", count,
350 GNUNET_CONTAINER_multihashmap_size (atc->peers));
351#endif
352
353 if (NULL == asc->cb) 346 if (NULL == asc->cb)
354 { 347 {
355 GNUNET_free (asc); 348 GNUNET_free (asc);
@@ -531,7 +524,7 @@ update_session (void *cls, const GNUNET_HashCode * key, void *value)
531 { 524 {
532#if DEBUG_ATS 525#if DEBUG_ATS
533 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 526 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
534 "Found type %u, old value=%u new value=%u\n", 527 "Found type %i, old value=%i new value=%i\n",
535 ntohl (arold->ats[c_old].type), 528 ntohl (arold->ats[c_old].type),
536 ntohl (arold->ats[c_old].value), 529 ntohl (arold->ats[c_old].value),
537 ntohl (arnew->ats[c_new].value)); 530 ntohl (arnew->ats[c_new].value));
@@ -545,18 +538,18 @@ update_session (void *cls, const GNUNET_HashCode * key, void *value)
545 if (found == GNUNET_NO) 538 if (found == GNUNET_NO)
546 { 539 {
547#if DEBUG_ATS 540#if DEBUG_ATS
548 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 541 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Added new type %i new value=%i\n",
549 "Added new value type %u, old value=%u new value=%u\n",
550 ntohl (arnew->ats[c_new].type), 542 ntohl (arnew->ats[c_new].type),
551 ntohl (arnew->ats[c_new].value)); 543 ntohl (arnew->ats[c_new].value));
552 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Old array size: %u\n", 544 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Old array size: %u\n",
553 arold->ats_count); 545 arold->ats_count);
554#endif 546#endif
555 GNUNET_array_grow (arold->ats, arold->ats_count, arold->ats_count + 1); 547 GNUNET_array_grow (arold->ats, arold->ats_count, arold->ats_count + 1);
556 arold->ats[arold->ats_count - 1].type = arnew->ats[c_new].type; 548 GNUNET_assert (arold->ats_count >= 2);
557 arold->ats[arold->ats_count - 1].value = arnew->ats[c_new].value; 549 arold->ats[arold->ats_count - 2].type = arnew->ats[c_new].type;
558 arold->ats[arold->ats_count].type = htonl (0); 550 arold->ats[arold->ats_count - 2].value = arnew->ats[c_new].value;
559 arold->ats[arold->ats_count].value = htonl (0); 551 arold->ats[arold->ats_count - 1].type = htonl (0);
552 arold->ats[arold->ats_count - 1].value = htonl (0);
560#if DEBUG_ATS 553#if DEBUG_ATS
561 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New array size: %i\n", 554 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New array size: %i\n",
562 arold->ats_count); 555 arold->ats_count);
@@ -780,6 +773,7 @@ notify_valid (void *cls, const GNUNET_HashCode * key, void *value)
780 GNUNET_BANDWIDTH_value_init (asc->atc->total_bps / 32), ar->ats, 773 GNUNET_BANDWIDTH_value_init (asc->atc->total_bps / 32), ar->ats,
781 ar->ats_count); 774 ar->ats_count);
782 GNUNET_ATS_suggest_address_cancel (asc); 775 GNUNET_ATS_suggest_address_cancel (asc);
776 asc = NULL;
783 return GNUNET_OK; 777 return GNUNET_OK;
784} 778}
785 779