diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-02-07 12:46:37 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-02-07 12:46:37 +0000 |
commit | 6e54571bd00f7ea045dabcd5fc9fc3080665f5fc (patch) | |
tree | e8e204155e5fd9fc8bf6e7620331a9fc484ce78a | |
parent | 577ad3b798f0cd62c2e9ab92fdc58cfe75a3fcdc (diff) | |
download | gnunet-6e54571bd00f7ea045dabcd5fc9fc3080665f5fc.tar.gz gnunet-6e54571bd00f7ea045dabcd5fc9fc3080665f5fc.zip |
simplify logic
-rw-r--r-- | src/ats/Makefile.am | 1 | ||||
-rw-r--r-- | src/ats/gnunet-ats-solver-eval.c | 15 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_addresses.c | 7 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_normalization.c | 5 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_plugins.c | 21 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_plugins.h | 14 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_preferences.c | 264 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_preferences.h | 14 |
8 files changed, 130 insertions, 211 deletions
diff --git a/src/ats/Makefile.am b/src/ats/Makefile.am index fcd71d37d..501fec4d7 100644 --- a/src/ats/Makefile.am +++ b/src/ats/Makefile.am | |||
@@ -48,7 +48,6 @@ gnunet_ats_solver_eval_SOURCES = \ | |||
48 | gnunet-service-ats_connectivity.c gnunet-service-ats_connectivity.h \ | 48 | gnunet-service-ats_connectivity.c gnunet-service-ats_connectivity.h \ |
49 | gnunet-service-ats_feedback.c gnunet-service-ats_feedback.h \ | 49 | gnunet-service-ats_feedback.c gnunet-service-ats_feedback.h \ |
50 | gnunet-service-ats_performance.c gnunet-service-ats_performance.h \ | 50 | gnunet-service-ats_performance.c gnunet-service-ats_performance.h \ |
51 | gnunet-service-ats_preferences.c gnunet-service-ats_preferences.h \ | ||
52 | gnunet-service-ats_reservations.c gnunet-service-ats_reservations.h \ | 51 | gnunet-service-ats_reservations.c gnunet-service-ats_reservations.h \ |
53 | gnunet-service-ats_scheduling.c gnunet-service-ats_scheduling.h \ | 52 | gnunet-service-ats_scheduling.c gnunet-service-ats_scheduling.h \ |
54 | gnunet-service-ats_normalization.c | 53 | gnunet-service-ats_normalization.c |
diff --git a/src/ats/gnunet-ats-solver-eval.c b/src/ats/gnunet-ats-solver-eval.c index c39bb30f7..99771d0e8 100644 --- a/src/ats/gnunet-ats-solver-eval.c +++ b/src/ats/gnunet-ats-solver-eval.c | |||
@@ -27,7 +27,7 @@ | |||
27 | #include "gnunet_util_lib.h" | 27 | #include "gnunet_util_lib.h" |
28 | #include "gnunet-ats-solver-eval.h" | 28 | #include "gnunet-ats-solver-eval.h" |
29 | #include "gnunet-service-ats_normalization.h" | 29 | #include "gnunet-service-ats_normalization.h" |
30 | #include "gnunet-service-ats_preferences.h" | 30 | #include "gnunet-service-ats_preferences.c" |
31 | 31 | ||
32 | #define BIG_M_STRING "unlimited" | 32 | #define BIG_M_STRING "unlimited" |
33 | 33 | ||
@@ -980,7 +980,6 @@ set_pref_task (void *cls, | |||
980 | pg->peer, NULL + (pg->client_id), | 980 | pg->peer, NULL + (pg->client_id), |
981 | GNUNET_ATS_print_preference_type (pg->kind), pref_value); | 981 | GNUNET_ATS_print_preference_type (pg->kind), pref_value); |
982 | 982 | ||
983 | sh->sf->s_bulk_start (sh->sf->cls); | ||
984 | if (GNUNET_YES == opt_disable_normalization) | 983 | if (GNUNET_YES == opt_disable_normalization) |
985 | { | 984 | { |
986 | p->pref_abs[pg->kind] = pref_value; | 985 | p->pref_abs[pg->kind] = pref_value; |
@@ -988,15 +987,17 @@ set_pref_task (void *cls, | |||
988 | sh->sf->s_pref (sh->sf->cls, &p->peer_id, pg->kind, pref_value); | 987 | sh->sf->s_pref (sh->sf->cls, &p->peer_id, pg->kind, pref_value); |
989 | } | 988 | } |
990 | else | 989 | else |
991 | GAS_normalization_normalize_preference (NULL + (pg->client_id), | 990 | normalize_preference (NULL + (pg->client_id), |
992 | &p->peer_id, pg->kind, pref_value); | 991 | &p->peer_id, |
993 | sh->sf->s_bulk_stop (sh->sf->cls); | 992 | pg->kind, |
993 | pref_value); | ||
994 | 994 | ||
995 | pg->set_task = GNUNET_SCHEDULER_add_delayed (pg->frequency, | 995 | pg->set_task = GNUNET_SCHEDULER_add_delayed (pg->frequency, |
996 | set_pref_task, pg); | 996 | &set_pref_task, |
997 | 997 | pg); | |
998 | } | 998 | } |
999 | 999 | ||
1000 | |||
1000 | static struct PreferenceGenerator * | 1001 | static struct PreferenceGenerator * |
1001 | find_pref_gen (unsigned int peer, enum GNUNET_ATS_PreferenceKind kind) | 1002 | find_pref_gen (unsigned int peer, enum GNUNET_ATS_PreferenceKind kind) |
1002 | { | 1003 | { |
diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c index 0c896e489..78bde6ec2 100644 --- a/src/ats/gnunet-service-ats_addresses.c +++ b/src/ats/gnunet-service-ats_addresses.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "gnunet-service-ats_addresses.h" | 28 | #include "gnunet-service-ats_addresses.h" |
29 | #include "gnunet-service-ats_performance.h" | 29 | #include "gnunet-service-ats_performance.h" |
30 | #include "gnunet-service-ats_normalization.h" | ||
30 | #include "gnunet-service-ats_plugins.h" | 31 | #include "gnunet-service-ats_plugins.h" |
31 | 32 | ||
32 | 33 | ||
@@ -644,9 +645,9 @@ GAS_addresses_update (const struct GNUNET_PeerIdentity *peer, | |||
644 | GNUNET_BANDWIDTH_value_init (aa->assigned_bw_out), | 645 | GNUNET_BANDWIDTH_value_init (aa->assigned_bw_out), |
645 | GNUNET_BANDWIDTH_value_init (aa->assigned_bw_in)); | 646 | GNUNET_BANDWIDTH_value_init (aa->assigned_bw_in)); |
646 | 647 | ||
647 | GAS_plugin_update_address (aa, | 648 | GAS_normalization_normalize_property (aa, |
648 | atsi, | 649 | atsi, |
649 | atsi_count); | 650 | atsi_count); |
650 | } | 651 | } |
651 | GNUNET_free_non_null (atsi_delta); | 652 | GNUNET_free_non_null (atsi_delta); |
652 | } | 653 | } |
diff --git a/src/ats/gnunet-service-ats_normalization.c b/src/ats/gnunet-service-ats_normalization.c index 244813108..8eaedc92d 100644 --- a/src/ats/gnunet-service-ats_normalization.c +++ b/src/ats/gnunet-service-ats_normalization.c | |||
@@ -24,7 +24,7 @@ | |||
24 | * @author Matthias Wachs | 24 | * @author Matthias Wachs |
25 | * @author Christian Grothoff | 25 | * @author Christian Grothoff |
26 | * | 26 | * |
27 | * FIXME: rename to 'properties'!? | 27 | * FIXME: rename to 'properties'!? merge with addresses!? |
28 | */ | 28 | */ |
29 | #include "platform.h" | 29 | #include "platform.h" |
30 | #include "gnunet_ats_service.h" | 30 | #include "gnunet_ats_service.h" |
@@ -360,7 +360,7 @@ GAS_normalization_normalize_property (struct ATS_Address *address, | |||
360 | "Updating %u elements for peer `%s'\n", | 360 | "Updating %u elements for peer `%s'\n", |
361 | atsi_count, | 361 | atsi_count, |
362 | GNUNET_i2s (&address->peer)); | 362 | GNUNET_i2s (&address->peer)); |
363 | 363 | GAS_plugin_solver_lock (); | |
364 | for (c1 = 0; c1 < atsi_count; c1++) | 364 | for (c1 = 0; c1 < atsi_count; c1++) |
365 | { | 365 | { |
366 | current_type = ntohl (atsi[c1].type); | 366 | current_type = ntohl (atsi[c1].type); |
@@ -391,6 +391,7 @@ GAS_normalization_normalize_property (struct ATS_Address *address, | |||
391 | address, | 391 | address, |
392 | current_val); | 392 | current_val); |
393 | } | 393 | } |
394 | GAS_plugin_solver_unlock (); | ||
394 | } | 395 | } |
395 | 396 | ||
396 | 397 | ||
diff --git a/src/ats/gnunet-service-ats_plugins.c b/src/ats/gnunet-service-ats_plugins.c index c388e7f67..8cc6af46f 100644 --- a/src/ats/gnunet-service-ats_plugins.c +++ b/src/ats/gnunet-service-ats_plugins.c | |||
@@ -545,27 +545,6 @@ GAS_plugin_new_address (struct ATS_Address *new_address, | |||
545 | 545 | ||
546 | 546 | ||
547 | /** | 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 | */ | ||
555 | void | ||
556 | GAS_plugin_update_address (struct ATS_Address *address, | ||
557 | const struct GNUNET_ATS_Information *atsi, | ||
558 | uint32_t atsi_count) | ||
559 | { | ||
560 | sf->s_bulk_start (sf->cls); | ||
561 | GAS_normalization_normalize_property (address, | ||
562 | atsi, | ||
563 | atsi_count); | ||
564 | sf->s_bulk_stop (sf->cls); | ||
565 | } | ||
566 | |||
567 | |||
568 | /** | ||
569 | * Tell the solver that the given address is no longer valid | 548 | * Tell the solver that the given address is no longer valid |
570 | * can cannot be used any longer. | 549 | * can cannot be used any longer. |
571 | * | 550 | * |
diff --git a/src/ats/gnunet-service-ats_plugins.h b/src/ats/gnunet-service-ats_plugins.h index 7e093d940..46a1d29fb 100644 --- a/src/ats/gnunet-service-ats_plugins.h +++ b/src/ats/gnunet-service-ats_plugins.h | |||
@@ -125,20 +125,6 @@ GAS_plugin_new_address (struct ATS_Address *new_address, | |||
125 | 125 | ||
126 | 126 | ||
127 | /** | 127 | /** |
128 | * Tell the solver that updated performance data was | ||
129 | * observed for the given address. | ||
130 | * | ||
131 | * @param new_address the new address | ||
132 | * @param atsi updated performance data for the address | ||
133 | * @param atsi_count size of the @a atsi array | ||
134 | */ | ||
135 | void | ||
136 | GAS_plugin_update_address (struct ATS_Address *address, | ||
137 | const struct GNUNET_ATS_Information *atsi, | ||
138 | uint32_t atsi_count); | ||
139 | |||
140 | |||
141 | /** | ||
142 | * Tell the solver that the given address is no longer valid | 128 | * Tell the solver that the given address is no longer valid |
143 | * can cannot be used any longer. | 129 | * can cannot be used any longer. |
144 | * | 130 | * |
diff --git a/src/ats/gnunet-service-ats_preferences.c b/src/ats/gnunet-service-ats_preferences.c index c9559ba89..297db7d7e 100644 --- a/src/ats/gnunet-service-ats_preferences.c +++ b/src/ats/gnunet-service-ats_preferences.c | |||
@@ -446,35 +446,122 @@ update_abs_preference (struct PreferenceClient *c, | |||
446 | 446 | ||
447 | 447 | ||
448 | /** | 448 | /** |
449 | * Change the preference for a peer | 449 | * Normalize an updated preference value |
450 | * | 450 | * |
451 | * @param client the client sending this request | 451 | * @param client the client with this preference |
452 | * @param peer the peer id | 452 | * @param peer the peer to change the preference for |
453 | * @param kind the preference kind to change | 453 | * @param kind the kind to change the preference |
454 | * @param score_abs the new preference score | 454 | * @param score_abs the normalized score |
455 | */ | 455 | */ |
456 | static void | 456 | static void |
457 | preference_change (struct GNUNET_SERVER_Client *client, | 457 | normalize_preference (struct GNUNET_SERVER_Client *client, |
458 | const struct GNUNET_PeerIdentity *peer, | 458 | const struct GNUNET_PeerIdentity *peer, |
459 | enum GNUNET_ATS_PreferenceKind kind, | 459 | enum GNUNET_ATS_PreferenceKind kind, |
460 | float score_abs) | 460 | float score_abs) |
461 | { | 461 | { |
462 | if (GNUNET_NO == | 462 | struct PreferenceClient *c_cur; |
463 | GNUNET_CONTAINER_multipeermap_contains (GSA_addresses, | 463 | struct PreferencePeer *p_cur; |
464 | peer)) | 464 | struct PeerRelative *r_cur; |
465 | double old_value; | ||
466 | int i; | ||
467 | |||
468 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
469 | "Client changes preference for peer `%s' for `%s' to %.2f\n", | ||
470 | GNUNET_i2s (peer), | ||
471 | GNUNET_ATS_print_preference_type (kind), | ||
472 | score_abs); | ||
473 | |||
474 | if (kind >= GNUNET_ATS_PreferenceCount) | ||
465 | { | 475 | { |
466 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 476 | GNUNET_break(0); |
467 | "Received CHANGE_PREFERENCE for unknown peer `%s'\n", | ||
468 | GNUNET_i2s (peer)); | ||
469 | return; | 477 | return; |
470 | } | 478 | } |
471 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 479 | |
472 | "Received CHANGE_PREFERENCE for peer `%s'\n", | 480 | /* Find preference client */ |
473 | GNUNET_i2s (peer)); | 481 | for (c_cur = pc_head; NULL != c_cur; c_cur = c_cur->next) |
474 | GAS_normalization_normalize_preference (client, | 482 | if (client == c_cur->client) |
475 | peer, | 483 | break; |
476 | kind, | 484 | /* Not found: create new preference client */ |
477 | score_abs); | 485 | if (NULL == c_cur) |
486 | { | ||
487 | c_cur = GNUNET_new (struct PreferenceClient); | ||
488 | c_cur->client = client; | ||
489 | for (i = 0; i < GNUNET_ATS_PreferenceCount; i++) | ||
490 | { | ||
491 | c_cur->f_abs_sum[i] = DEFAULT_ABS_PREFERENCE; | ||
492 | c_cur->f_rel_sum[i] = DEFAULT_REL_PREFERENCE; | ||
493 | } | ||
494 | GNUNET_CONTAINER_DLL_insert (pc_head, | ||
495 | pc_tail, | ||
496 | c_cur); | ||
497 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
498 | "Adding new client %p\n", | ||
499 | c_cur); | ||
500 | } | ||
501 | |||
502 | /* Find entry for peer */ | ||
503 | for (p_cur = c_cur->p_head; NULL != p_cur; p_cur = p_cur->next) | ||
504 | if (0 == memcmp (&p_cur->id, | ||
505 | peer, | ||
506 | sizeof (p_cur->id))) | ||
507 | break; | ||
508 | |||
509 | /* Not found: create new peer entry */ | ||
510 | if (NULL == p_cur) | ||
511 | { | ||
512 | p_cur = GNUNET_new (struct PreferencePeer); | ||
513 | p_cur->client = c_cur; | ||
514 | p_cur->id = *peer; | ||
515 | for (i = 0; i < GNUNET_ATS_PreferenceCount; i++) | ||
516 | { | ||
517 | /* Default value per peer absolute preference for a preference: 0 */ | ||
518 | p_cur->f_abs[i] = DEFAULT_ABS_PREFERENCE; | ||
519 | /* Default value per peer relative preference for a quality: 1.0 */ | ||
520 | p_cur->f_rel[i] = DEFAULT_REL_PREFERENCE; | ||
521 | p_cur->next_aging[i] = GNUNET_TIME_UNIT_FOREVER_ABS; | ||
522 | } | ||
523 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
524 | "Adding new peer %p for client %p\n", | ||
525 | p_cur, | ||
526 | c_cur); | ||
527 | GNUNET_CONTAINER_DLL_insert (c_cur->p_head, | ||
528 | c_cur->p_tail, | ||
529 | p_cur); | ||
530 | } | ||
531 | |||
532 | /* Create struct for peer */ | ||
533 | if (NULL == | ||
534 | GNUNET_CONTAINER_multipeermap_get (preference_peers, | ||
535 | peer)) | ||
536 | { | ||
537 | r_cur = GNUNET_new (struct PeerRelative); | ||
538 | r_cur->id = *peer; | ||
539 | for (i = 0; i < GNUNET_ATS_PreferenceCount; i++) | ||
540 | r_cur->f_rel[i] = DEFAULT_REL_PREFERENCE; | ||
541 | GNUNET_assert(GNUNET_OK == | ||
542 | GNUNET_CONTAINER_multipeermap_put (preference_peers, | ||
543 | &r_cur->id, | ||
544 | r_cur, | ||
545 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | ||
546 | } | ||
547 | |||
548 | /* Update absolute value */ | ||
549 | old_value = p_cur->f_abs[kind]; | ||
550 | update_abs_preference (c_cur, p_cur, kind, score_abs); | ||
551 | if (p_cur->f_abs[kind] == old_value) | ||
552 | return; | ||
553 | |||
554 | GAS_plugin_solver_lock (); | ||
555 | run_preference_update (c_cur, | ||
556 | p_cur, | ||
557 | kind, | ||
558 | score_abs); | ||
559 | GAS_plugin_solver_unlock (); | ||
560 | |||
561 | if (NULL == aging_task) | ||
562 | aging_task = GNUNET_SCHEDULER_add_delayed (PREF_AGING_INTERVAL, | ||
563 | &preference_aging, | ||
564 | NULL); | ||
478 | } | 565 | } |
479 | 566 | ||
480 | 567 | ||
@@ -497,8 +584,7 @@ GAS_handle_preference_change (void *cls, | |||
497 | uint32_t i; | 584 | uint32_t i; |
498 | 585 | ||
499 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 586 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
500 | "Received `%s' message\n", | 587 | "Received PREFERENCE_CHANGE message\n"); |
501 | "PREFERENCE_CHANGE"); | ||
502 | msize = ntohs (message->size); | 588 | msize = ntohs (message->size); |
503 | if (msize < sizeof (struct ChangePreferenceMessage)) | 589 | if (msize < sizeof (struct ChangePreferenceMessage)) |
504 | { | 590 | { |
@@ -521,11 +607,11 @@ GAS_handle_preference_change (void *cls, | |||
521 | 1, GNUNET_NO); | 607 | 1, GNUNET_NO); |
522 | pi = (const struct PreferenceInformation *) &msg[1]; | 608 | pi = (const struct PreferenceInformation *) &msg[1]; |
523 | for (i = 0; i < nump; i++) | 609 | for (i = 0; i < nump; i++) |
524 | preference_change (client, | 610 | normalize_preference (client, |
525 | &msg->peer, | 611 | &msg->peer, |
526 | (enum GNUNET_ATS_PreferenceKind) | 612 | (enum GNUNET_ATS_PreferenceKind) |
527 | ntohl (pi[i].preference_kind), | 613 | ntohl (pi[i].preference_kind), |
528 | pi[i].preference_value); | 614 | pi[i].preference_value); |
529 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 615 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
530 | } | 616 | } |
531 | 617 | ||
@@ -619,126 +705,6 @@ GAS_preference_done () | |||
619 | 705 | ||
620 | 706 | ||
621 | /** | 707 | /** |
622 | * Normalize an updated preference value | ||
623 | * | ||
624 | * @param client the client with this preference | ||
625 | * @param peer the peer to change the preference for | ||
626 | * @param kind the kind to change the preference | ||
627 | * @param score_abs the normalized score | ||
628 | */ | ||
629 | void | ||
630 | GAS_normalization_normalize_preference (struct GNUNET_SERVER_Client *client, | ||
631 | const struct GNUNET_PeerIdentity *peer, | ||
632 | enum GNUNET_ATS_PreferenceKind kind, | ||
633 | float score_abs) | ||
634 | { | ||
635 | struct PreferenceClient *c_cur; | ||
636 | struct PreferencePeer *p_cur; | ||
637 | struct PeerRelative *r_cur; | ||
638 | double old_value; | ||
639 | int i; | ||
640 | |||
641 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
642 | "Client changes preference for peer `%s' for `%s' to %.2f\n", | ||
643 | GNUNET_i2s (peer), | ||
644 | GNUNET_ATS_print_preference_type (kind), | ||
645 | score_abs); | ||
646 | |||
647 | if (kind >= GNUNET_ATS_PreferenceCount) | ||
648 | { | ||
649 | GNUNET_break(0); | ||
650 | return; | ||
651 | } | ||
652 | |||
653 | /* Find preference client */ | ||
654 | for (c_cur = pc_head; NULL != c_cur; c_cur = c_cur->next) | ||
655 | if (client == c_cur->client) | ||
656 | break; | ||
657 | /* Not found: create new preference client */ | ||
658 | if (NULL == c_cur) | ||
659 | { | ||
660 | c_cur = GNUNET_new (struct PreferenceClient); | ||
661 | c_cur->client = client; | ||
662 | for (i = 0; i < GNUNET_ATS_PreferenceCount; i++) | ||
663 | { | ||
664 | c_cur->f_abs_sum[i] = DEFAULT_ABS_PREFERENCE; | ||
665 | c_cur->f_rel_sum[i] = DEFAULT_REL_PREFERENCE; | ||
666 | } | ||
667 | GNUNET_CONTAINER_DLL_insert (pc_head, | ||
668 | pc_tail, | ||
669 | c_cur); | ||
670 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
671 | "Adding new client %p\n", | ||
672 | c_cur); | ||
673 | } | ||
674 | |||
675 | /* Find entry for peer */ | ||
676 | for (p_cur = c_cur->p_head; NULL != p_cur; p_cur = p_cur->next) | ||
677 | if (0 == memcmp (&p_cur->id, | ||
678 | peer, | ||
679 | sizeof (p_cur->id))) | ||
680 | break; | ||
681 | |||
682 | /* Not found: create new peer entry */ | ||
683 | if (NULL == p_cur) | ||
684 | { | ||
685 | p_cur = GNUNET_new (struct PreferencePeer); | ||
686 | p_cur->client = c_cur; | ||
687 | p_cur->id = *peer; | ||
688 | for (i = 0; i < GNUNET_ATS_PreferenceCount; i++) | ||
689 | { | ||
690 | /* Default value per peer absolute preference for a preference: 0 */ | ||
691 | p_cur->f_abs[i] = DEFAULT_ABS_PREFERENCE; | ||
692 | /* Default value per peer relative preference for a quality: 1.0 */ | ||
693 | p_cur->f_rel[i] = DEFAULT_REL_PREFERENCE; | ||
694 | p_cur->next_aging[i] = GNUNET_TIME_UNIT_FOREVER_ABS; | ||
695 | } | ||
696 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
697 | "Adding new peer %p for client %p\n", | ||
698 | p_cur, | ||
699 | c_cur); | ||
700 | GNUNET_CONTAINER_DLL_insert (c_cur->p_head, | ||
701 | c_cur->p_tail, | ||
702 | p_cur); | ||
703 | } | ||
704 | |||
705 | /* Create struct for peer */ | ||
706 | if (NULL == | ||
707 | GNUNET_CONTAINER_multipeermap_get (preference_peers, | ||
708 | peer)) | ||
709 | { | ||
710 | r_cur = GNUNET_new (struct PeerRelative); | ||
711 | r_cur->id = *peer; | ||
712 | for (i = 0; i < GNUNET_ATS_PreferenceCount; i++) | ||
713 | r_cur->f_rel[i] = DEFAULT_REL_PREFERENCE; | ||
714 | GNUNET_assert(GNUNET_OK == | ||
715 | GNUNET_CONTAINER_multipeermap_put (preference_peers, | ||
716 | &r_cur->id, | ||
717 | r_cur, | ||
718 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | ||
719 | } | ||
720 | |||
721 | /* Update absolute value */ | ||
722 | old_value = p_cur->f_abs[kind]; | ||
723 | update_abs_preference (c_cur, p_cur, kind, score_abs); | ||
724 | if (p_cur->f_abs[kind] == old_value) | ||
725 | return; | ||
726 | |||
727 | GAS_plugin_solver_lock (); | ||
728 | run_preference_update (c_cur, | ||
729 | p_cur, | ||
730 | kind, | ||
731 | score_abs); | ||
732 | GAS_plugin_solver_unlock (); | ||
733 | |||
734 | if (NULL == aging_task) | ||
735 | aging_task = GNUNET_SCHEDULER_add_delayed (PREF_AGING_INTERVAL, | ||
736 | &preference_aging, | ||
737 | NULL); | ||
738 | } | ||
739 | |||
740 | |||
741 | /** | ||
742 | * Get the normalized preference values for a specific peer or | 708 | * Get the normalized preference values for a specific peer or |
743 | * the default values if | 709 | * the default values if |
744 | * | 710 | * |
diff --git a/src/ats/gnunet-service-ats_preferences.h b/src/ats/gnunet-service-ats_preferences.h index 1715288d7..fb52ecb62 100644 --- a/src/ats/gnunet-service-ats_preferences.h +++ b/src/ats/gnunet-service-ats_preferences.h | |||
@@ -66,20 +66,6 @@ GAS_preference_done (void); | |||
66 | 66 | ||
67 | 67 | ||
68 | /** | 68 | /** |
69 | * Normalize an updated preference value | ||
70 | * | ||
71 | * @param client the client with this preference | ||
72 | * @param peer the peer to change the preference for | ||
73 | * @param kind the kind to change the preference | ||
74 | * @param score_abs the normalized score | ||
75 | */ | ||
76 | void | ||
77 | GAS_normalization_normalize_preference (struct GNUNET_SERVER_Client *client, | ||
78 | const struct GNUNET_PeerIdentity *peer, | ||
79 | enum GNUNET_ATS_PreferenceKind kind, | ||
80 | float score_abs); | ||
81 | |||
82 | /** | ||
83 | * Get the normalized preference values for a specific peer. | 69 | * Get the normalized preference values for a specific peer. |
84 | * | 70 | * |
85 | * @param cls ignored | 71 | * @param cls ignored |