diff options
Diffstat (limited to 'src/ats/gnunet-service-ats.c')
-rw-r--r-- | src/ats/gnunet-service-ats.c | 466 |
1 files changed, 235 insertions, 231 deletions
diff --git a/src/ats/gnunet-service-ats.c b/src/ats/gnunet-service-ats.c index 2dc3edea6..d9bb71c2b 100644 --- a/src/ats/gnunet-service-ats.c +++ b/src/ats/gnunet-service-ats.c | |||
@@ -11,12 +11,12 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @file ats/gnunet-service-ats.c | 21 | * @file ats/gnunet-service-ats.c |
22 | * @brief ats service | 22 | * @brief ats service |
@@ -50,43 +50,47 @@ struct GNUNET_STATISTICS_Handle *GSA_stats; | |||
50 | * @param msg the start message | 50 | * @param msg the start message |
51 | */ | 51 | */ |
52 | static void | 52 | static void |
53 | handle_ats_start (void *cls, | 53 | handle_ats_start(void *cls, |
54 | const struct ClientStartMessage *msg) | 54 | const struct ClientStartMessage *msg) |
55 | { | 55 | { |
56 | struct GNUNET_SERVICE_Client *client = cls; | 56 | struct GNUNET_SERVICE_Client *client = cls; |
57 | enum StartFlag flag; | 57 | enum StartFlag flag; |
58 | 58 | ||
59 | flag = ntohl (msg->start_flag); | 59 | flag = ntohl(msg->start_flag); |
60 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 60 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
61 | "Received ATS_START (%d) message\n", | 61 | "Received ATS_START (%d) message\n", |
62 | (int) flag); | 62 | (int)flag); |
63 | switch (flag) | 63 | switch (flag) |
64 | { | ||
65 | case START_FLAG_SCHEDULING: | ||
66 | if (GNUNET_OK != | ||
67 | GAS_scheduling_add_client (client)) | ||
68 | { | 64 | { |
69 | GNUNET_SERVICE_client_drop (client); | 65 | case START_FLAG_SCHEDULING: |
66 | if (GNUNET_OK != | ||
67 | GAS_scheduling_add_client(client)) | ||
68 | { | ||
69 | GNUNET_SERVICE_client_drop(client); | ||
70 | return; | ||
71 | } | ||
72 | break; | ||
73 | |||
74 | case START_FLAG_PERFORMANCE_WITH_PIC: | ||
75 | GAS_performance_add_client(client, | ||
76 | flag); | ||
77 | break; | ||
78 | |||
79 | case START_FLAG_PERFORMANCE_NO_PIC: | ||
80 | GAS_performance_add_client(client, | ||
81 | flag); | ||
82 | break; | ||
83 | |||
84 | case START_FLAG_CONNECTION_SUGGESTION: | ||
85 | /* This client won't receive messages from us, no need to 'add' */ | ||
86 | break; | ||
87 | |||
88 | default: | ||
89 | GNUNET_break(0); | ||
90 | GNUNET_SERVICE_client_drop(client); | ||
70 | return; | 91 | return; |
71 | } | 92 | } |
72 | break; | 93 | GNUNET_SERVICE_client_continue(client); |
73 | case START_FLAG_PERFORMANCE_WITH_PIC: | ||
74 | GAS_performance_add_client (client, | ||
75 | flag); | ||
76 | break; | ||
77 | case START_FLAG_PERFORMANCE_NO_PIC: | ||
78 | GAS_performance_add_client (client, | ||
79 | flag); | ||
80 | break; | ||
81 | case START_FLAG_CONNECTION_SUGGESTION: | ||
82 | /* This client won't receive messages from us, no need to 'add' */ | ||
83 | break; | ||
84 | default: | ||
85 | GNUNET_break (0); | ||
86 | GNUNET_SERVICE_client_drop (client); | ||
87 | return; | ||
88 | } | ||
89 | GNUNET_SERVICE_client_continue (client); | ||
90 | } | 94 | } |
91 | 95 | ||
92 | 96 | ||
@@ -98,14 +102,14 @@ handle_ats_start (void *cls, | |||
98 | * @param message the request message | 102 | * @param message the request message |
99 | */ | 103 | */ |
100 | static void | 104 | static void |
101 | handle_reservation_request (void *cls, | 105 | handle_reservation_request(void *cls, |
102 | const struct ReservationRequestMessage *message) | 106 | const struct ReservationRequestMessage *message) |
103 | { | 107 | { |
104 | struct GNUNET_SERVICE_Client *client = cls; | 108 | struct GNUNET_SERVICE_Client *client = cls; |
105 | 109 | ||
106 | GAS_handle_reservation_request (client, | 110 | GAS_handle_reservation_request(client, |
107 | message); | 111 | message); |
108 | GNUNET_SERVICE_client_continue (client); | 112 | GNUNET_SERVICE_client_continue(client); |
109 | } | 113 | } |
110 | 114 | ||
111 | 115 | ||
@@ -117,23 +121,23 @@ handle_reservation_request (void *cls, | |||
117 | * @return #GNUNET_OK if @a message is well-formed | 121 | * @return #GNUNET_OK if @a message is well-formed |
118 | */ | 122 | */ |
119 | static int | 123 | static int |
120 | check_feedback (void *cls, | 124 | check_feedback(void *cls, |
121 | const struct FeedbackPreferenceMessage *message) | 125 | const struct FeedbackPreferenceMessage *message) |
122 | { | 126 | { |
123 | uint16_t msize; | 127 | uint16_t msize; |
124 | uint32_t nump; | 128 | uint32_t nump; |
125 | 129 | ||
126 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 130 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
127 | "Received PREFERENCE_FEEDBACK message\n"); | 131 | "Received PREFERENCE_FEEDBACK message\n"); |
128 | msize = ntohs (message->header.size); | 132 | msize = ntohs(message->header.size); |
129 | nump = ntohl (message->num_feedback); | 133 | nump = ntohl(message->num_feedback); |
130 | if (msize != | 134 | if (msize != |
131 | sizeof (struct FeedbackPreferenceMessage) + | 135 | sizeof(struct FeedbackPreferenceMessage) + |
132 | nump * sizeof (struct PreferenceInformation)) | 136 | nump * sizeof(struct PreferenceInformation)) |
133 | { | 137 | { |
134 | GNUNET_break (0); | 138 | GNUNET_break(0); |
135 | return GNUNET_SYSERR; | 139 | return GNUNET_SYSERR; |
136 | } | 140 | } |
137 | return GNUNET_OK; | 141 | return GNUNET_OK; |
138 | } | 142 | } |
139 | 143 | ||
@@ -145,42 +149,42 @@ check_feedback (void *cls, | |||
145 | * @param msg the request message | 149 | * @param msg the request message |
146 | */ | 150 | */ |
147 | static void | 151 | static void |
148 | handle_feedback (void *cls, | 152 | handle_feedback(void *cls, |
149 | const struct FeedbackPreferenceMessage *msg) | 153 | const struct FeedbackPreferenceMessage *msg) |
150 | { | 154 | { |
151 | struct GNUNET_SERVICE_Client *client = cls; | 155 | struct GNUNET_SERVICE_Client *client = cls; |
152 | const struct PreferenceInformation *pi; | 156 | const struct PreferenceInformation *pi; |
153 | uint32_t nump; | 157 | uint32_t nump; |
154 | 158 | ||
155 | nump = ntohl (msg->num_feedback); | 159 | nump = ntohl(msg->num_feedback); |
156 | if (GNUNET_NO == | 160 | if (GNUNET_NO == |
157 | GNUNET_CONTAINER_multipeermap_contains (GSA_addresses, | 161 | GNUNET_CONTAINER_multipeermap_contains(GSA_addresses, |
158 | &msg->peer)) | 162 | &msg->peer)) |
159 | { | 163 | { |
160 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, | 164 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, |
161 | "Received PREFERENCE FEEDBACK for unknown peer `%s'\n", | 165 | "Received PREFERENCE FEEDBACK for unknown peer `%s'\n", |
162 | GNUNET_i2s (&msg->peer)); | 166 | GNUNET_i2s(&msg->peer)); |
163 | GNUNET_SERVICE_client_continue (client); | 167 | GNUNET_SERVICE_client_continue(client); |
164 | return; | 168 | return; |
165 | } | 169 | } |
166 | 170 | ||
167 | GNUNET_STATISTICS_update (GSA_stats, | 171 | GNUNET_STATISTICS_update(GSA_stats, |
168 | "# preference feedbacks requests processed", | 172 | "# preference feedbacks requests processed", |
169 | 1, | 173 | 1, |
170 | GNUNET_NO); | 174 | GNUNET_NO); |
171 | pi = (const struct PreferenceInformation *) &msg[1]; | 175 | pi = (const struct PreferenceInformation *)&msg[1]; |
172 | for (uint32_t i = 0; i < nump; i++) | 176 | for (uint32_t i = 0; i < nump; i++) |
173 | { | 177 | { |
174 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 178 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
175 | "Received PREFERENCE FEEDBACK for peer `%s'\n", | 179 | "Received PREFERENCE FEEDBACK for peer `%s'\n", |
176 | GNUNET_i2s (&msg->peer)); | 180 | GNUNET_i2s(&msg->peer)); |
177 | GAS_plugin_notify_feedback (client, | 181 | GAS_plugin_notify_feedback(client, |
178 | &msg->peer, | 182 | &msg->peer, |
179 | GNUNET_TIME_relative_ntoh (msg->scope), | 183 | GNUNET_TIME_relative_ntoh(msg->scope), |
180 | (enum GNUNET_ATS_PreferenceKind) ntohl (pi[i].preference_kind), | 184 | (enum GNUNET_ATS_PreferenceKind)ntohl(pi[i].preference_kind), |
181 | pi[i].preference_value); | 185 | pi[i].preference_value); |
182 | } | 186 | } |
183 | GNUNET_SERVICE_client_continue (client); | 187 | GNUNET_SERVICE_client_continue(client); |
184 | } | 188 | } |
185 | 189 | ||
186 | 190 | ||
@@ -191,14 +195,14 @@ handle_feedback (void *cls, | |||
191 | * @param message the request message | 195 | * @param message the request message |
192 | */ | 196 | */ |
193 | static void | 197 | static void |
194 | handle_request_address_list (void *cls, | 198 | handle_request_address_list(void *cls, |
195 | const struct AddressListRequestMessage *message) | 199 | const struct AddressListRequestMessage *message) |
196 | { | 200 | { |
197 | struct GNUNET_SERVICE_Client *client = cls; | 201 | struct GNUNET_SERVICE_Client *client = cls; |
198 | 202 | ||
199 | GAS_handle_request_address_list (client, | 203 | GAS_handle_request_address_list(client, |
200 | message); | 204 | message); |
201 | GNUNET_SERVICE_client_continue (client); | 205 | GNUNET_SERVICE_client_continue(client); |
202 | } | 206 | } |
203 | 207 | ||
204 | 208 | ||
@@ -209,14 +213,14 @@ handle_request_address_list (void *cls, | |||
209 | * @param message the request message | 213 | * @param message the request message |
210 | */ | 214 | */ |
211 | static void | 215 | static void |
212 | handle_request_address (void *cls, | 216 | handle_request_address(void *cls, |
213 | const struct RequestAddressMessage * message) | 217 | const struct RequestAddressMessage * message) |
214 | { | 218 | { |
215 | struct GNUNET_SERVICE_Client *client = cls; | 219 | struct GNUNET_SERVICE_Client *client = cls; |
216 | 220 | ||
217 | GAS_handle_request_address (client, | 221 | GAS_handle_request_address(client, |
218 | message); | 222 | message); |
219 | GNUNET_SERVICE_client_continue (client); | 223 | GNUNET_SERVICE_client_continue(client); |
220 | } | 224 | } |
221 | 225 | ||
222 | 226 | ||
@@ -227,14 +231,14 @@ handle_request_address (void *cls, | |||
227 | * @param message the request message | 231 | * @param message the request message |
228 | */ | 232 | */ |
229 | static void | 233 | static void |
230 | handle_request_address_cancel (void *cls, | 234 | handle_request_address_cancel(void *cls, |
231 | const struct RequestAddressMessage *message) | 235 | const struct RequestAddressMessage *message) |
232 | { | 236 | { |
233 | struct GNUNET_SERVICE_Client *client = cls; | 237 | struct GNUNET_SERVICE_Client *client = cls; |
234 | 238 | ||
235 | GAS_handle_request_address_cancel (client, | 239 | GAS_handle_request_address_cancel(client, |
236 | message); | 240 | message); |
237 | GNUNET_SERVICE_client_continue (client); | 241 | GNUNET_SERVICE_client_continue(client); |
238 | } | 242 | } |
239 | 243 | ||
240 | 244 | ||
@@ -245,8 +249,8 @@ handle_request_address_cancel (void *cls, | |||
245 | * @param m the request message | 249 | * @param m the request message |
246 | */ | 250 | */ |
247 | static int | 251 | static int |
248 | check_address_add (void *cls, | 252 | check_address_add(void *cls, |
249 | const struct AddressAddMessage *m) | 253 | const struct AddressAddMessage *m) |
250 | { | 254 | { |
251 | const char *address; | 255 | const char *address; |
252 | const char *plugin_name; | 256 | const char *plugin_name; |
@@ -254,23 +258,23 @@ check_address_add (void *cls, | |||
254 | uint16_t plugin_name_length; | 258 | uint16_t plugin_name_length; |
255 | uint16_t size; | 259 | uint16_t size; |
256 | 260 | ||
257 | size = ntohs (m->header.size); | 261 | size = ntohs(m->header.size); |
258 | address_length = ntohs (m->address_length); | 262 | address_length = ntohs(m->address_length); |
259 | plugin_name_length = ntohs (m->plugin_name_length); | 263 | plugin_name_length = ntohs(m->plugin_name_length); |
260 | address = (const char *) &m[1]; | 264 | address = (const char *)&m[1]; |
261 | if (plugin_name_length != 0) | 265 | if (plugin_name_length != 0) |
262 | plugin_name = &address[address_length]; | 266 | plugin_name = &address[address_length]; |
263 | else | 267 | else |
264 | plugin_name = ""; | 268 | plugin_name = ""; |
265 | 269 | ||
266 | if ( (address_length + plugin_name_length + | 270 | if ((address_length + plugin_name_length + |
267 | sizeof (struct AddressAddMessage) != size) || | 271 | sizeof(struct AddressAddMessage) != size) || |
268 | ( (plugin_name_length > 0) && | 272 | ((plugin_name_length > 0) && |
269 | (plugin_name[plugin_name_length - 1] != '\0') ) ) | 273 | (plugin_name[plugin_name_length - 1] != '\0'))) |
270 | { | 274 | { |
271 | GNUNET_break (0); | 275 | GNUNET_break(0); |
272 | return GNUNET_SYSERR; | 276 | return GNUNET_SYSERR; |
273 | } | 277 | } |
274 | return GNUNET_OK; | 278 | return GNUNET_OK; |
275 | } | 279 | } |
276 | 280 | ||
@@ -282,13 +286,13 @@ check_address_add (void *cls, | |||
282 | * @param message the request message | 286 | * @param message the request message |
283 | */ | 287 | */ |
284 | static void | 288 | static void |
285 | handle_address_add (void *cls, | 289 | handle_address_add(void *cls, |
286 | const struct AddressAddMessage *message) | 290 | const struct AddressAddMessage *message) |
287 | { | 291 | { |
288 | struct GNUNET_SERVICE_Client *client = cls; | 292 | struct GNUNET_SERVICE_Client *client = cls; |
289 | 293 | ||
290 | GAS_handle_address_add (message); | 294 | GAS_handle_address_add(message); |
291 | GNUNET_SERVICE_client_continue (client); | 295 | GNUNET_SERVICE_client_continue(client); |
292 | } | 296 | } |
293 | 297 | ||
294 | 298 | ||
@@ -299,13 +303,13 @@ handle_address_add (void *cls, | |||
299 | * @param message the request message | 303 | * @param message the request message |
300 | */ | 304 | */ |
301 | static void | 305 | static void |
302 | handle_address_update (void *cls, | 306 | handle_address_update(void *cls, |
303 | const struct AddressUpdateMessage *message) | 307 | const struct AddressUpdateMessage *message) |
304 | { | 308 | { |
305 | struct GNUNET_SERVICE_Client *client = cls; | 309 | struct GNUNET_SERVICE_Client *client = cls; |
306 | 310 | ||
307 | GAS_handle_address_update (message); | 311 | GAS_handle_address_update(message); |
308 | GNUNET_SERVICE_client_continue (client); | 312 | GNUNET_SERVICE_client_continue(client); |
309 | } | 313 | } |
310 | 314 | ||
311 | 315 | ||
@@ -316,13 +320,13 @@ handle_address_update (void *cls, | |||
316 | * @param message the request message | 320 | * @param message the request message |
317 | */ | 321 | */ |
318 | static void | 322 | static void |
319 | handle_address_destroyed (void *cls, | 323 | handle_address_destroyed(void *cls, |
320 | const struct AddressDestroyedMessage *message) | 324 | const struct AddressDestroyedMessage *message) |
321 | { | 325 | { |
322 | struct GNUNET_SERVICE_Client *client = cls; | 326 | struct GNUNET_SERVICE_Client *client = cls; |
323 | 327 | ||
324 | GAS_handle_address_destroyed (message); | 328 | GAS_handle_address_destroyed(message); |
325 | GNUNET_SERVICE_client_continue (client); | 329 | GNUNET_SERVICE_client_continue(client); |
326 | } | 330 | } |
327 | 331 | ||
328 | 332 | ||
@@ -334,22 +338,22 @@ handle_address_destroyed (void *cls, | |||
334 | * @return #GNUNET_OK if @a message is well-formed | 338 | * @return #GNUNET_OK if @a message is well-formed |
335 | */ | 339 | */ |
336 | static int | 340 | static int |
337 | check_preference_change (void *cls, | 341 | check_preference_change(void *cls, |
338 | const struct ChangePreferenceMessage *message) | 342 | const struct ChangePreferenceMessage *message) |
339 | { | 343 | { |
340 | uint16_t msize; | 344 | uint16_t msize; |
341 | uint32_t nump; | 345 | uint32_t nump; |
342 | 346 | ||
343 | msize = ntohs (message->header.size); | 347 | msize = ntohs(message->header.size); |
344 | nump = ntohl (message->num_preferences); | 348 | nump = ntohl(message->num_preferences); |
345 | if ( (msize != | 349 | if ((msize != |
346 | sizeof (struct ChangePreferenceMessage) + | 350 | sizeof(struct ChangePreferenceMessage) + |
347 | nump * sizeof (struct PreferenceInformation)) || | 351 | nump * sizeof(struct PreferenceInformation)) || |
348 | (UINT16_MAX / sizeof (struct PreferenceInformation) < nump) ) | 352 | (UINT16_MAX / sizeof(struct PreferenceInformation) < nump)) |
349 | { | 353 | { |
350 | GNUNET_break (0); | 354 | GNUNET_break(0); |
351 | return GNUNET_SYSERR; | 355 | return GNUNET_SYSERR; |
352 | } | 356 | } |
353 | return GNUNET_OK; | 357 | return GNUNET_OK; |
354 | } | 358 | } |
355 | 359 | ||
@@ -361,14 +365,14 @@ check_preference_change (void *cls, | |||
361 | * @param message the request message | 365 | * @param message the request message |
362 | */ | 366 | */ |
363 | static void | 367 | static void |
364 | handle_preference_change (void *cls, | 368 | handle_preference_change(void *cls, |
365 | const struct ChangePreferenceMessage *message) | 369 | const struct ChangePreferenceMessage *message) |
366 | { | 370 | { |
367 | struct GNUNET_SERVICE_Client *client = cls; | 371 | struct GNUNET_SERVICE_Client *client = cls; |
368 | 372 | ||
369 | GAS_handle_preference_change (client, | 373 | GAS_handle_preference_change(client, |
370 | message); | 374 | message); |
371 | GNUNET_SERVICE_client_continue (client); | 375 | GNUNET_SERVICE_client_continue(client); |
372 | } | 376 | } |
373 | 377 | ||
374 | 378 | ||
@@ -382,9 +386,9 @@ handle_preference_change (void *cls, | |||
382 | * @return @a client | 386 | * @return @a client |
383 | */ | 387 | */ |
384 | static void * | 388 | static void * |
385 | client_connect_cb (void *cls, | 389 | client_connect_cb(void *cls, |
386 | struct GNUNET_SERVICE_Client *client, | 390 | struct GNUNET_SERVICE_Client *client, |
387 | struct GNUNET_MQ_Handle *mq) | 391 | struct GNUNET_MQ_Handle *mq) |
388 | { | 392 | { |
389 | return client; | 393 | return client; |
390 | } | 394 | } |
@@ -399,15 +403,15 @@ client_connect_cb (void *cls, | |||
399 | * @param app_ctx | 403 | * @param app_ctx |
400 | */ | 404 | */ |
401 | static void | 405 | static void |
402 | client_disconnect_cb (void *cls, | 406 | client_disconnect_cb(void *cls, |
403 | struct GNUNET_SERVICE_Client *client, | 407 | struct GNUNET_SERVICE_Client *client, |
404 | void *app_ctx) | 408 | void *app_ctx) |
405 | { | 409 | { |
406 | if (NULL == client) | 410 | if (NULL == client) |
407 | return; | 411 | return; |
408 | GAS_scheduling_remove_client (client); | 412 | GAS_scheduling_remove_client(client); |
409 | GAS_connectivity_remove_client (client); | 413 | GAS_connectivity_remove_client(client); |
410 | GAS_preference_client_disconnect (client); | 414 | GAS_preference_client_disconnect(client); |
411 | } | 415 | } |
412 | 416 | ||
413 | 417 | ||
@@ -417,22 +421,22 @@ client_disconnect_cb (void *cls, | |||
417 | * @param cls unused | 421 | * @param cls unused |
418 | */ | 422 | */ |
419 | static void | 423 | static void |
420 | cleanup_task (void *cls) | 424 | cleanup_task(void *cls) |
421 | { | 425 | { |
422 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 426 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
423 | "ATS shutdown initiated\n"); | 427 | "ATS shutdown initiated\n"); |
424 | GAS_connectivity_done (); | 428 | GAS_connectivity_done(); |
425 | GAS_addresses_done (); | 429 | GAS_addresses_done(); |
426 | GAS_plugin_done (); | 430 | GAS_plugin_done(); |
427 | GAS_normalization_stop (); | 431 | GAS_normalization_stop(); |
428 | GAS_performance_done (); | 432 | GAS_performance_done(); |
429 | GAS_preference_done (); | 433 | GAS_preference_done(); |
430 | GAS_reservations_done (); | 434 | GAS_reservations_done(); |
431 | if (NULL != GSA_stats) | 435 | if (NULL != GSA_stats) |
432 | { | 436 | { |
433 | GNUNET_STATISTICS_destroy (GSA_stats, GNUNET_NO); | 437 | GNUNET_STATISTICS_destroy(GSA_stats, GNUNET_NO); |
434 | GSA_stats = NULL; | 438 | GSA_stats = NULL; |
435 | } | 439 | } |
436 | } | 440 | } |
437 | 441 | ||
438 | 442 | ||
@@ -444,37 +448,37 @@ cleanup_task (void *cls) | |||
444 | * @param service the initialized service | 448 | * @param service the initialized service |
445 | */ | 449 | */ |
446 | static void | 450 | static void |
447 | run (void *cls, | 451 | run(void *cls, |
448 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 452 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
449 | struct GNUNET_SERVICE_Handle *service) | 453 | struct GNUNET_SERVICE_Handle *service) |
450 | { | 454 | { |
451 | GSA_stats = GNUNET_STATISTICS_create ("ats", | 455 | GSA_stats = GNUNET_STATISTICS_create("ats", |
452 | cfg); | 456 | cfg); |
453 | GAS_reservations_init (); | 457 | GAS_reservations_init(); |
454 | GAS_connectivity_init (); | 458 | GAS_connectivity_init(); |
455 | GAS_preference_init (); | 459 | GAS_preference_init(); |
456 | GAS_normalization_start (); | 460 | GAS_normalization_start(); |
457 | GAS_addresses_init (); | 461 | GAS_addresses_init(); |
458 | if (GNUNET_OK != | 462 | if (GNUNET_OK != |
459 | GAS_plugin_init (cfg)) | 463 | GAS_plugin_init(cfg)) |
460 | { | ||
461 | GNUNET_break (0); | ||
462 | GAS_addresses_done (); | ||
463 | GAS_normalization_stop (); | ||
464 | GAS_reservations_done (); | ||
465 | GAS_connectivity_done (); | ||
466 | GAS_preference_done (); | ||
467 | if (NULL != GSA_stats) | ||
468 | { | 464 | { |
469 | GNUNET_STATISTICS_destroy (GSA_stats, | 465 | GNUNET_break(0); |
470 | GNUNET_NO); | 466 | GAS_addresses_done(); |
471 | GSA_stats = NULL; | 467 | GAS_normalization_stop(); |
468 | GAS_reservations_done(); | ||
469 | GAS_connectivity_done(); | ||
470 | GAS_preference_done(); | ||
471 | if (NULL != GSA_stats) | ||
472 | { | ||
473 | GNUNET_STATISTICS_destroy(GSA_stats, | ||
474 | GNUNET_NO); | ||
475 | GSA_stats = NULL; | ||
476 | } | ||
477 | return; | ||
472 | } | 478 | } |
473 | return; | 479 | GAS_performance_init(); |
474 | } | 480 | GNUNET_SCHEDULER_add_shutdown(&cleanup_task, |
475 | GAS_performance_init (); | 481 | NULL); |
476 | GNUNET_SCHEDULER_add_shutdown (&cleanup_task, | ||
477 | NULL); | ||
478 | } | 482 | } |
479 | 483 | ||
480 | 484 | ||
@@ -482,53 +486,53 @@ run (void *cls, | |||
482 | * Define "main" method using service macro. | 486 | * Define "main" method using service macro. |
483 | */ | 487 | */ |
484 | GNUNET_SERVICE_MAIN | 488 | GNUNET_SERVICE_MAIN |
485 | ("ats", | 489 | ("ats", |
486 | GNUNET_SERVICE_OPTION_NONE, | 490 | GNUNET_SERVICE_OPTION_NONE, |
487 | &run, | 491 | &run, |
488 | &client_connect_cb, | 492 | &client_connect_cb, |
489 | &client_disconnect_cb, | 493 | &client_disconnect_cb, |
490 | NULL, | 494 | NULL, |
491 | GNUNET_MQ_hd_fixed_size (ats_start, | 495 | GNUNET_MQ_hd_fixed_size(ats_start, |
492 | GNUNET_MESSAGE_TYPE_ATS_START, | 496 | GNUNET_MESSAGE_TYPE_ATS_START, |
493 | struct ClientStartMessage, | 497 | struct ClientStartMessage, |
494 | NULL), | 498 | NULL), |
495 | GNUNET_MQ_hd_fixed_size (request_address, | 499 | GNUNET_MQ_hd_fixed_size(request_address, |
496 | GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS, | 500 | GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS, |
497 | struct RequestAddressMessage, | 501 | struct RequestAddressMessage, |
498 | NULL), | 502 | NULL), |
499 | GNUNET_MQ_hd_fixed_size (request_address_cancel, | 503 | GNUNET_MQ_hd_fixed_size(request_address_cancel, |
500 | GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS_CANCEL, | 504 | GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS_CANCEL, |
501 | struct RequestAddressMessage, | 505 | struct RequestAddressMessage, |
502 | NULL), | 506 | NULL), |
503 | GNUNET_MQ_hd_fixed_size (request_address_list, | 507 | GNUNET_MQ_hd_fixed_size(request_address_list, |
504 | GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_REQUEST, | 508 | GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_REQUEST, |
505 | struct AddressListRequestMessage, | 509 | struct AddressListRequestMessage, |
506 | NULL), | 510 | NULL), |
507 | GNUNET_MQ_hd_var_size (address_add, | 511 | GNUNET_MQ_hd_var_size(address_add, |
508 | GNUNET_MESSAGE_TYPE_ATS_ADDRESS_ADD, | 512 | GNUNET_MESSAGE_TYPE_ATS_ADDRESS_ADD, |
509 | struct AddressAddMessage, | 513 | struct AddressAddMessage, |
510 | NULL), | 514 | NULL), |
511 | GNUNET_MQ_hd_fixed_size (address_update, | 515 | GNUNET_MQ_hd_fixed_size(address_update, |
512 | GNUNET_MESSAGE_TYPE_ATS_ADDRESS_UPDATE, | 516 | GNUNET_MESSAGE_TYPE_ATS_ADDRESS_UPDATE, |
513 | struct AddressUpdateMessage, | 517 | struct AddressUpdateMessage, |
514 | NULL), | 518 | NULL), |
515 | GNUNET_MQ_hd_fixed_size (address_destroyed, | 519 | GNUNET_MQ_hd_fixed_size(address_destroyed, |
516 | GNUNET_MESSAGE_TYPE_ATS_ADDRESS_DESTROYED, | 520 | GNUNET_MESSAGE_TYPE_ATS_ADDRESS_DESTROYED, |
517 | struct AddressDestroyedMessage, | 521 | struct AddressDestroyedMessage, |
518 | NULL), | 522 | NULL), |
519 | GNUNET_MQ_hd_fixed_size (reservation_request, | 523 | GNUNET_MQ_hd_fixed_size(reservation_request, |
520 | GNUNET_MESSAGE_TYPE_ATS_RESERVATION_REQUEST, | 524 | GNUNET_MESSAGE_TYPE_ATS_RESERVATION_REQUEST, |
521 | struct ReservationRequestMessage, | 525 | struct ReservationRequestMessage, |
522 | NULL), | 526 | NULL), |
523 | GNUNET_MQ_hd_var_size (preference_change, | 527 | GNUNET_MQ_hd_var_size(preference_change, |
524 | GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_CHANGE, | 528 | GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_CHANGE, |
525 | struct ChangePreferenceMessage, | 529 | struct ChangePreferenceMessage, |
526 | NULL), | 530 | NULL), |
527 | GNUNET_MQ_hd_var_size (feedback, | 531 | GNUNET_MQ_hd_var_size(feedback, |
528 | GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_FEEDBACK, | 532 | GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_FEEDBACK, |
529 | struct FeedbackPreferenceMessage, | 533 | struct FeedbackPreferenceMessage, |
530 | NULL), | 534 | NULL), |
531 | GNUNET_MQ_handler_end ()); | 535 | GNUNET_MQ_handler_end()); |
532 | 536 | ||
533 | 537 | ||
534 | /* end of gnunet-service-ats.c */ | 538 | /* end of gnunet-service-ats.c */ |