diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-02-07 12:33:51 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-02-07 12:33:51 +0000 |
commit | 577ad3b798f0cd62c2e9ab92fdc58cfe75a3fcdc (patch) | |
tree | c0b50fb6b802221d17ea691f4e6a16ce30f8e6de /src/ats/gnunet-service-ats_plugins.c | |
parent | c20f6b6366bcfd93ca613b5771dd0dae4b5ccca3 (diff) | |
download | gnunet-577ad3b798f0cd62c2e9ab92fdc58cfe75a3fcdc.tar.gz gnunet-577ad3b798f0cd62c2e9ab92fdc58cfe75a3fcdc.zip |
simplify logic
Diffstat (limited to 'src/ats/gnunet-service-ats_plugins.c')
-rw-r--r-- | src/ats/gnunet-service-ats_plugins.c | 114 |
1 files changed, 76 insertions, 38 deletions
diff --git a/src/ats/gnunet-service-ats_plugins.c b/src/ats/gnunet-service-ats_plugins.c index 5e3f9c8d4..c388e7f67 100644 --- a/src/ats/gnunet-service-ats_plugins.c +++ b/src/ats/gnunet-service-ats_plugins.c | |||
@@ -277,10 +277,10 @@ load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
277 | unsigned long long *in_dest, | 277 | unsigned long long *in_dest, |
278 | int dest_length) | 278 | int dest_length) |
279 | { | 279 | { |
280 | char * entry_in = NULL; | 280 | char *entry_in = NULL; |
281 | char * entry_out = NULL; | 281 | char *entry_out = NULL; |
282 | char * quota_out_str; | 282 | char *quota_out_str; |
283 | char * quota_in_str; | 283 | char *quota_in_str; |
284 | int c; | 284 | int c; |
285 | int res; | 285 | int res; |
286 | 286 | ||
@@ -367,11 +367,11 @@ load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
367 | 367 | ||
368 | if (GNUNET_NO == res) | 368 | if (GNUNET_NO == res) |
369 | { | 369 | { |
370 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 370 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
371 | _("Could not load quota for network `%s': `%s', assigning default bandwidth %llu\n"), | 371 | _("Could not load quota for network `%s': `%s', assigning default bandwidth %llu\n"), |
372 | GNUNET_ATS_print_network_type (c), | 372 | GNUNET_ATS_print_network_type (c), |
373 | quota_in_str, | 373 | quota_in_str, |
374 | GNUNET_ATS_DefaultBandwidth); | 374 | GNUNET_ATS_DefaultBandwidth); |
375 | in_dest[c] = GNUNET_ATS_DefaultBandwidth; | 375 | in_dest[c] = GNUNET_ATS_DefaultBandwidth; |
376 | } | 376 | } |
377 | else | 377 | else |
@@ -385,17 +385,17 @@ load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
385 | } | 385 | } |
386 | else | 386 | else |
387 | { | 387 | { |
388 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 388 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
389 | _("No outbound quota configure for network `%s', assigning default bandwidth %llu\n"), | 389 | _("No outbound quota configure for network `%s', assigning default bandwidth %llu\n"), |
390 | GNUNET_ATS_print_network_type (c), | 390 | GNUNET_ATS_print_network_type (c), |
391 | GNUNET_ATS_DefaultBandwidth); | 391 | GNUNET_ATS_DefaultBandwidth); |
392 | in_dest[c] = GNUNET_ATS_DefaultBandwidth; | 392 | in_dest[c] = GNUNET_ATS_DefaultBandwidth; |
393 | } | 393 | } |
394 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 394 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
395 | "Loaded quota for network `%s' (in/out): %llu %llu\n", | 395 | "Loaded quota for network `%s' (in/out): %llu %llu\n", |
396 | GNUNET_ATS_print_network_type (c), | 396 | GNUNET_ATS_print_network_type (c), |
397 | in_dest[c], | 397 | in_dest[c], |
398 | out_dest[c]); | 398 | out_dest[c]); |
399 | GNUNET_free(entry_out); | 399 | GNUNET_free(entry_out); |
400 | GNUNET_free(entry_in); | 400 | GNUNET_free(entry_in); |
401 | } | 401 | } |
@@ -520,6 +520,15 @@ GAS_plugins_done () | |||
520 | } | 520 | } |
521 | 521 | ||
522 | 522 | ||
523 | /** | ||
524 | * Tell the solver that the given address can now be used | ||
525 | * for talking to the respective peer. | ||
526 | * | ||
527 | * @param new_address the new address | ||
528 | * @param addr_net network scope the address is in | ||
529 | * @param atsi performance data for the address | ||
530 | * @param atsi_count size of the @a atsi array | ||
531 | */ | ||
523 | void | 532 | void |
524 | GAS_plugin_new_address (struct ATS_Address *new_address, | 533 | GAS_plugin_new_address (struct ATS_Address *new_address, |
525 | enum GNUNET_ATS_Network_Type addr_net, | 534 | enum GNUNET_ATS_Network_Type addr_net, |
@@ -532,10 +541,17 @@ GAS_plugin_new_address (struct ATS_Address *new_address, | |||
532 | atsi, | 541 | atsi, |
533 | atsi_count); | 542 | atsi_count); |
534 | sf->s_bulk_stop (sf->cls); | 543 | sf->s_bulk_stop (sf->cls); |
535 | // if (GAS_connectivity_has_peer (&new_address->peer)) GAS_plugin_request_connect_start (&new_address->peer); | ||
536 | } | 544 | } |
537 | 545 | ||
538 | 546 | ||
547 | /** | ||
548 | * Tell the solver that updated performance data was | ||
549 | * observed for the given address. | ||
550 | * | ||
551 | * @param new_address the new address | ||
552 | * @param atsi updated performance data for the address | ||
553 | * @param atsi_count size of the @a atsi array | ||
554 | */ | ||
539 | void | 555 | void |
540 | GAS_plugin_update_address (struct ATS_Address *address, | 556 | GAS_plugin_update_address (struct ATS_Address *address, |
541 | const struct GNUNET_ATS_Information *atsi, | 557 | const struct GNUNET_ATS_Information *atsi, |
@@ -549,6 +565,12 @@ GAS_plugin_update_address (struct ATS_Address *address, | |||
549 | } | 565 | } |
550 | 566 | ||
551 | 567 | ||
568 | /** | ||
569 | * Tell the solver that the given address is no longer valid | ||
570 | * can cannot be used any longer. | ||
571 | * | ||
572 | * @param address address that was deleted | ||
573 | */ | ||
552 | void | 574 | void |
553 | GAS_plugin_delete_address (struct ATS_Address *address) | 575 | GAS_plugin_delete_address (struct ATS_Address *address) |
554 | { | 576 | { |
@@ -556,35 +578,36 @@ GAS_plugin_delete_address (struct ATS_Address *address) | |||
556 | } | 578 | } |
557 | 579 | ||
558 | 580 | ||
581 | /** | ||
582 | * Tell the solver that the given client has expressed its | ||
583 | * appreciation for the past performance of a given connection. | ||
584 | * | ||
585 | * @param application client providing the feedback | ||
586 | * @param peer peer the feedback is about | ||
587 | * @param scope timeframe the feedback applies to | ||
588 | * @param kind performance property the feedback relates to | ||
589 | * @param score_abs degree of the appreciation | ||
590 | */ | ||
559 | void | 591 | void |
560 | GAS_plugin_update_preferences (void *client, | 592 | GAS_plugin_preference_feedback (struct GNUNET_SERVER_Client *application, |
561 | const struct GNUNET_PeerIdentity *peer, | ||
562 | enum GNUNET_ATS_PreferenceKind kind, | ||
563 | float score_abs) | ||
564 | { | ||
565 | sf->s_bulk_start (sf->cls); | ||
566 | /* Tell normalization about change, normalization will call callback if preference changed */ | ||
567 | GAS_normalization_normalize_preference (client, peer, kind, score_abs); | ||
568 | sf->s_bulk_stop (sf->cls); | ||
569 | } | ||
570 | |||
571 | |||
572 | void | ||
573 | GAS_plugin_preference_feedback (void *application, | ||
574 | const struct GNUNET_PeerIdentity *peer, | 593 | const struct GNUNET_PeerIdentity *peer, |
575 | const struct GNUNET_TIME_Relative scope, | 594 | const struct GNUNET_TIME_Relative scope, |
576 | enum GNUNET_ATS_PreferenceKind kind, | 595 | enum GNUNET_ATS_PreferenceKind kind, |
577 | float score_abs) | 596 | float score_abs) |
578 | { | 597 | { |
579 | sf->s_feedback (sf->cls, | 598 | sf->s_feedback (sf->cls, |
580 | application, | 599 | application, |
581 | peer, | 600 | peer, |
582 | scope, | 601 | scope, |
583 | kind, | 602 | kind, |
584 | score_abs); | 603 | score_abs); |
585 | } | 604 | } |
586 | 605 | ||
587 | 606 | ||
607 | /** | ||
608 | * Stop instant solving, there are many state updates | ||
609 | * happening in bulk right now. | ||
610 | */ | ||
588 | void | 611 | void |
589 | GAS_plugin_solver_lock () | 612 | GAS_plugin_solver_lock () |
590 | { | 613 | { |
@@ -592,6 +615,9 @@ GAS_plugin_solver_lock () | |||
592 | } | 615 | } |
593 | 616 | ||
594 | 617 | ||
618 | /** | ||
619 | * Resume instant solving, we are done with the bulk state updates. | ||
620 | */ | ||
595 | void | 621 | void |
596 | GAS_plugin_solver_unlock () | 622 | GAS_plugin_solver_unlock () |
597 | { | 623 | { |
@@ -599,6 +625,12 @@ GAS_plugin_solver_unlock () | |||
599 | } | 625 | } |
600 | 626 | ||
601 | 627 | ||
628 | /** | ||
629 | * Notify the plugin that a request to connect to | ||
630 | * a particular peer was given to us. | ||
631 | * | ||
632 | * @param pid identity of peer we now care about | ||
633 | */ | ||
602 | void | 634 | void |
603 | GAS_plugin_request_connect_start (const struct GNUNET_PeerIdentity *pid) | 635 | GAS_plugin_request_connect_start (const struct GNUNET_PeerIdentity *pid) |
604 | { | 636 | { |
@@ -623,6 +655,12 @@ GAS_plugin_request_connect_start (const struct GNUNET_PeerIdentity *pid) | |||
623 | } | 655 | } |
624 | 656 | ||
625 | 657 | ||
658 | /** | ||
659 | * Notify the plugin that a request to connect to | ||
660 | * a particular peer was dropped. | ||
661 | * | ||
662 | * @param pid identity of peer we care now less about | ||
663 | */ | ||
626 | void | 664 | void |
627 | GAS_plugin_request_connect_stop (const struct GNUNET_PeerIdentity *pid) | 665 | GAS_plugin_request_connect_stop (const struct GNUNET_PeerIdentity *pid) |
628 | { | 666 | { |