diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-02-06 09:00:14 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-02-06 09:00:14 +0000 |
commit | 170d5baeece2def099112c6a25287a95d2b28899 (patch) | |
tree | 5950b36e6c5fa5fe6b90c8c3efc68dcce50d931d /src/ats/gnunet-service-ats_performance.c | |
parent | d9c8e8f14e77670c657ae42030ff3581ad060968 (diff) | |
download | gnunet-170d5baeece2def099112c6a25287a95d2b28899.tar.gz gnunet-170d5baeece2def099112c6a25287a95d2b28899.zip |
-use only one nc per client
Diffstat (limited to 'src/ats/gnunet-service-ats_performance.c')
-rw-r--r-- | src/ats/gnunet-service-ats_performance.c | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/src/ats/gnunet-service-ats_performance.c b/src/ats/gnunet-service-ats_performance.c index 9237b0711..e87cf3f6d 100644 --- a/src/ats/gnunet-service-ats_performance.c +++ b/src/ats/gnunet-service-ats_performance.c | |||
@@ -33,7 +33,7 @@ | |||
33 | /** | 33 | /** |
34 | * Context for sending messages to performance clients without PIC. | 34 | * Context for sending messages to performance clients without PIC. |
35 | */ | 35 | */ |
36 | static struct GNUNET_SERVER_NotificationContext *nc; | 36 | static struct GNUNET_SERVER_NotificationContext *nc_no_pic; |
37 | 37 | ||
38 | /** | 38 | /** |
39 | * Context for sending messages to performance clients with PIC. | 39 | * Context for sending messages to performance clients with PIC. |
@@ -79,6 +79,7 @@ notify_client (struct GNUNET_SERVER_Client *client, | |||
79 | plugin_name_length; | 79 | plugin_name_length; |
80 | char buf[msize] GNUNET_ALIGN; | 80 | char buf[msize] GNUNET_ALIGN; |
81 | struct GNUNET_ATS_Information *atsp; | 81 | struct GNUNET_ATS_Information *atsp; |
82 | struct GNUNET_SERVER_NotificationContext *nc; | ||
82 | char *addrp; | 83 | char *addrp; |
83 | 84 | ||
84 | GNUNET_assert (msize < GNUNET_SERVER_MAX_MESSAGE_SIZE); | 85 | GNUNET_assert (msize < GNUNET_SERVER_MAX_MESSAGE_SIZE); |
@@ -109,6 +110,13 @@ notify_client (struct GNUNET_SERVER_Client *client, | |||
109 | } | 110 | } |
110 | else | 111 | else |
111 | { | 112 | { |
113 | nc = *GNUNET_SERVER_client_get_user_context (client, | ||
114 | struct GNUNET_SERVER_NotificationContext *); | ||
115 | if (NULL == nc) | ||
116 | { | ||
117 | GNUNET_break (0); | ||
118 | return; | ||
119 | } | ||
112 | GNUNET_SERVER_notification_context_unicast (nc, | 120 | GNUNET_SERVER_notification_context_unicast (nc, |
113 | client, | 121 | client, |
114 | &msg->header, | 122 | &msg->header, |
@@ -223,15 +231,19 @@ GAS_performance_add_client (struct GNUNET_SERVER_Client *client, | |||
223 | { | 231 | { |
224 | GNUNET_SERVER_notification_context_add (nc_pic, | 232 | GNUNET_SERVER_notification_context_add (nc_pic, |
225 | client); | 233 | client); |
226 | GNUNET_SERVER_notification_context_add (nc, | 234 | GNUNET_SERVER_client_set_user_context (client, |
227 | client); | 235 | &nc_pic); |
236 | GAS_addresses_get_peer_info (NULL, | ||
237 | &peerinfo_it, | ||
238 | client); | ||
228 | } | 239 | } |
229 | else | 240 | else |
230 | GNUNET_SERVER_notification_context_add (nc, | 241 | { |
242 | GNUNET_SERVER_notification_context_add (nc_no_pic, | ||
231 | client); | 243 | client); |
232 | GAS_addresses_get_peer_info (NULL, | 244 | GNUNET_SERVER_client_set_user_context (client, |
233 | &peerinfo_it, | 245 | &nc_no_pic); |
234 | client); | 246 | } |
235 | } | 247 | } |
236 | 248 | ||
237 | 249 | ||
@@ -243,7 +255,7 @@ GAS_performance_add_client (struct GNUNET_SERVER_Client *client, | |||
243 | void | 255 | void |
244 | GAS_performance_init (struct GNUNET_SERVER_Handle *server) | 256 | GAS_performance_init (struct GNUNET_SERVER_Handle *server) |
245 | { | 257 | { |
246 | nc = GNUNET_SERVER_notification_context_create (server, 32); | 258 | nc_no_pic = GNUNET_SERVER_notification_context_create (server, 32); |
247 | nc_pic = GNUNET_SERVER_notification_context_create (server, 32); | 259 | nc_pic = GNUNET_SERVER_notification_context_create (server, 32); |
248 | } | 260 | } |
249 | 261 | ||
@@ -254,8 +266,8 @@ GAS_performance_init (struct GNUNET_SERVER_Handle *server) | |||
254 | void | 266 | void |
255 | GAS_performance_done () | 267 | GAS_performance_done () |
256 | { | 268 | { |
257 | GNUNET_SERVER_notification_context_destroy (nc); | 269 | GNUNET_SERVER_notification_context_destroy (nc_no_pic); |
258 | nc = NULL; | 270 | nc_no_pic = NULL; |
259 | GNUNET_SERVER_notification_context_destroy (nc_pic); | 271 | GNUNET_SERVER_notification_context_destroy (nc_pic); |
260 | nc_pic = NULL; | 272 | nc_pic = NULL; |
261 | } | 273 | } |