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_preferences.c | |
parent | c20f6b6366bcfd93ca613b5771dd0dae4b5ccca3 (diff) | |
download | gnunet-577ad3b798f0cd62c2e9ab92fdc58cfe75a3fcdc.tar.gz gnunet-577ad3b798f0cd62c2e9ab92fdc58cfe75a3fcdc.zip |
simplify logic
Diffstat (limited to 'src/ats/gnunet-service-ats_preferences.c')
-rw-r--r-- | src/ats/gnunet-service-ats_preferences.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/ats/gnunet-service-ats_preferences.c b/src/ats/gnunet-service-ats_preferences.c index cbb1eba08..c9559ba89 100644 --- a/src/ats/gnunet-service-ats_preferences.c +++ b/src/ats/gnunet-service-ats_preferences.c | |||
@@ -435,7 +435,7 @@ update_abs_preference (struct PreferenceClient *c, | |||
435 | p->f_abs[kind] = score; | 435 | p->f_abs[kind] = score; |
436 | /* p->f_abs[kind] = (p->f_abs[kind] + score) / 2; */ | 436 | /* p->f_abs[kind] = (p->f_abs[kind] + score) / 2; */ |
437 | p->next_aging[kind] = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), | 437 | p->next_aging[kind] = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), |
438 | PREF_AGING_INTERVAL); | 438 | PREF_AGING_INTERVAL); |
439 | break; | 439 | break; |
440 | case GNUNET_ATS_PREFERENCE_END: | 440 | case GNUNET_ATS_PREFERENCE_END: |
441 | break; | 441 | break; |
@@ -471,10 +471,10 @@ preference_change (struct GNUNET_SERVER_Client *client, | |||
471 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 471 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
472 | "Received CHANGE_PREFERENCE for peer `%s'\n", | 472 | "Received CHANGE_PREFERENCE for peer `%s'\n", |
473 | GNUNET_i2s (peer)); | 473 | GNUNET_i2s (peer)); |
474 | GAS_plugin_update_preferences (client, | 474 | GAS_normalization_normalize_preference (client, |
475 | peer, | 475 | peer, |
476 | kind, | 476 | kind, |
477 | score_abs); | 477 | score_abs); |
478 | } | 478 | } |
479 | 479 | ||
480 | 480 | ||
@@ -664,7 +664,6 @@ GAS_normalization_normalize_preference (struct GNUNET_SERVER_Client *client, | |||
664 | c_cur->f_abs_sum[i] = DEFAULT_ABS_PREFERENCE; | 664 | c_cur->f_abs_sum[i] = DEFAULT_ABS_PREFERENCE; |
665 | c_cur->f_rel_sum[i] = DEFAULT_REL_PREFERENCE; | 665 | c_cur->f_rel_sum[i] = DEFAULT_REL_PREFERENCE; |
666 | } | 666 | } |
667 | |||
668 | GNUNET_CONTAINER_DLL_insert (pc_head, | 667 | GNUNET_CONTAINER_DLL_insert (pc_head, |
669 | pc_tail, | 668 | pc_tail, |
670 | c_cur); | 669 | c_cur); |
@@ -685,7 +684,7 @@ GAS_normalization_normalize_preference (struct GNUNET_SERVER_Client *client, | |||
685 | { | 684 | { |
686 | p_cur = GNUNET_new (struct PreferencePeer); | 685 | p_cur = GNUNET_new (struct PreferencePeer); |
687 | p_cur->client = c_cur; | 686 | p_cur->client = c_cur; |
688 | p_cur->id = (*peer); | 687 | p_cur->id = *peer; |
689 | for (i = 0; i < GNUNET_ATS_PreferenceCount; i++) | 688 | for (i = 0; i < GNUNET_ATS_PreferenceCount; i++) |
690 | { | 689 | { |
691 | /* Default value per peer absolute preference for a preference: 0 */ | 690 | /* Default value per peer absolute preference for a preference: 0 */ |
@@ -725,10 +724,12 @@ GAS_normalization_normalize_preference (struct GNUNET_SERVER_Client *client, | |||
725 | if (p_cur->f_abs[kind] == old_value) | 724 | if (p_cur->f_abs[kind] == old_value) |
726 | return; | 725 | return; |
727 | 726 | ||
727 | GAS_plugin_solver_lock (); | ||
728 | run_preference_update (c_cur, | 728 | run_preference_update (c_cur, |
729 | p_cur, | 729 | p_cur, |
730 | kind, | 730 | kind, |
731 | score_abs); | 731 | score_abs); |
732 | GAS_plugin_solver_unlock (); | ||
732 | 733 | ||
733 | if (NULL == aging_task) | 734 | if (NULL == aging_task) |
734 | aging_task = GNUNET_SCHEDULER_add_delayed (PREF_AGING_INTERVAL, | 735 | aging_task = GNUNET_SCHEDULER_add_delayed (PREF_AGING_INTERVAL, |