diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-09-21 10:56:28 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-09-21 10:56:28 +0000 |
commit | d4afc6e37a14fe3257263c377a243c1a22ed9ee5 (patch) | |
tree | ccfce6d4f92808372d3e7ebfe9f5372e9f21f50c /src/ats/gnunet-service-ats_performance.c | |
parent | 60d02b5b0899f454cb65408bd2ed4c453fa75a3d (diff) | |
download | gnunet-d4afc6e37a14fe3257263c377a243c1a22ed9ee5.tar.gz gnunet-d4afc6e37a14fe3257263c377a243c1a22ed9ee5.zip |
migrating more services to new service API
Diffstat (limited to 'src/ats/gnunet-service-ats_performance.c')
-rw-r--r-- | src/ats/gnunet-service-ats_performance.c | 62 |
1 files changed, 26 insertions, 36 deletions
diff --git a/src/ats/gnunet-service-ats_performance.c b/src/ats/gnunet-service-ats_performance.c index 8702716f9..5252a71bc 100644 --- a/src/ats/gnunet-service-ats_performance.c +++ b/src/ats/gnunet-service-ats_performance.c | |||
@@ -36,12 +36,12 @@ | |||
36 | /** | 36 | /** |
37 | * Context for sending messages to performance clients without PIC. | 37 | * Context for sending messages to performance clients without PIC. |
38 | */ | 38 | */ |
39 | static struct GNUNET_SERVER_NotificationContext *nc_no_pic; | 39 | static struct GNUNET_NotificationContext *nc_no_pic; |
40 | 40 | ||
41 | /** | 41 | /** |
42 | * Context for sending messages to performance clients with PIC. | 42 | * Context for sending messages to performance clients with PIC. |
43 | */ | 43 | */ |
44 | static struct GNUNET_SERVER_NotificationContext *nc_pic; | 44 | static struct GNUNET_NotificationContext *nc_pic; |
45 | 45 | ||
46 | 46 | ||
47 | /** | 47 | /** |
@@ -63,7 +63,7 @@ static struct GNUNET_SERVER_NotificationContext *nc_pic; | |||
63 | * @param bandwidth_in assigned inbound bandwidth | 63 | * @param bandwidth_in assigned inbound bandwidth |
64 | */ | 64 | */ |
65 | static void | 65 | static void |
66 | notify_client (struct GNUNET_SERVER_Client *client, | 66 | notify_client (struct GNUNET_SERVICE_Client *client, |
67 | const struct GNUNET_PeerIdentity *peer, | 67 | const struct GNUNET_PeerIdentity *peer, |
68 | const char *plugin_name, | 68 | const char *plugin_name, |
69 | const void *plugin_addr, | 69 | const void *plugin_addr, |
@@ -81,8 +81,6 @@ notify_client (struct GNUNET_SERVER_Client *client, | |||
81 | plugin_addr_len + | 81 | plugin_addr_len + |
82 | plugin_name_length; | 82 | plugin_name_length; |
83 | char buf[msize] GNUNET_ALIGN; | 83 | char buf[msize] GNUNET_ALIGN; |
84 | struct GNUNET_SERVER_NotificationContext **uc; | ||
85 | struct GNUNET_SERVER_NotificationContext *nc; | ||
86 | char *addrp; | 84 | char *addrp; |
87 | 85 | ||
88 | if (NULL != prop) | 86 | if (NULL != prop) |
@@ -111,24 +109,17 @@ notify_client (struct GNUNET_SERVER_Client *client, | |||
111 | strcpy (&addrp[plugin_addr_len], plugin_name); | 109 | strcpy (&addrp[plugin_addr_len], plugin_name); |
112 | if (NULL == client) | 110 | if (NULL == client) |
113 | { | 111 | { |
114 | GNUNET_SERVER_notification_context_broadcast (nc_pic, | 112 | GNUNET_notification_context_broadcast (nc_pic, |
115 | &msg->header, | 113 | &msg->header, |
116 | GNUNET_YES); | 114 | GNUNET_YES); |
117 | } | 115 | } |
118 | else | 116 | else |
119 | { | 117 | { |
120 | uc = GNUNET_SERVER_client_get_user_context (client, | 118 | struct GNUNET_MQ_Envelope *env; |
121 | struct GNUNET_SERVER_NotificationContext *); | 119 | |
122 | if (NULL == uc) | 120 | env = GNUNET_MQ_msg_copy (&msg->header); |
123 | { | 121 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), |
124 | GNUNET_break (0); | 122 | env); |
125 | return; | ||
126 | } | ||
127 | nc = *uc; | ||
128 | GNUNET_SERVER_notification_context_unicast (nc, | ||
129 | client, | ||
130 | &msg->header, | ||
131 | GNUNET_YES); | ||
132 | } | 123 | } |
133 | } | 124 | } |
134 | 125 | ||
@@ -183,7 +174,7 @@ GAS_performance_notify_all_clients (const struct GNUNET_PeerIdentity *peer, | |||
183 | /** | 174 | /** |
184 | * Iterator for called from #GAS_addresses_get_peer_info() | 175 | * Iterator for called from #GAS_addresses_get_peer_info() |
185 | * | 176 | * |
186 | * @param cls closure with the `struct GNUNET_SERVER_Client *` to inform. | 177 | * @param cls closure with the `struct GNUNET_SERVICE_Client *` to inform. |
187 | * @param id the peer id | 178 | * @param id the peer id |
188 | * @param plugin_name plugin name | 179 | * @param plugin_name plugin name |
189 | * @param plugin_addr address | 180 | * @param plugin_addr address |
@@ -206,7 +197,7 @@ peerinfo_it (void *cls, | |||
206 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, | 197 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, |
207 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in) | 198 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in) |
208 | { | 199 | { |
209 | struct GNUNET_SERVER_Client *client = cls; | 200 | struct GNUNET_SERVICE_Client *client = cls; |
210 | 201 | ||
211 | if (NULL == id) | 202 | if (NULL == id) |
212 | return; | 203 | return; |
@@ -237,25 +228,24 @@ peerinfo_it (void *cls, | |||
237 | * @param flag flag specifying the type of the client | 228 | * @param flag flag specifying the type of the client |
238 | */ | 229 | */ |
239 | void | 230 | void |
240 | GAS_performance_add_client (struct GNUNET_SERVER_Client *client, | 231 | GAS_performance_add_client (struct GNUNET_SERVICE_Client *client, |
241 | enum StartFlag flag) | 232 | enum StartFlag flag) |
242 | { | 233 | { |
234 | struct GNUNET_MQ_Handle *mq; | ||
235 | |||
236 | mq = GNUNET_SERVICE_client_get_mq (client); | ||
243 | if (START_FLAG_PERFORMANCE_WITH_PIC == flag) | 237 | if (START_FLAG_PERFORMANCE_WITH_PIC == flag) |
244 | { | 238 | { |
245 | GNUNET_SERVER_notification_context_add (nc_pic, | 239 | GNUNET_notification_context_add (nc_pic, |
246 | client); | 240 | mq); |
247 | GNUNET_SERVER_client_set_user_context (client, | ||
248 | &nc_pic); | ||
249 | GAS_addresses_get_peer_info (NULL, | 241 | GAS_addresses_get_peer_info (NULL, |
250 | &peerinfo_it, | 242 | &peerinfo_it, |
251 | client); | 243 | client); |
252 | } | 244 | } |
253 | else | 245 | else |
254 | { | 246 | { |
255 | GNUNET_SERVER_notification_context_add (nc_no_pic, | 247 | GNUNET_notification_context_add (nc_no_pic, |
256 | client); | 248 | mq); |
257 | GNUNET_SERVER_client_set_user_context (client, | ||
258 | &nc_no_pic); | ||
259 | } | 249 | } |
260 | } | 250 | } |
261 | 251 | ||
@@ -266,10 +256,10 @@ GAS_performance_add_client (struct GNUNET_SERVER_Client *client, | |||
266 | * @param server handle to our server | 256 | * @param server handle to our server |
267 | */ | 257 | */ |
268 | void | 258 | void |
269 | GAS_performance_init (struct GNUNET_SERVER_Handle *server) | 259 | GAS_performance_init () |
270 | { | 260 | { |
271 | nc_no_pic = GNUNET_SERVER_notification_context_create (server, 32); | 261 | nc_no_pic = GNUNET_notification_context_create (32); |
272 | nc_pic = GNUNET_SERVER_notification_context_create (server, 32); | 262 | nc_pic = GNUNET_notification_context_create (32); |
273 | } | 263 | } |
274 | 264 | ||
275 | 265 | ||
@@ -279,9 +269,9 @@ GAS_performance_init (struct GNUNET_SERVER_Handle *server) | |||
279 | void | 269 | void |
280 | GAS_performance_done () | 270 | GAS_performance_done () |
281 | { | 271 | { |
282 | GNUNET_SERVER_notification_context_destroy (nc_no_pic); | 272 | GNUNET_notification_context_destroy (nc_no_pic); |
283 | nc_no_pic = NULL; | 273 | nc_no_pic = NULL; |
284 | GNUNET_SERVER_notification_context_destroy (nc_pic); | 274 | GNUNET_notification_context_destroy (nc_pic); |
285 | nc_pic = NULL; | 275 | nc_pic = NULL; |
286 | } | 276 | } |
287 | 277 | ||