diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-10-14 08:13:38 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-10-14 08:13:38 +0000 |
commit | 530b88b4942a070b1ab2ee43f9d1e084497dd769 (patch) | |
tree | b9d2ebbb5b67cf7deddaf14543c36bc8be306627 | |
parent | e047b52bb409063e65abdcfcf108007fac42c95e (diff) | |
download | gnunet-530b88b4942a070b1ab2ee43f9d1e084497dd769.tar.gz gnunet-530b88b4942a070b1ab2ee43f9d1e084497dd769.zip |
stuff
-rw-r--r-- | src/ats/gnunet-service-ats_performance.c | 75 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_performance.h | 27 |
2 files changed, 96 insertions, 6 deletions
diff --git a/src/ats/gnunet-service-ats_performance.c b/src/ats/gnunet-service-ats_performance.c index a0062ab7a..f68b1b8ae 100644 --- a/src/ats/gnunet-service-ats_performance.c +++ b/src/ats/gnunet-service-ats_performance.c | |||
@@ -29,12 +29,27 @@ | |||
29 | #include "ats.h" | 29 | #include "ats.h" |
30 | 30 | ||
31 | 31 | ||
32 | /** | ||
33 | * We keep clients that are interested in performance notifications in a linked list. | ||
34 | * Note that not ALL clients that are handeled by this module also register for | ||
35 | * notifications. Only those clients that are in this list are managed by the | ||
36 | * notification context. | ||
37 | */ | ||
32 | struct PerformanceClient | 38 | struct PerformanceClient |
33 | { | 39 | { |
40 | /** | ||
41 | * Next in doubly-linked list. | ||
42 | */ | ||
34 | struct PerformanceClient * next; | 43 | struct PerformanceClient * next; |
35 | 44 | ||
45 | /** | ||
46 | * Previous in doubly-linked list. | ||
47 | */ | ||
36 | struct PerformanceClient * prev; | 48 | struct PerformanceClient * prev; |
37 | 49 | ||
50 | /** | ||
51 | * Actual handle to the client. | ||
52 | */ | ||
38 | struct GNUNET_SERVER_Client *client; | 53 | struct GNUNET_SERVER_Client *client; |
39 | 54 | ||
40 | }; | 55 | }; |
@@ -50,7 +65,18 @@ static struct PerformanceClient *pc_head; | |||
50 | */ | 65 | */ |
51 | static struct PerformanceClient *pc_tail; | 66 | static struct PerformanceClient *pc_tail; |
52 | 67 | ||
68 | /** | ||
69 | * Context for sending messages to performance clients. | ||
70 | */ | ||
71 | static struct GNUNET_SERVER_NotificationContext *nc; | ||
72 | |||
53 | 73 | ||
74 | /** | ||
75 | * Find the performance client associated with the given handle. | ||
76 | * | ||
77 | * @param client server handle | ||
78 | * @return internal handle | ||
79 | */ | ||
54 | static struct PerformanceClient * | 80 | static struct PerformanceClient * |
55 | find_client (struct GNUNET_SERVER_Client *client) | 81 | find_client (struct GNUNET_SERVER_Client *client) |
56 | { | 82 | { |
@@ -63,6 +89,11 @@ find_client (struct GNUNET_SERVER_Client *client) | |||
63 | } | 89 | } |
64 | 90 | ||
65 | 91 | ||
92 | /** | ||
93 | * Register a new performance client. | ||
94 | * | ||
95 | * @param client handle of the new client | ||
96 | */ | ||
66 | void | 97 | void |
67 | GAS_performance_add_client (struct GNUNET_SERVER_Client *client) | 98 | GAS_performance_add_client (struct GNUNET_SERVER_Client *client) |
68 | { | 99 | { |
@@ -71,10 +102,18 @@ GAS_performance_add_client (struct GNUNET_SERVER_Client *client) | |||
71 | GNUNET_break (NULL == find_client (client)); | 102 | GNUNET_break (NULL == find_client (client)); |
72 | pc = GNUNET_malloc (sizeof (struct PerformanceClient)); | 103 | pc = GNUNET_malloc (sizeof (struct PerformanceClient)); |
73 | pc->client = client; | 104 | pc->client = client; |
105 | GNUNET_SERVER_notification_context_add (nc, client); | ||
106 | GNUNET_SERVER_client_keep (client); | ||
74 | GNUNET_CONTAINER_DLL_insert(pc_head, pc_tail, pc); | 107 | GNUNET_CONTAINER_DLL_insert(pc_head, pc_tail, pc); |
75 | } | 108 | } |
76 | 109 | ||
77 | 110 | ||
111 | /** | ||
112 | * Unregister a client (which may have been a performance client, | ||
113 | * but this is not assured). | ||
114 | * | ||
115 | * @param client handle of the (now dead) client | ||
116 | */ | ||
78 | void | 117 | void |
79 | GAS_performance_remove_client (struct GNUNET_SERVER_Client *client) | 118 | GAS_performance_remove_client (struct GNUNET_SERVER_Client *client) |
80 | { | 119 | { |
@@ -91,22 +130,46 @@ GAS_performance_remove_client (struct GNUNET_SERVER_Client *client) | |||
91 | 130 | ||
92 | void | 131 | void |
93 | GAS_handle_reservation_request (void *cls, struct GNUNET_SERVER_Client *client, | 132 | GAS_handle_reservation_request (void *cls, struct GNUNET_SERVER_Client *client, |
94 | const struct GNUNET_MessageHeader *message) | 133 | const struct GNUNET_MessageHeader *message) |
95 | |||
96 | { | 134 | { |
97 | // struct AddressUpdateMessage * msg = (struct AddressUpdateMessage *) message; | 135 | // const struct ReservationRequestMessage * msg = (const struct ReservationRequestMessage *) message; |
98 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "RESERVATION_REQUEST"); | 136 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "RESERVATION_REQUEST"); |
137 | |||
99 | } | 138 | } |
100 | 139 | ||
101 | 140 | ||
102 | void | 141 | void |
103 | GAS_handle_preference_change (void *cls, struct GNUNET_SERVER_Client *client, | 142 | GAS_handle_preference_change (void *cls, struct GNUNET_SERVER_Client *client, |
104 | const struct GNUNET_MessageHeader *message) | 143 | const struct GNUNET_MessageHeader *message) |
105 | 144 | ||
106 | { | 145 | { |
107 | // struct ChangePreferenceMessage * msg = (struct ChangePreferenceMessage *) message; | 146 | // const struct ChangePreferenceMessage * msg = (const struct ChangePreferenceMessage *) message; |
108 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "PREFERENCE_CHANGE"); | 147 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "PREFERENCE_CHANGE"); |
148 | // FIXME: implement later (we can safely ignore these for now) | ||
149 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | ||
109 | } | 150 | } |
110 | 151 | ||
111 | 152 | ||
153 | /** | ||
154 | * Initialize performance subsystem. | ||
155 | * | ||
156 | * @param server handle to our server | ||
157 | */ | ||
158 | void | ||
159 | GAS_performance_init (struct GNUNET_SERVER_Handle *server) | ||
160 | { | ||
161 | nc = GNUNET_SERVER_notification_context_create (server, 128); | ||
162 | } | ||
163 | |||
164 | |||
165 | /** | ||
166 | * Shutdown performance subsystem. | ||
167 | */ | ||
168 | void | ||
169 | GAS_performance_done () | ||
170 | { | ||
171 | GNUNET_SERVER_notification_context_destroy (nc); | ||
172 | nc = NULL; | ||
173 | } | ||
174 | |||
112 | /* end of gnunet-service-ats_performance.c */ | 175 | /* end of gnunet-service-ats_performance.c */ |
diff --git a/src/ats/gnunet-service-ats_performance.h b/src/ats/gnunet-service-ats_performance.h index cb6677f5b..e3a5aa394 100644 --- a/src/ats/gnunet-service-ats_performance.h +++ b/src/ats/gnunet-service-ats_performance.h | |||
@@ -29,10 +29,21 @@ | |||
29 | 29 | ||
30 | #include "gnunet_util_lib.h" | 30 | #include "gnunet_util_lib.h" |
31 | 31 | ||
32 | /** | ||
33 | * Register a new performance client. | ||
34 | * | ||
35 | * @param client handle of the new client | ||
36 | */ | ||
32 | void | 37 | void |
33 | GAS_performance_add_client (struct GNUNET_SERVER_Client *client); | 38 | GAS_performance_add_client (struct GNUNET_SERVER_Client *client); |
34 | 39 | ||
35 | 40 | ||
41 | /** | ||
42 | * Unregister a client (which may have been a performance client, | ||
43 | * but this is not assured). | ||
44 | * | ||
45 | * @param client handle of the (now dead) client | ||
46 | */ | ||
36 | void | 47 | void |
37 | GAS_performance_remove_client (struct GNUNET_SERVER_Client *client); | 48 | GAS_performance_remove_client (struct GNUNET_SERVER_Client *client); |
38 | 49 | ||
@@ -47,5 +58,21 @@ GAS_handle_preference_change (void *cls, struct GNUNET_SERVER_Client *client, | |||
47 | const struct GNUNET_MessageHeader *message); | 58 | const struct GNUNET_MessageHeader *message); |
48 | 59 | ||
49 | 60 | ||
61 | /** | ||
62 | * Initialize performance subsystem. | ||
63 | * | ||
64 | * @param server handle to our server | ||
65 | */ | ||
66 | void | ||
67 | GAS_performance_init (struct GNUNET_SERVER_Handle *server); | ||
68 | |||
69 | |||
70 | /** | ||
71 | * Shutdown performance subsystem. | ||
72 | */ | ||
73 | void | ||
74 | GAS_performance_done (void); | ||
75 | |||
76 | |||
50 | #endif | 77 | #endif |
51 | /* end of gnunet-service-ats_performance.h */ | 78 | /* end of gnunet-service-ats_performance.h */ |