aboutsummaryrefslogtreecommitdiff
path: root/src/ats/ats_api.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-05-06 01:12:57 +0000
committerChristian Grothoff <christian@grothoff.org>2012-05-06 01:12:57 +0000
commit9fac6b6eefdc9144053f736fd388cb2199a97046 (patch)
tree82740a981b7f6ae973d915aa77797acd9db668b2 /src/ats/ats_api.c
parent23d8d343d5c70481ecf78ec4fafc698907f3e8a9 (diff)
downloadgnunet-9fac6b6eefdc9144053f736fd388cb2199a97046.tar.gz
gnunet-9fac6b6eefdc9144053f736fd388cb2199a97046.zip
-removing legacy ifdefs, fixing log statements
Diffstat (limited to 'src/ats/ats_api.c')
-rw-r--r--src/ats/ats_api.c28
1 files changed, 0 insertions, 28 deletions
diff --git a/src/ats/ats_api.c b/src/ats/ats_api.c
index 82eede9dc..8499c5b22 100644
--- a/src/ats/ats_api.c
+++ b/src/ats/ats_api.c
@@ -34,8 +34,6 @@
34#include "gnunet_ats_service.h" 34#include "gnunet_ats_service.h"
35#include "ats_api.h" 35#include "ats_api.h"
36 36
37#define DEBUG_ATS GNUNET_EXTRA_LOGGING
38
39#define LOG(kind,...) GNUNET_log_from (kind, "ats-api", __VA_ARGS__) 37#define LOG(kind,...) GNUNET_log_from (kind, "ats-api", __VA_ARGS__)
40 38
41/** 39/**
@@ -235,13 +233,10 @@ suggest_address (void *cls, const GNUNET_HashCode * key, void *value)
235 struct GNUNET_ATS_SuggestionContext *asc = cls; 233 struct GNUNET_ATS_SuggestionContext *asc = cls;
236 struct AllocationRecord *ar = value; 234 struct AllocationRecord *ar = value;
237 235
238#if DEBUG_ATS
239 LOG (GNUNET_ERROR_TYPE_DEBUG, 236 LOG (GNUNET_ERROR_TYPE_DEBUG,
240 "Suggesting address for peer `%s', starting with i:%u/o:%u bytes/s\n", 237 "Suggesting address for peer `%s', starting with i:%u/o:%u bytes/s\n",
241 GNUNET_h2s (key), asc->atc->total_bps_in / 32, 238 GNUNET_h2s (key), asc->atc->total_bps_in / 32,
242 asc->atc->total_bps_out / 32); 239 asc->atc->total_bps_out / 32);
243#endif
244
245 /* trivial strategy: pick first available address... */ 240 /* trivial strategy: pick first available address... */
246 asc->cb (asc->cb_cls, &asc->target, ar->plugin_name, ar->plugin_addr, 241 asc->cb (asc->cb_cls, &asc->target, ar->plugin_name, ar->plugin_addr,
247 ar->plugin_addr_len, ar->session, 242 ar->plugin_addr_len, ar->session,
@@ -269,10 +264,8 @@ GNUNET_ATS_suggest_address (struct GNUNET_ATS_SchedulingHandle *atc,
269{ 264{
270 struct GNUNET_ATS_SuggestionContext *asc; 265 struct GNUNET_ATS_SuggestionContext *asc;
271 266
272#if DEBUG_ATS
273 LOG (GNUNET_ERROR_TYPE_DEBUG, "Looking up suggested address for peer `%s'\n", 267 LOG (GNUNET_ERROR_TYPE_DEBUG, "Looking up suggested address for peer `%s'\n",
274 GNUNET_i2s (peer)); 268 GNUNET_i2s (peer));
275#endif
276 asc = GNUNET_malloc (sizeof (struct GNUNET_ATS_SuggestionContext)); 269 asc = GNUNET_malloc (sizeof (struct GNUNET_ATS_SuggestionContext));
277 asc->cb = cb; 270 asc->cb = cb;
278 asc->cb_cls = cb_cls; 271 asc->cb_cls = cb_cls;
@@ -324,9 +317,7 @@ GNUNET_ATS_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
324{ 317{
325 struct GNUNET_ATS_SchedulingHandle *atc; 318 struct GNUNET_ATS_SchedulingHandle *atc;
326 319
327#if DEBUG_ATS
328 LOG (GNUNET_ERROR_TYPE_DEBUG, "ATS init\n"); 320 LOG (GNUNET_ERROR_TYPE_DEBUG, "ATS init\n");
329#endif
330 atc = GNUNET_malloc (sizeof (struct GNUNET_ATS_SchedulingHandle)); 321 atc = GNUNET_malloc (sizeof (struct GNUNET_ATS_SchedulingHandle));
331 atc->cfg = cfg; 322 atc->cfg = cfg;
332 atc->alloc_cb = alloc_cb; 323 atc->alloc_cb = alloc_cb;
@@ -369,9 +360,7 @@ destroy_allocation_record (void *cls, const GNUNET_HashCode * key, void *value)
369void 360void
370GNUNET_ATS_shutdown (struct GNUNET_ATS_SchedulingHandle *atc) 361GNUNET_ATS_shutdown (struct GNUNET_ATS_SchedulingHandle *atc)
371{ 362{
372#if DEBUG_ATS
373 LOG (GNUNET_ERROR_TYPE_DEBUG, "ATS shutdown\n"); 363 LOG (GNUNET_ERROR_TYPE_DEBUG, "ATS shutdown\n");
374#endif
375 if (GNUNET_SCHEDULER_NO_TASK != atc->ba_task) 364 if (GNUNET_SCHEDULER_NO_TASK != atc->ba_task)
376 { 365 {
377 GNUNET_SCHEDULER_cancel (atc->ba_task); 366 GNUNET_SCHEDULER_cancel (atc->ba_task);
@@ -435,10 +424,8 @@ update_session (void *cls, const GNUNET_HashCode * key, void *value)
435 arnew->plugin_addr_len))))) 424 arnew->plugin_addr_len)))))
436 return GNUNET_YES; /* no match */ 425 return GNUNET_YES; /* no match */
437 /* records match */ 426 /* records match */
438#if DEBUG_ATS
439 LOG (GNUNET_ERROR_TYPE_DEBUG, "Updating session for peer `%s' plugin `%s'\n", 427 LOG (GNUNET_ERROR_TYPE_DEBUG, "Updating session for peer `%s' plugin `%s'\n",
440 GNUNET_h2s (key), arold->plugin_name); 428 GNUNET_h2s (key), arold->plugin_name);
441#endif
442 if (arnew->session != arold->session) 429 if (arnew->session != arold->session)
443 { 430 {
444 arold->session = arnew->session; 431 arold->session = arnew->session;
@@ -458,12 +445,10 @@ update_session (void *cls, const GNUNET_HashCode * key, void *value)
458 { 445 {
459 if (arold->ats[c_old].type == arnew->ats[c_new].type) 446 if (arold->ats[c_old].type == arnew->ats[c_new].type)
460 { 447 {
461#if DEBUG_ATS
462 LOG (GNUNET_ERROR_TYPE_DEBUG, 448 LOG (GNUNET_ERROR_TYPE_DEBUG,
463 "Found type %i, old value=%i new value=%i\n", 449 "Found type %i, old value=%i new value=%i\n",
464 ntohl (arold->ats[c_old].type), ntohl (arold->ats[c_old].value), 450 ntohl (arold->ats[c_old].type), ntohl (arold->ats[c_old].value),
465 ntohl (arnew->ats[c_new].value)); 451 ntohl (arnew->ats[c_new].value));
466#endif
467 arold->ats[c_old].value = arnew->ats[c_new].value; 452 arold->ats[c_old].value = arnew->ats[c_new].value;
468 found = GNUNET_YES; 453 found = GNUNET_YES;
469 } 454 }
@@ -472,20 +457,16 @@ update_session (void *cls, const GNUNET_HashCode * key, void *value)
472 /* Add new value */ 457 /* Add new value */
473 if (found == GNUNET_NO) 458 if (found == GNUNET_NO)
474 { 459 {
475#if DEBUG_ATS
476 LOG (GNUNET_ERROR_TYPE_DEBUG, "Added new type %i new value=%i\n", 460 LOG (GNUNET_ERROR_TYPE_DEBUG, "Added new type %i new value=%i\n",
477 ntohl (arnew->ats[c_new].type), ntohl (arnew->ats[c_new].value)); 461 ntohl (arnew->ats[c_new].type), ntohl (arnew->ats[c_new].value));
478 LOG (GNUNET_ERROR_TYPE_DEBUG, "Old array size: %u\n", arold->ats_count); 462 LOG (GNUNET_ERROR_TYPE_DEBUG, "Old array size: %u\n", arold->ats_count);
479#endif
480 GNUNET_array_grow (arold->ats, arold->ats_count, arold->ats_count + 1); 463 GNUNET_array_grow (arold->ats, arold->ats_count, arold->ats_count + 1);
481 GNUNET_assert (arold->ats_count >= 2); 464 GNUNET_assert (arold->ats_count >= 2);
482 arold->ats[arold->ats_count - 2].type = arnew->ats[c_new].type; 465 arold->ats[arold->ats_count - 2].type = arnew->ats[c_new].type;
483 arold->ats[arold->ats_count - 2].value = arnew->ats[c_new].value; 466 arold->ats[arold->ats_count - 2].value = arnew->ats[c_new].value;
484 arold->ats[arold->ats_count - 1].type = htonl (0); 467 arold->ats[arold->ats_count - 1].type = htonl (0);
485 arold->ats[arold->ats_count - 1].value = htonl (0); 468 arold->ats[arold->ats_count - 1].value = htonl (0);
486#if DEBUG_ATS
487 LOG (GNUNET_ERROR_TYPE_DEBUG, "New array size: %i\n", arold->ats_count); 469 LOG (GNUNET_ERROR_TYPE_DEBUG, "New array size: %i\n", arold->ats_count);
488#endif
489 } 470 }
490 c_new++; 471 c_new++;
491 } 472 }
@@ -577,10 +558,7 @@ GNUNET_ATS_peer_connect (struct GNUNET_ATS_SchedulingHandle *atc,
577 struct AllocationRecord *ar; 558 struct AllocationRecord *ar;
578 struct UpdateSessionContext usc; 559 struct UpdateSessionContext usc;
579 560
580#if DEBUG_ATS
581 LOG (GNUNET_ERROR_TYPE_DEBUG, "Connected to peer %s\n", GNUNET_i2s (peer)); 561 LOG (GNUNET_ERROR_TYPE_DEBUG, "Connected to peer %s\n", GNUNET_i2s (peer));
582#endif
583
584 (void) GNUNET_CONTAINER_multihashmap_iterate (atc->peers, &disconnect_peer, 562 (void) GNUNET_CONTAINER_multihashmap_iterate (atc->peers, &disconnect_peer,
585 atc); 563 atc);
586 ar = create_allocation_record (plugin_name, session, plugin_addr, 564 ar = create_allocation_record (plugin_name, session, plugin_addr,
@@ -613,10 +591,8 @@ void
613GNUNET_ATS_peer_disconnect (struct GNUNET_ATS_SchedulingHandle *atc, 591GNUNET_ATS_peer_disconnect (struct GNUNET_ATS_SchedulingHandle *atc,
614 const struct GNUNET_PeerIdentity *peer) 592 const struct GNUNET_PeerIdentity *peer)
615{ 593{
616#if DEBUG_ATS
617 LOG (GNUNET_ERROR_TYPE_DEBUG, "Disconnected from peer %s\n", 594 LOG (GNUNET_ERROR_TYPE_DEBUG, "Disconnected from peer %s\n",
618 GNUNET_i2s (peer)); 595 GNUNET_i2s (peer));
619#endif
620 (void) GNUNET_CONTAINER_multihashmap_get_multiple (atc->peers, 596 (void) GNUNET_CONTAINER_multihashmap_get_multiple (atc->peers,
621 &peer->hashPubKey, 597 &peer->hashPubKey,
622 &disconnect_peer, atc); 598 &disconnect_peer, atc);
@@ -748,10 +724,8 @@ GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *atc,
748 struct AllocationRecord *ar; 724 struct AllocationRecord *ar;
749 struct UpdateSessionContext usc; 725 struct UpdateSessionContext usc;
750 726
751#if DEBUG_ATS
752 LOG (GNUNET_ERROR_TYPE_DEBUG, "Updating address for peer `%s', plugin `%s'\n", 727 LOG (GNUNET_ERROR_TYPE_DEBUG, "Updating address for peer `%s', plugin `%s'\n",
753 GNUNET_i2s (peer), plugin_name); 728 GNUNET_i2s (peer), plugin_name);
754#endif
755 ar = create_allocation_record (plugin_name, session, plugin_addr, 729 ar = create_allocation_record (plugin_name, session, plugin_addr,
756 plugin_addr_len, ats, ats_count); 730 plugin_addr_len, ats, ats_count);
757 usc.atc = atc; 731 usc.atc = atc;
@@ -762,11 +736,9 @@ GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *atc,
762 destroy_allocation_record (NULL, &peer->hashPubKey, ar); 736 destroy_allocation_record (NULL, &peer->hashPubKey, ar);
763 return; 737 return;
764 } 738 }
765#if DEBUG_ATS
766 LOG (GNUNET_ERROR_TYPE_DEBUG, 739 LOG (GNUNET_ERROR_TYPE_DEBUG,
767 "Adding new address for peer `%s', plugin `%s'\n", GNUNET_i2s (peer), 740 "Adding new address for peer `%s', plugin `%s'\n", GNUNET_i2s (peer),
768 plugin_name); 741 plugin_name);
769#endif
770 ar->connected = GNUNET_NO; 742 ar->connected = GNUNET_NO;
771 GNUNET_assert (GNUNET_OK == 743 GNUNET_assert (GNUNET_OK ==
772 GNUNET_CONTAINER_multihashmap_put (atc->peers, 744 GNUNET_CONTAINER_multihashmap_put (atc->peers,