diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-10-10 13:46:01 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-10-10 13:46:01 +0000 |
commit | ce2f5fa9e8dd91ccd9647d38e86d33bdc0a7001c (patch) | |
tree | 94674c478a978a229ce4e618aeb2369eb1640b4d /src/ats/ats_api.c | |
parent | 21ef781a9e2bf50ff728af7277b90443779822fa (diff) | |
download | gnunet-ce2f5fa9e8dd91ccd9647d38e86d33bdc0a7001c.tar.gz gnunet-ce2f5fa9e8dd91ccd9647d38e86d33bdc0a7001c.zip |
use LOG macro in ats_api.c
Diffstat (limited to 'src/ats/ats_api.c')
-rw-r--r-- | src/ats/ats_api.c | 93 |
1 files changed, 45 insertions, 48 deletions
diff --git a/src/ats/ats_api.c b/src/ats/ats_api.c index 53ab6e9ca..20cf62ca7 100644 --- a/src/ats/ats_api.c +++ b/src/ats/ats_api.c | |||
@@ -36,6 +36,8 @@ | |||
36 | 36 | ||
37 | #define DEBUG_ATS GNUNET_EXTRA_LOGGING | 37 | #define DEBUG_ATS GNUNET_EXTRA_LOGGING |
38 | 38 | ||
39 | #define LOG(kind,...) GNUNET_log_from (kind, "ats-api", __VA_ARGS__) | ||
40 | |||
39 | /** | 41 | /** |
40 | * Receive and send buffer windows grow over time. For | 42 | * Receive and send buffer windows grow over time. For |
41 | * how long can 'unused' bandwidth accumulate before we | 43 | * how long can 'unused' bandwidth accumulate before we |
@@ -139,12 +141,13 @@ set_bw_connections (void *cls, const GNUNET_HashCode * key, void *value) | |||
139 | ar->bandwidth_in = sbc->bw_in; | 141 | ar->bandwidth_in = sbc->bw_in; |
140 | ar->bandwidth_out = sbc->bw_out; | 142 | ar->bandwidth_out = sbc->bw_out; |
141 | GNUNET_BANDWIDTH_tracker_update_quota (&ar->available_recv_window, | 143 | GNUNET_BANDWIDTH_tracker_update_quota (&ar->available_recv_window, |
142 | ar->bandwidth_in); | 144 | ar->bandwidth_in); |
143 | if (NULL != sbc->atc->alloc_cb) | 145 | if (NULL != sbc->atc->alloc_cb) |
144 | sbc->atc->alloc_cb (sbc->atc->alloc_cb_cls, | 146 | sbc->atc->alloc_cb (sbc->atc->alloc_cb_cls, |
145 | (const struct GNUNET_PeerIdentity *) key, | 147 | (const struct GNUNET_PeerIdentity *) key, |
146 | ar->plugin_name, ar->session, ar->plugin_addr, | 148 | ar->plugin_name, ar->session, ar->plugin_addr, |
147 | ar->plugin_addr_len, ar->bandwidth_out, ar->bandwidth_in); | 149 | ar->plugin_addr_len, ar->bandwidth_out, |
150 | ar->bandwidth_in); | ||
148 | } | 151 | } |
149 | else if (ntohl (ar->bandwidth_out.value__) > 0) | 152 | else if (ntohl (ar->bandwidth_out.value__) > 0) |
150 | { | 153 | { |
@@ -152,9 +155,10 @@ set_bw_connections (void *cls, const GNUNET_HashCode * key, void *value) | |||
152 | ar->bandwidth_out = GNUNET_BANDWIDTH_value_init (0); | 155 | ar->bandwidth_out = GNUNET_BANDWIDTH_value_init (0); |
153 | if (NULL != sbc->atc->alloc_cb) | 156 | if (NULL != sbc->atc->alloc_cb) |
154 | sbc->atc->alloc_cb (sbc->atc->alloc_cb_cls, | 157 | sbc->atc->alloc_cb (sbc->atc->alloc_cb_cls, |
155 | (const struct GNUNET_PeerIdentity *) key, | 158 | (const struct GNUNET_PeerIdentity *) key, |
156 | ar->plugin_name, ar->session, ar->plugin_addr, | 159 | ar->plugin_name, ar->session, ar->plugin_addr, |
157 | ar->plugin_addr_len, ar->bandwidth_out, ar->bandwidth_in); | 160 | ar->plugin_addr_len, ar->bandwidth_out, |
161 | ar->bandwidth_in); | ||
158 | } | 162 | } |
159 | return GNUNET_YES; | 163 | return GNUNET_YES; |
160 | } | 164 | } |
@@ -217,16 +221,15 @@ suggest_address (void *cls, const GNUNET_HashCode * key, void *value) | |||
217 | struct AllocationRecord *ar = value; | 221 | struct AllocationRecord *ar = value; |
218 | 222 | ||
219 | #if DEBUG_ATS | 223 | #if DEBUG_ATS |
220 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "ats-api", | 224 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Suggesting address for peer `%s'\n", |
221 | "Suggesting address for peer `%s'\n", GNUNET_h2s (key)); | 225 | GNUNET_h2s (key)); |
222 | #endif | 226 | #endif |
223 | 227 | ||
224 | /* trivial strategy: pick first available address... */ | 228 | /* trivial strategy: pick first available address... */ |
225 | asc->cb (asc->cb_cls, &asc->target, ar->plugin_name, ar->plugin_addr, | 229 | asc->cb (asc->cb_cls, &asc->target, ar->plugin_name, ar->plugin_addr, |
226 | ar->plugin_addr_len, ar->session, | 230 | ar->plugin_addr_len, ar->session, |
227 | GNUNET_BANDWIDTH_value_init (asc->atc->total_bps_out / 32), | 231 | GNUNET_BANDWIDTH_value_init (asc->atc->total_bps_out / 32), |
228 | GNUNET_BANDWIDTH_value_init (asc->atc->total_bps_in / 32), | 232 | GNUNET_BANDWIDTH_value_init (asc->atc->total_bps_in / 32), ar->ats, |
229 | ar->ats, | ||
230 | ar->ats_count); | 233 | ar->ats_count); |
231 | asc->cb = NULL; | 234 | asc->cb = NULL; |
232 | return GNUNET_NO; | 235 | return GNUNET_NO; |
@@ -235,8 +238,7 @@ suggest_address (void *cls, const GNUNET_HashCode * key, void *value) | |||
235 | int | 238 | int |
236 | map_it (void *cls, const GNUNET_HashCode * key, void *value) | 239 | map_it (void *cls, const GNUNET_HashCode * key, void *value) |
237 | { | 240 | { |
238 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "ats-api", "Found entry for %s\n", | 241 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Found entry for %s\n", GNUNET_h2s (key)); |
239 | GNUNET_h2s (key)); | ||
240 | return GNUNET_YES; | 242 | return GNUNET_YES; |
241 | } | 243 | } |
242 | 244 | ||
@@ -258,17 +260,17 @@ GNUNET_ATS_suggest_address (struct GNUNET_ATS_Handle *atc, | |||
258 | struct GNUNET_ATS_SuggestionContext *asc; | 260 | struct GNUNET_ATS_SuggestionContext *asc; |
259 | 261 | ||
260 | #if DEBUG_ATS | 262 | #if DEBUG_ATS |
261 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "ats-api", | 263 | LOG (GNUNET_ERROR_TYPE_DEBUG, "ats-api", |
262 | "Looking up suggested address for peer `%s'\n", | 264 | "Looking up suggested address for peer `%s'\n", GNUNET_i2s (peer)); |
263 | GNUNET_i2s (peer)); | ||
264 | #endif | 265 | #endif |
265 | asc = GNUNET_malloc (sizeof (struct GNUNET_ATS_SuggestionContext)); | 266 | asc = GNUNET_malloc (sizeof (struct GNUNET_ATS_SuggestionContext)); |
266 | asc->cb = cb; | 267 | asc->cb = cb; |
267 | asc->cb_cls = cb_cls; | 268 | asc->cb_cls = cb_cls; |
268 | asc->atc = atc; | 269 | asc->atc = atc; |
269 | asc->target = *peer; | 270 | asc->target = *peer; |
270 | (void) GNUNET_CONTAINER_multihashmap_get_multiple (atc->peers, &peer->hashPubKey, | 271 | (void) GNUNET_CONTAINER_multihashmap_get_multiple (atc->peers, |
271 | &suggest_address, asc); | 272 | &peer->hashPubKey, |
273 | &suggest_address, asc); | ||
272 | 274 | ||
273 | if (NULL == asc->cb) | 275 | if (NULL == asc->cb) |
274 | { | 276 | { |
@@ -313,7 +315,7 @@ GNUNET_ATS_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
313 | struct GNUNET_ATS_Handle *atc; | 315 | struct GNUNET_ATS_Handle *atc; |
314 | 316 | ||
315 | #if DEBUG_ATS | 317 | #if DEBUG_ATS |
316 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "ats-api", "ATS init\n"); | 318 | LOG (GNUNET_ERROR_TYPE_DEBUG, "ATS init\n"); |
317 | #endif | 319 | #endif |
318 | atc = GNUNET_malloc (sizeof (struct GNUNET_ATS_Handle)); | 320 | atc = GNUNET_malloc (sizeof (struct GNUNET_ATS_Handle)); |
319 | atc->cfg = cfg; | 321 | atc->cfg = cfg; |
@@ -358,7 +360,7 @@ void | |||
358 | GNUNET_ATS_shutdown (struct GNUNET_ATS_Handle *atc) | 360 | GNUNET_ATS_shutdown (struct GNUNET_ATS_Handle *atc) |
359 | { | 361 | { |
360 | #if DEBUG_ATS | 362 | #if DEBUG_ATS |
361 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "ats-api", "ATS shutdown\n"); | 363 | LOG (GNUNET_ERROR_TYPE_DEBUG, "ATS shutdown\n"); |
362 | #endif | 364 | #endif |
363 | if (GNUNET_SCHEDULER_NO_TASK != atc->ba_task) | 365 | if (GNUNET_SCHEDULER_NO_TASK != atc->ba_task) |
364 | { | 366 | { |
@@ -414,9 +416,9 @@ update_session (void *cls, const GNUNET_HashCode * key, void *value) | |||
414 | 416 | ||
415 | 417 | ||
416 | #if DEBUG_ATS | 418 | #if DEBUG_ATS |
417 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "ats-api", | 419 | LOG (GNUNET_ERROR_TYPE_DEBUG, "ats-api", |
418 | "Updating session for peer `%s' plugin `%s'\n", | 420 | "Updating session for peer `%s' plugin `%s'\n", GNUNET_h2s (key), |
419 | GNUNET_h2s (key), arold->plugin_name); | 421 | arold->plugin_name); |
420 | #endif | 422 | #endif |
421 | 423 | ||
422 | if (0 != strcmp (arnew->plugin_name, arold->plugin_name)) | 424 | if (0 != strcmp (arnew->plugin_name, arold->plugin_name)) |
@@ -452,11 +454,10 @@ update_session (void *cls, const GNUNET_HashCode * key, void *value) | |||
452 | if (arold->ats[c_old].type == arnew->ats[c_new].type) | 454 | if (arold->ats[c_old].type == arnew->ats[c_new].type) |
453 | { | 455 | { |
454 | #if DEBUG_ATS | 456 | #if DEBUG_ATS |
455 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 457 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
456 | "Found type %i, old value=%i new value=%i\n", | 458 | "Found type %i, old value=%i new value=%i\n", |
457 | ntohl (arold->ats[c_old].type), | 459 | ntohl (arold->ats[c_old].type), ntohl (arold->ats[c_old].value), |
458 | ntohl (arold->ats[c_old].value), | 460 | ntohl (arnew->ats[c_new].value)); |
459 | ntohl (arnew->ats[c_new].value)); | ||
460 | #endif | 461 | #endif |
461 | arold->ats[c_old].value = arnew->ats[c_new].value; | 462 | arold->ats[c_old].value = arnew->ats[c_new].value; |
462 | found = GNUNET_YES; | 463 | found = GNUNET_YES; |
@@ -467,11 +468,9 @@ update_session (void *cls, const GNUNET_HashCode * key, void *value) | |||
467 | if (found == GNUNET_NO) | 468 | if (found == GNUNET_NO) |
468 | { | 469 | { |
469 | #if DEBUG_ATS | 470 | #if DEBUG_ATS |
470 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Added new type %i new value=%i\n", | 471 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Added new type %i new value=%i\n", |
471 | ntohl (arnew->ats[c_new].type), | 472 | ntohl (arnew->ats[c_new].type), ntohl (arnew->ats[c_new].value)); |
472 | ntohl (arnew->ats[c_new].value)); | 473 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Old array size: %u\n", arold->ats_count); |
473 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Old array size: %u\n", | ||
474 | arold->ats_count); | ||
475 | #endif | 474 | #endif |
476 | GNUNET_array_grow (arold->ats, arold->ats_count, arold->ats_count + 1); | 475 | GNUNET_array_grow (arold->ats, arold->ats_count, arold->ats_count + 1); |
477 | GNUNET_assert (arold->ats_count >= 2); | 476 | GNUNET_assert (arold->ats_count >= 2); |
@@ -480,8 +479,7 @@ update_session (void *cls, const GNUNET_HashCode * key, void *value) | |||
480 | arold->ats[arold->ats_count - 1].type = htonl (0); | 479 | arold->ats[arold->ats_count - 1].type = htonl (0); |
481 | arold->ats[arold->ats_count - 1].value = htonl (0); | 480 | arold->ats[arold->ats_count - 1].value = htonl (0); |
482 | #if DEBUG_ATS | 481 | #if DEBUG_ATS |
483 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New array size: %i\n", | 482 | LOG (GNUNET_ERROR_TYPE_DEBUG, "New array size: %i\n", arold->ats_count); |
484 | arold->ats_count); | ||
485 | #endif | 483 | #endif |
486 | } | 484 | } |
487 | c_new++; | 485 | c_new++; |
@@ -518,9 +516,8 @@ create_allocation_record (const char *plugin_name, struct Session *session, | |||
518 | ar->plugin_addr = &ar[1]; | 516 | ar->plugin_addr = &ar[1]; |
519 | memcpy (&ar[1], plugin_addr, plugin_addr_len); | 517 | memcpy (&ar[1], plugin_addr, plugin_addr_len); |
520 | ar->session = session; | 518 | ar->session = session; |
521 | ar->plugin_addr_len = plugin_addr_len; | 519 | ar->plugin_addr_len = plugin_addr_len; |
522 | GNUNET_BANDWIDTH_tracker_init (&ar->available_recv_window, | 520 | GNUNET_BANDWIDTH_tracker_init (&ar->available_recv_window, ar->bandwidth_in, |
523 | ar->bandwidth_in, | ||
524 | MAX_WINDOW_TIME_S); | 521 | MAX_WINDOW_TIME_S); |
525 | GNUNET_assert (ats_count > 0); | 522 | GNUNET_assert (ats_count > 0); |
526 | GNUNET_array_grow (ar->ats, ar->ats_count, ats_count); | 523 | GNUNET_array_grow (ar->ats, ar->ats_count, ats_count); |
@@ -702,9 +699,9 @@ notify_valid (void *cls, const GNUNET_HashCode * key, void *value) | |||
702 | 699 | ||
703 | asc->cb (asc->cb_cls, &asc->target, ar->plugin_name, ar->plugin_addr, | 700 | asc->cb (asc->cb_cls, &asc->target, ar->plugin_name, ar->plugin_addr, |
704 | ar->plugin_addr_len, ar->session, | 701 | ar->plugin_addr_len, ar->session, |
705 | GNUNET_BANDWIDTH_value_init (asc->atc->total_bps_out / 32), | 702 | GNUNET_BANDWIDTH_value_init (asc->atc->total_bps_out / 32), |
706 | GNUNET_BANDWIDTH_value_init (asc->atc->total_bps_in / 32), | 703 | GNUNET_BANDWIDTH_value_init (asc->atc->total_bps_in / 32), ar->ats, |
707 | ar->ats, ar->ats_count); | 704 | ar->ats_count); |
708 | GNUNET_ATS_suggest_address_cancel (asc); | 705 | GNUNET_ATS_suggest_address_cancel (asc); |
709 | asc = NULL; | 706 | asc = NULL; |
710 | return GNUNET_OK; | 707 | return GNUNET_OK; |
@@ -742,9 +739,9 @@ GNUNET_ATS_address_update (struct GNUNET_ATS_Handle *atc, | |||
742 | struct UpdateSessionContext usc; | 739 | struct UpdateSessionContext usc; |
743 | 740 | ||
744 | #if DEBUG_ATS | 741 | #if DEBUG_ATS |
745 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "ats-api", | 742 | LOG (GNUNET_ERROR_TYPE_DEBUG, "ats-api", |
746 | "Updating address for peer `%s', plugin `%s'\n", | 743 | "Updating address for peer `%s', plugin `%s'\n", GNUNET_i2s (peer), |
747 | GNUNET_i2s (peer), plugin_name); | 744 | plugin_name); |
748 | #endif | 745 | #endif |
749 | ar = create_allocation_record (plugin_name, session, plugin_addr, | 746 | ar = create_allocation_record (plugin_name, session, plugin_addr, |
750 | plugin_addr_len, ats, ats_count); | 747 | plugin_addr_len, ats, ats_count); |
@@ -757,9 +754,9 @@ GNUNET_ATS_address_update (struct GNUNET_ATS_Handle *atc, | |||
757 | return; | 754 | return; |
758 | } | 755 | } |
759 | #if DEBUG_ATS | 756 | #if DEBUG_ATS |
760 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "ats-api", | 757 | LOG (GNUNET_ERROR_TYPE_DEBUG, "ats-api", |
761 | "Adding new address for peer `%s', plugin `%s'\n", | 758 | "Adding new address for peer `%s', plugin `%s'\n", GNUNET_i2s (peer), |
762 | GNUNET_i2s (peer), plugin_name); | 759 | plugin_name); |
763 | #endif | 760 | #endif |
764 | GNUNET_assert (GNUNET_OK == | 761 | GNUNET_assert (GNUNET_OK == |
765 | GNUNET_CONTAINER_multihashmap_put (atc->peers, | 762 | GNUNET_CONTAINER_multihashmap_put (atc->peers, |