diff options
-rw-r--r-- | src/ats/gnunet-service-ats.c | 1 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_preferences.c | 133 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_preferences.h | 12 |
3 files changed, 15 insertions, 131 deletions
diff --git a/src/ats/gnunet-service-ats.c b/src/ats/gnunet-service-ats.c index 98068bc25..87fa97bd5 100644 --- a/src/ats/gnunet-service-ats.c +++ b/src/ats/gnunet-service-ats.c | |||
@@ -112,7 +112,6 @@ client_disconnect_handler (void *cls, | |||
112 | GAS_scheduling_remove_client (client); | 112 | GAS_scheduling_remove_client (client); |
113 | GAS_connectivity_remove_client (client); | 113 | GAS_connectivity_remove_client (client); |
114 | GAS_normalization_preference_client_disconnect (client); | 114 | GAS_normalization_preference_client_disconnect (client); |
115 | GAS_preference_client_disconnect (client); | ||
116 | } | 115 | } |
117 | 116 | ||
118 | 117 | ||
diff --git a/src/ats/gnunet-service-ats_preferences.c b/src/ats/gnunet-service-ats_preferences.c index ea0210acb..41fb78140 100644 --- a/src/ats/gnunet-service-ats_preferences.c +++ b/src/ats/gnunet-service-ats_preferences.c | |||
@@ -19,7 +19,7 @@ | |||
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @file ats/gnunet-service-ats_preferences.c | 21 | * @file ats/gnunet-service-ats_preferences.c |
22 | * @brief ats service, interaction with 'performance' API | 22 | * @brief manage preferences expressed by clients |
23 | * @author Matthias Wachs | 23 | * @author Matthias Wachs |
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | */ | 25 | */ |
@@ -35,7 +35,9 @@ | |||
35 | #define LOG(kind,...) GNUNET_log_from (kind, "ats-preferencesx",__VA_ARGS__) | 35 | #define LOG(kind,...) GNUNET_log_from (kind, "ats-preferencesx",__VA_ARGS__) |
36 | 36 | ||
37 | #define PREF_AGING_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) | 37 | #define PREF_AGING_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) |
38 | |||
38 | #define PREF_AGING_FACTOR 0.95 | 39 | #define PREF_AGING_FACTOR 0.95 |
40 | |||
39 | #define PREF_EPSILON 0.01 | 41 | #define PREF_EPSILON 0.01 |
40 | 42 | ||
41 | 43 | ||
@@ -50,50 +52,13 @@ struct PeerRelative | |||
50 | double f_rel[GNUNET_ATS_PreferenceCount]; | 52 | double f_rel[GNUNET_ATS_PreferenceCount]; |
51 | 53 | ||
52 | /** | 54 | /** |
53 | * Peer id | 55 | * Peer identity for which we have these preferences. |
54 | */ | 56 | */ |
55 | struct GNUNET_PeerIdentity id; | 57 | struct GNUNET_PeerIdentity id; |
56 | }; | 58 | }; |
57 | 59 | ||
58 | 60 | ||
59 | /** | 61 | /** |
60 | * FIXME | ||
61 | */ | ||
62 | struct GAS_Addresses_Preference_Clients | ||
63 | { | ||
64 | /** | ||
65 | * Next in DLL | ||
66 | */ | ||
67 | struct GAS_Addresses_Preference_Clients *next; | ||
68 | |||
69 | /** | ||
70 | * Previous in DLL | ||
71 | */ | ||
72 | struct GAS_Addresses_Preference_Clients *prev; | ||
73 | |||
74 | /** | ||
75 | * Peer ID | ||
76 | */ | ||
77 | void *client; | ||
78 | }; | ||
79 | |||
80 | |||
81 | /** | ||
82 | * Preference requests DLL head | ||
83 | */ | ||
84 | static struct GAS_Addresses_Preference_Clients *preference_clients_head; | ||
85 | |||
86 | /** | ||
87 | * Preference requests DLL head | ||
88 | */ | ||
89 | static struct GAS_Addresses_Preference_Clients *preference_clients_tail; | ||
90 | |||
91 | /** | ||
92 | * Preferences clients | ||
93 | */ | ||
94 | static int pref_clients; | ||
95 | |||
96 | /** | ||
97 | * Default values | 62 | * Default values |
98 | */ | 63 | */ |
99 | static struct PeerRelative defvalues; | 64 | static struct PeerRelative defvalues; |
@@ -204,20 +169,6 @@ static struct PreferenceClient *pc_tail; | |||
204 | static struct GNUNET_SCHEDULER_Task * aging_task; | 169 | static struct GNUNET_SCHEDULER_Task * aging_task; |
205 | 170 | ||
206 | 171 | ||
207 | |||
208 | |||
209 | static struct GAS_Addresses_Preference_Clients * | ||
210 | find_preference_client (struct GNUNET_SERVER_Client *client) | ||
211 | { | ||
212 | struct GAS_Addresses_Preference_Clients *cur; | ||
213 | |||
214 | for (cur = preference_clients_head; NULL != cur; cur = cur->next) | ||
215 | if (cur->client == client) | ||
216 | return cur; | ||
217 | return NULL; | ||
218 | } | ||
219 | |||
220 | |||
221 | /** | 172 | /** |
222 | * Update a peer | 173 | * Update a peer |
223 | * | 174 | * |
@@ -479,34 +430,6 @@ update_abs_preference (struct PreferenceClient *c, | |||
479 | 430 | ||
480 | 431 | ||
481 | 432 | ||
482 | |||
483 | |||
484 | /** | ||
485 | * A performance client disconnected | ||
486 | * | ||
487 | * @param client the client | ||
488 | */ | ||
489 | void | ||
490 | GAS_preference_client_disconnect (struct GNUNET_SERVER_Client *client) | ||
491 | { | ||
492 | struct GAS_Addresses_Preference_Clients *pc; | ||
493 | |||
494 | if (NULL != (pc = find_preference_client (client))) | ||
495 | { | ||
496 | GNUNET_CONTAINER_DLL_remove (preference_clients_head, | ||
497 | preference_clients_tail, | ||
498 | pc); | ||
499 | GNUNET_free (pc); | ||
500 | GNUNET_assert (pref_clients > 0); | ||
501 | pref_clients --; | ||
502 | GNUNET_STATISTICS_set (GSA_stats, | ||
503 | "# active performance clients", | ||
504 | pref_clients, | ||
505 | GNUNET_NO); | ||
506 | } | ||
507 | } | ||
508 | |||
509 | |||
510 | /** | 433 | /** |
511 | * Change the preference for a peer | 434 | * Change the preference for a peer |
512 | * | 435 | * |
@@ -521,36 +444,22 @@ preference_change (struct GNUNET_SERVER_Client *client, | |||
521 | enum GNUNET_ATS_PreferenceKind kind, | 444 | enum GNUNET_ATS_PreferenceKind kind, |
522 | float score_abs) | 445 | float score_abs) |
523 | { | 446 | { |
524 | struct GAS_Addresses_Preference_Clients *pc; | ||
525 | |||
526 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
527 | "Received `%s' for peer `%s' for client %p\n", "CHANGE PREFERENCE", | ||
528 | GNUNET_i2s (peer), client); | ||
529 | |||
530 | if (GNUNET_NO == | 447 | if (GNUNET_NO == |
531 | GNUNET_CONTAINER_multipeermap_contains (GSA_addresses, | 448 | GNUNET_CONTAINER_multipeermap_contains (GSA_addresses, |
532 | peer)) | 449 | peer)) |
533 | { | 450 | { |
534 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 451 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
535 | "Received `%s' for unknown peer `%s' from client %p\n", | 452 | "Received CHANGE_PREFERENCE for unknown peer `%s'\n", |
536 | "CHANGE PREFERENCE", GNUNET_i2s (peer), client); | 453 | GNUNET_i2s (peer)); |
537 | return; | 454 | return; |
538 | } | 455 | } |
539 | 456 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | |
540 | if (NULL == find_preference_client (client)) | 457 | "Received CHANGE_PREFERENCE for peer `%s'\n", |
541 | { | 458 | GNUNET_i2s (peer)); |
542 | pc = GNUNET_new (struct GAS_Addresses_Preference_Clients); | 459 | GAS_plugin_update_preferences (client, |
543 | pc->client = client; | 460 | peer, |
544 | GNUNET_CONTAINER_DLL_insert (preference_clients_head, | 461 | kind, |
545 | preference_clients_tail, | 462 | score_abs); |
546 | pc); | ||
547 | pref_clients ++; | ||
548 | GNUNET_STATISTICS_set (GSA_stats, | ||
549 | "# active performance clients", | ||
550 | pref_clients, | ||
551 | GNUNET_NO); | ||
552 | } | ||
553 | GAS_plugin_update_preferences (client, peer, kind, score_abs); | ||
554 | } | 463 | } |
555 | 464 | ||
556 | 465 | ||
@@ -669,7 +578,6 @@ free_client (struct PreferenceClient *pc) | |||
669 | void | 578 | void |
670 | GAS_preference_done () | 579 | GAS_preference_done () |
671 | { | 580 | { |
672 | struct GAS_Addresses_Preference_Clients *pcur; | ||
673 | struct PreferenceClient *pc; | 581 | struct PreferenceClient *pc; |
674 | struct PreferenceClient *next_pc; | 582 | struct PreferenceClient *next_pc; |
675 | 583 | ||
@@ -690,19 +598,6 @@ GAS_preference_done () | |||
690 | NULL); | 598 | NULL); |
691 | GNUNET_CONTAINER_multipeermap_destroy (preference_peers); | 599 | GNUNET_CONTAINER_multipeermap_destroy (preference_peers); |
692 | 600 | ||
693 | while (NULL != (pcur = preference_clients_head)) | ||
694 | { | ||
695 | GNUNET_CONTAINER_DLL_remove (preference_clients_head, | ||
696 | preference_clients_tail, | ||
697 | pcur); | ||
698 | GNUNET_assert (pref_clients > 0); | ||
699 | pref_clients --; | ||
700 | GNUNET_STATISTICS_set (GSA_stats, | ||
701 | "# active performance clients", | ||
702 | pref_clients, | ||
703 | GNUNET_NO); | ||
704 | GNUNET_free (pcur); | ||
705 | } | ||
706 | } | 601 | } |
707 | 602 | ||
708 | 603 | ||
diff --git a/src/ats/gnunet-service-ats_preferences.h b/src/ats/gnunet-service-ats_preferences.h index e17a8bd22..9ed2b5f84 100644 --- a/src/ats/gnunet-service-ats_preferences.h +++ b/src/ats/gnunet-service-ats_preferences.h | |||
@@ -17,10 +17,9 @@ | |||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | |||
21 | /** | 20 | /** |
22 | * @file ats/gnunet-service-ats_preferences.h | 21 | * @file ats/gnunet-service-ats_preferences.h |
23 | * @brief FIXME | 22 | * @brief manage preferences expressed by clients |
24 | * @author Matthias Wachs | 23 | * @author Matthias Wachs |
25 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
26 | */ | 25 | */ |
@@ -40,15 +39,6 @@ | |||
40 | 39 | ||
41 | 40 | ||
42 | /** | 41 | /** |
43 | * A preference client disconnected. | ||
44 | * | ||
45 | * @param client the client | ||
46 | */ | ||
47 | void | ||
48 | GAS_preference_client_disconnect (struct GNUNET_SERVER_Client *client); | ||
49 | |||
50 | |||
51 | /** | ||
52 | * Get the normalized preference values for a specific peer. | 42 | * Get the normalized preference values for a specific peer. |
53 | * | 43 | * |
54 | * @param cls ignored | 44 | * @param cls ignored |