diff options
Diffstat (limited to 'src/testbed/gnunet-service-testbed_barriers.c')
-rw-r--r-- | src/testbed/gnunet-service-testbed_barriers.c | 740 |
1 files changed, 369 insertions, 371 deletions
diff --git a/src/testbed/gnunet-service-testbed_barriers.c b/src/testbed/gnunet-service-testbed_barriers.c index dbcf5ed69..c2cb9a99c 100644 --- a/src/testbed/gnunet-service-testbed_barriers.c +++ b/src/testbed/gnunet-service-testbed_barriers.c | |||
@@ -1,22 +1,22 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2008--2016 GNUnet e.V. | 3 | Copyright (C) 2008--2016 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation, either version 3 of the License, | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | or (at your option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
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 | /** | 21 | /** |
22 | * @file testbed/gnunet-service-testbed_barriers.c | 22 | * @file testbed/gnunet-service-testbed_barriers.c |
@@ -33,7 +33,7 @@ | |||
33 | * timeout for outgoing message transmissions in seconds | 33 | * timeout for outgoing message transmissions in seconds |
34 | */ | 34 | */ |
35 | #define MESSAGE_SEND_TIMEOUT(s) \ | 35 | #define MESSAGE_SEND_TIMEOUT(s) \ |
36 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, s) | 36 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, s) |
37 | 37 | ||
38 | 38 | ||
39 | /** | 39 | /** |
@@ -50,8 +50,8 @@ | |||
50 | /** | 50 | /** |
51 | * Logging shorthand | 51 | * Logging shorthand |
52 | */ | 52 | */ |
53 | #define LOG(kind,...) \ | 53 | #define LOG(kind, ...) \ |
54 | GNUNET_log_from (kind, "testbed-barriers", __VA_ARGS__) | 54 | GNUNET_log_from(kind, "testbed-barriers", __VA_ARGS__) |
55 | 55 | ||
56 | 56 | ||
57 | /** | 57 | /** |
@@ -63,8 +63,7 @@ struct Barrier; | |||
63 | /** | 63 | /** |
64 | * Context to be associated with each client | 64 | * Context to be associated with each client |
65 | */ | 65 | */ |
66 | struct ClientCtx | 66 | struct ClientCtx { |
67 | { | ||
68 | /** | 67 | /** |
69 | * The barrier this client is waiting for | 68 | * The barrier this client is waiting for |
70 | */ | 69 | */ |
@@ -84,15 +83,13 @@ struct ClientCtx | |||
84 | * The client handle | 83 | * The client handle |
85 | */ | 84 | */ |
86 | struct GNUNET_SERVICE_Client *client; | 85 | struct GNUNET_SERVICE_Client *client; |
87 | |||
88 | }; | 86 | }; |
89 | 87 | ||
90 | 88 | ||
91 | /** | 89 | /** |
92 | * Wrapper around Barrier handle | 90 | * Wrapper around Barrier handle |
93 | */ | 91 | */ |
94 | struct WBarrier | 92 | struct WBarrier { |
95 | { | ||
96 | /** | 93 | /** |
97 | * DLL next pointer | 94 | * DLL next pointer |
98 | */ | 95 | */ |
@@ -128,8 +125,7 @@ struct WBarrier | |||
128 | /** | 125 | /** |
129 | * Barrier | 126 | * Barrier |
130 | */ | 127 | */ |
131 | struct Barrier | 128 | struct Barrier { |
132 | { | ||
133 | /** | 129 | /** |
134 | * The hashcode of the barrier name | 130 | * The hashcode of the barrier name |
135 | */ | 131 | */ |
@@ -204,7 +200,6 @@ struct Barrier | |||
204 | * Quorum percentage to be reached | 200 | * Quorum percentage to be reached |
205 | */ | 201 | */ |
206 | uint8_t quorum; | 202 | uint8_t quorum; |
207 | |||
208 | }; | 203 | }; |
209 | 204 | ||
210 | 205 | ||
@@ -226,23 +221,23 @@ static struct GNUNET_SERVICE_Handle *ctx; | |||
226 | * @param barrier the barrier handle | 221 | * @param barrier the barrier handle |
227 | */ | 222 | */ |
228 | static void | 223 | static void |
229 | remove_barrier (struct Barrier *barrier) | 224 | remove_barrier(struct Barrier *barrier) |
230 | { | 225 | { |
231 | struct ClientCtx *ctx; | 226 | struct ClientCtx *ctx; |
232 | 227 | ||
233 | GNUNET_assert (GNUNET_YES == | 228 | GNUNET_assert(GNUNET_YES == |
234 | GNUNET_CONTAINER_multihashmap_remove (barrier_map, | 229 | GNUNET_CONTAINER_multihashmap_remove(barrier_map, |
235 | &barrier->hash, | 230 | &barrier->hash, |
236 | barrier)); | 231 | barrier)); |
237 | while (NULL != (ctx = barrier->head)) | 232 | while (NULL != (ctx = barrier->head)) |
238 | { | 233 | { |
239 | GNUNET_CONTAINER_DLL_remove (barrier->head, | 234 | GNUNET_CONTAINER_DLL_remove(barrier->head, |
240 | barrier->tail, | 235 | barrier->tail, |
241 | ctx); | 236 | ctx); |
242 | ctx->barrier = NULL; | 237 | ctx->barrier = NULL; |
243 | } | 238 | } |
244 | GNUNET_free (barrier->name); | 239 | GNUNET_free(barrier->name); |
245 | GNUNET_free (barrier); | 240 | GNUNET_free(barrier); |
246 | } | 241 | } |
247 | 242 | ||
248 | 243 | ||
@@ -252,18 +247,18 @@ remove_barrier (struct Barrier *barrier) | |||
252 | * @param barrier the local barrier | 247 | * @param barrier the local barrier |
253 | */ | 248 | */ |
254 | static void | 249 | static void |
255 | cancel_wrappers (struct Barrier *barrier) | 250 | cancel_wrappers(struct Barrier *barrier) |
256 | { | 251 | { |
257 | struct WBarrier *wrapper; | 252 | struct WBarrier *wrapper; |
258 | 253 | ||
259 | while (NULL != (wrapper = barrier->whead)) | 254 | while (NULL != (wrapper = barrier->whead)) |
260 | { | 255 | { |
261 | GNUNET_TESTBED_barrier_cancel (wrapper->hbarrier); | 256 | GNUNET_TESTBED_barrier_cancel(wrapper->hbarrier); |
262 | GNUNET_CONTAINER_DLL_remove (barrier->whead, | 257 | GNUNET_CONTAINER_DLL_remove(barrier->whead, |
263 | barrier->wtail, | 258 | barrier->wtail, |
264 | wrapper); | 259 | wrapper); |
265 | GNUNET_free (wrapper); | 260 | GNUNET_free(wrapper); |
266 | } | 261 | } |
267 | } | 262 | } |
268 | 263 | ||
269 | 264 | ||
@@ -277,33 +272,33 @@ cancel_wrappers (struct Barrier *barrier) | |||
277 | * status=GNUNET_TESTBED_BARRIERSTATUS_ERROR | 272 | * status=GNUNET_TESTBED_BARRIERSTATUS_ERROR |
278 | */ | 273 | */ |
279 | static void | 274 | static void |
280 | send_client_status_msg (struct GNUNET_SERVICE_Client *client, | 275 | send_client_status_msg(struct GNUNET_SERVICE_Client *client, |
281 | const char *name, | 276 | const char *name, |
282 | enum GNUNET_TESTBED_BarrierStatus status, | 277 | enum GNUNET_TESTBED_BarrierStatus status, |
283 | const char *emsg) | 278 | const char *emsg) |
284 | { | 279 | { |
285 | struct GNUNET_MQ_Envelope *env; | 280 | struct GNUNET_MQ_Envelope *env; |
286 | struct GNUNET_TESTBED_BarrierStatusMsg *msg; | 281 | struct GNUNET_TESTBED_BarrierStatusMsg *msg; |
287 | size_t name_len; | 282 | size_t name_len; |
288 | size_t err_len; | 283 | size_t err_len; |
289 | 284 | ||
290 | GNUNET_assert ( (NULL == emsg) || | 285 | GNUNET_assert((NULL == emsg) || |
291 | (GNUNET_TESTBED_BARRIERSTATUS_ERROR == status) ); | 286 | (GNUNET_TESTBED_BARRIERSTATUS_ERROR == status)); |
292 | name_len = strlen (name) + 1; | 287 | name_len = strlen(name) + 1; |
293 | err_len = ((NULL == emsg) ? 0 : (strlen (emsg) + 1)); | 288 | err_len = ((NULL == emsg) ? 0 : (strlen(emsg) + 1)); |
294 | env = GNUNET_MQ_msg_extra (msg, | 289 | env = GNUNET_MQ_msg_extra(msg, |
295 | name_len + err_len, | 290 | name_len + err_len, |
296 | GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS); | 291 | GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS); |
297 | msg->status = htons (status); | 292 | msg->status = htons(status); |
298 | msg->name_len = htons ((uint16_t) name_len - 1); | 293 | msg->name_len = htons((uint16_t)name_len - 1); |
299 | GNUNET_memcpy (msg->data, | 294 | GNUNET_memcpy(msg->data, |
300 | name, | 295 | name, |
301 | name_len); | 296 | name_len); |
302 | GNUNET_memcpy (msg->data + name_len, | 297 | GNUNET_memcpy(msg->data + name_len, |
303 | emsg, | 298 | emsg, |
304 | err_len); | 299 | err_len); |
305 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), | 300 | GNUNET_MQ_send(GNUNET_SERVICE_client_get_mq(client), |
306 | env); | 301 | env); |
307 | } | 302 | } |
308 | 303 | ||
309 | 304 | ||
@@ -315,14 +310,14 @@ send_client_status_msg (struct GNUNET_SERVICE_Client *client, | |||
315 | * status=GNUNET_TESTBED_BARRIERSTATUS_ERROR | 310 | * status=GNUNET_TESTBED_BARRIERSTATUS_ERROR |
316 | */ | 311 | */ |
317 | static void | 312 | static void |
318 | send_barrier_status_msg (struct Barrier *barrier, | 313 | send_barrier_status_msg(struct Barrier *barrier, |
319 | const char *emsg) | 314 | const char *emsg) |
320 | { | 315 | { |
321 | GNUNET_assert (0 != barrier->status); | 316 | GNUNET_assert(0 != barrier->status); |
322 | send_client_status_msg (barrier->mc, | 317 | send_client_status_msg(barrier->mc, |
323 | barrier->name, | 318 | barrier->name, |
324 | barrier->status, | 319 | barrier->status, |
325 | emsg); | 320 | emsg); |
326 | } | 321 | } |
327 | 322 | ||
328 | 323 | ||
@@ -333,8 +328,8 @@ send_barrier_status_msg (struct Barrier *barrier, | |||
333 | * @param message the actual message | 328 | * @param message the actual message |
334 | */ | 329 | */ |
335 | static int | 330 | static int |
336 | check_barrier_wait (void *cls, | 331 | check_barrier_wait(void *cls, |
337 | const struct GNUNET_TESTBED_BarrierWait *msg) | 332 | const struct GNUNET_TESTBED_BarrierWait *msg) |
338 | { | 333 | { |
339 | return GNUNET_OK; /* always well-formed */ | 334 | return GNUNET_OK; /* always well-formed */ |
340 | } | 335 | } |
@@ -352,8 +347,8 @@ check_barrier_wait (void *cls, | |||
352 | * @param message the actual message | 347 | * @param message the actual message |
353 | */ | 348 | */ |
354 | static void | 349 | static void |
355 | handle_barrier_wait (void *cls, | 350 | handle_barrier_wait(void *cls, |
356 | const struct GNUNET_TESTBED_BarrierWait *msg) | 351 | const struct GNUNET_TESTBED_BarrierWait *msg) |
357 | { | 352 | { |
358 | struct ClientCtx *client_ctx = cls; | 353 | struct ClientCtx *client_ctx = cls; |
359 | struct Barrier *barrier; | 354 | struct Barrier *barrier; |
@@ -362,50 +357,50 @@ handle_barrier_wait (void *cls, | |||
362 | size_t name_len; | 357 | size_t name_len; |
363 | uint16_t msize; | 358 | uint16_t msize; |
364 | 359 | ||
365 | msize = ntohs (msg->header.size); | 360 | msize = ntohs(msg->header.size); |
366 | if (NULL == barrier_map) | 361 | if (NULL == barrier_map) |
367 | { | 362 | { |
368 | GNUNET_break (0); | 363 | GNUNET_break(0); |
369 | GNUNET_SERVICE_client_drop (client_ctx->client); | 364 | GNUNET_SERVICE_client_drop(client_ctx->client); |
370 | return; | 365 | return; |
371 | } | 366 | } |
372 | name_len = msize - sizeof (struct GNUNET_TESTBED_BarrierWait); | 367 | name_len = msize - sizeof(struct GNUNET_TESTBED_BarrierWait); |
373 | name = GNUNET_malloc (name_len + 1); | 368 | name = GNUNET_malloc(name_len + 1); |
374 | name[name_len] = '\0'; | 369 | name[name_len] = '\0'; |
375 | GNUNET_memcpy (name, | 370 | GNUNET_memcpy(name, |
376 | msg->name, | 371 | msg->name, |
377 | name_len); | 372 | name_len); |
378 | LOG_DEBUG ("Received BARRIER_WAIT for barrier `%s'\n", | 373 | LOG_DEBUG("Received BARRIER_WAIT for barrier `%s'\n", |
379 | name); | 374 | name); |
380 | GNUNET_CRYPTO_hash (name, | 375 | GNUNET_CRYPTO_hash(name, |
381 | name_len, | 376 | name_len, |
382 | &key); | 377 | &key); |
383 | GNUNET_free (name); | 378 | GNUNET_free(name); |
384 | if (NULL == (barrier = GNUNET_CONTAINER_multihashmap_get (barrier_map, &key))) | 379 | if (NULL == (barrier = GNUNET_CONTAINER_multihashmap_get(barrier_map, &key))) |
385 | { | 380 | { |
386 | GNUNET_break (0); | 381 | GNUNET_break(0); |
387 | GNUNET_SERVICE_client_drop (client_ctx->client); | 382 | GNUNET_SERVICE_client_drop(client_ctx->client); |
388 | return; | 383 | return; |
389 | } | 384 | } |
390 | if (NULL != client_ctx->barrier) | 385 | if (NULL != client_ctx->barrier) |
391 | { | 386 | { |
392 | GNUNET_break (0); | 387 | GNUNET_break(0); |
393 | GNUNET_SERVICE_client_drop (client_ctx->client); | 388 | GNUNET_SERVICE_client_drop(client_ctx->client); |
394 | return; | 389 | return; |
395 | } | 390 | } |
396 | client_ctx->barrier = barrier; | 391 | client_ctx->barrier = barrier; |
397 | GNUNET_CONTAINER_DLL_insert_tail (barrier->head, | 392 | GNUNET_CONTAINER_DLL_insert_tail(barrier->head, |
398 | barrier->tail, | 393 | barrier->tail, |
399 | client_ctx); | 394 | client_ctx); |
400 | barrier->nreached++; | 395 | barrier->nreached++; |
401 | if ( (barrier->num_wbarriers_reached == barrier->num_wbarriers) && | 396 | if ((barrier->num_wbarriers_reached == barrier->num_wbarriers) && |
402 | (LOCAL_QUORUM_REACHED (barrier)) ) | 397 | (LOCAL_QUORUM_REACHED(barrier))) |
403 | { | 398 | { |
404 | barrier->status = GNUNET_TESTBED_BARRIERSTATUS_CROSSED; | 399 | barrier->status = GNUNET_TESTBED_BARRIERSTATUS_CROSSED; |
405 | send_barrier_status_msg (barrier, | 400 | send_barrier_status_msg(barrier, |
406 | NULL); | 401 | NULL); |
407 | } | 402 | } |
408 | GNUNET_SERVICE_client_continue (client_ctx->client); | 403 | GNUNET_SERVICE_client_continue(client_ctx->client); |
409 | } | 404 | } |
410 | 405 | ||
411 | 406 | ||
@@ -418,14 +413,14 @@ handle_barrier_wait (void *cls, | |||
418 | * @return our `struct ClientCtx` | 413 | * @return our `struct ClientCtx` |
419 | */ | 414 | */ |
420 | static void * | 415 | static void * |
421 | connect_cb (void *cls, | 416 | connect_cb(void *cls, |
422 | struct GNUNET_SERVICE_Client *client, | 417 | struct GNUNET_SERVICE_Client *client, |
423 | struct GNUNET_MQ_Handle *mq) | 418 | struct GNUNET_MQ_Handle *mq) |
424 | { | 419 | { |
425 | struct ClientCtx *client_ctx; | 420 | struct ClientCtx *client_ctx; |
426 | 421 | ||
427 | LOG_DEBUG ("Client connected to testbed-barrier service\n"); | 422 | LOG_DEBUG("Client connected to testbed-barrier service\n"); |
428 | client_ctx = GNUNET_new (struct ClientCtx); | 423 | client_ctx = GNUNET_new(struct ClientCtx); |
429 | client_ctx->client = client; | 424 | client_ctx->client = client; |
430 | return client_ctx; | 425 | return client_ctx; |
431 | } | 426 | } |
@@ -440,22 +435,22 @@ connect_cb (void *cls, | |||
440 | * for the last call when the server is destroyed | 435 | * for the last call when the server is destroyed |
441 | */ | 436 | */ |
442 | static void | 437 | static void |
443 | disconnect_cb (void *cls, | 438 | disconnect_cb(void *cls, |
444 | struct GNUNET_SERVICE_Client *client, | 439 | struct GNUNET_SERVICE_Client *client, |
445 | void *app_ctx) | 440 | void *app_ctx) |
446 | { | 441 | { |
447 | struct ClientCtx *client_ctx = app_ctx; | 442 | struct ClientCtx *client_ctx = app_ctx; |
448 | struct Barrier *barrier = client_ctx->barrier; | 443 | struct Barrier *barrier = client_ctx->barrier; |
449 | 444 | ||
450 | if (NULL != barrier) | 445 | if (NULL != barrier) |
451 | { | 446 | { |
452 | GNUNET_CONTAINER_DLL_remove (barrier->head, | 447 | GNUNET_CONTAINER_DLL_remove(barrier->head, |
453 | barrier->tail, | 448 | barrier->tail, |
454 | client_ctx); | 449 | client_ctx); |
455 | client_ctx->barrier = NULL; | 450 | client_ctx->barrier = NULL; |
456 | } | 451 | } |
457 | GNUNET_free (client_ctx); | 452 | GNUNET_free(client_ctx); |
458 | LOG_DEBUG ("Client disconnected from testbed-barrier service\n"); | 453 | LOG_DEBUG("Client disconnected from testbed-barrier service\n"); |
459 | } | 454 | } |
460 | 455 | ||
461 | 456 | ||
@@ -465,25 +460,25 @@ disconnect_cb (void *cls, | |||
465 | * @param cfg the configuration to use for initialisation | 460 | * @param cfg the configuration to use for initialisation |
466 | */ | 461 | */ |
467 | void | 462 | void |
468 | GST_barriers_init (struct GNUNET_CONFIGURATION_Handle *cfg) | 463 | GST_barriers_init(struct GNUNET_CONFIGURATION_Handle *cfg) |
469 | { | 464 | { |
470 | struct GNUNET_MQ_MessageHandler message_handlers[] = { | 465 | struct GNUNET_MQ_MessageHandler message_handlers[] = { |
471 | GNUNET_MQ_hd_var_size (barrier_wait, | 466 | GNUNET_MQ_hd_var_size(barrier_wait, |
472 | GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_WAIT, | 467 | GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_WAIT, |
473 | struct GNUNET_TESTBED_BarrierWait, | 468 | struct GNUNET_TESTBED_BarrierWait, |
474 | NULL), | 469 | NULL), |
475 | GNUNET_MQ_handler_end () | 470 | GNUNET_MQ_handler_end() |
476 | }; | 471 | }; |
477 | 472 | ||
478 | LOG_DEBUG ("Launching testbed-barrier service\n"); | 473 | LOG_DEBUG("Launching testbed-barrier service\n"); |
479 | barrier_map = GNUNET_CONTAINER_multihashmap_create (3, | 474 | barrier_map = GNUNET_CONTAINER_multihashmap_create(3, |
480 | GNUNET_YES); | 475 | GNUNET_YES); |
481 | ctx = GNUNET_SERVICE_start ("testbed-barrier", | 476 | ctx = GNUNET_SERVICE_start("testbed-barrier", |
482 | cfg, | 477 | cfg, |
483 | &connect_cb, | 478 | &connect_cb, |
484 | &disconnect_cb, | 479 | &disconnect_cb, |
485 | NULL, | 480 | NULL, |
486 | message_handlers); | 481 | message_handlers); |
487 | } | 482 | } |
488 | 483 | ||
489 | 484 | ||
@@ -498,15 +493,15 @@ GST_barriers_init (struct GNUNET_CONFIGURATION_Handle *cfg) | |||
498 | * #GNUNET_NO if not. | 493 | * #GNUNET_NO if not. |
499 | */ | 494 | */ |
500 | static int | 495 | static int |
501 | barrier_destroy_iterator (void *cls, | 496 | barrier_destroy_iterator(void *cls, |
502 | const struct GNUNET_HashCode *key, | 497 | const struct GNUNET_HashCode *key, |
503 | void *value) | 498 | void *value) |
504 | { | 499 | { |
505 | struct Barrier *barrier = value; | 500 | struct Barrier *barrier = value; |
506 | 501 | ||
507 | GNUNET_assert (NULL != barrier); | 502 | GNUNET_assert(NULL != barrier); |
508 | cancel_wrappers (barrier); | 503 | cancel_wrappers(barrier); |
509 | remove_barrier (barrier); | 504 | remove_barrier(barrier); |
510 | return GNUNET_YES; | 505 | return GNUNET_YES; |
511 | } | 506 | } |
512 | 507 | ||
@@ -515,16 +510,16 @@ barrier_destroy_iterator (void *cls, | |||
515 | * Function to stop the barrier service | 510 | * Function to stop the barrier service |
516 | */ | 511 | */ |
517 | void | 512 | void |
518 | GST_barriers_destroy () | 513 | GST_barriers_destroy() |
519 | { | 514 | { |
520 | GNUNET_assert (NULL != barrier_map); | 515 | GNUNET_assert(NULL != barrier_map); |
521 | GNUNET_assert (GNUNET_SYSERR != | 516 | GNUNET_assert(GNUNET_SYSERR != |
522 | GNUNET_CONTAINER_multihashmap_iterate (barrier_map, | 517 | GNUNET_CONTAINER_multihashmap_iterate(barrier_map, |
523 | &barrier_destroy_iterator, | 518 | &barrier_destroy_iterator, |
524 | NULL)); | 519 | NULL)); |
525 | GNUNET_CONTAINER_multihashmap_destroy (barrier_map); | 520 | GNUNET_CONTAINER_multihashmap_destroy(barrier_map); |
526 | GNUNET_assert (NULL != ctx); | 521 | GNUNET_assert(NULL != ctx); |
527 | GNUNET_SERVICE_stop (ctx); | 522 | GNUNET_SERVICE_stop(ctx); |
528 | } | 523 | } |
529 | 524 | ||
530 | 525 | ||
@@ -542,57 +537,59 @@ GST_barriers_destroy () | |||
542 | * error messsage | 537 | * error messsage |
543 | */ | 538 | */ |
544 | static void | 539 | static void |
545 | wbarrier_status_cb (void *cls, | 540 | wbarrier_status_cb(void *cls, |
546 | const char *name, | 541 | const char *name, |
547 | struct GNUNET_TESTBED_Barrier *b_, | 542 | struct GNUNET_TESTBED_Barrier *b_, |
548 | enum GNUNET_TESTBED_BarrierStatus status, | 543 | enum GNUNET_TESTBED_BarrierStatus status, |
549 | const char *emsg) | 544 | const char *emsg) |
550 | { | 545 | { |
551 | struct WBarrier *wrapper = cls; | 546 | struct WBarrier *wrapper = cls; |
552 | struct Barrier *barrier = wrapper->barrier; | 547 | struct Barrier *barrier = wrapper->barrier; |
553 | 548 | ||
554 | GNUNET_assert (b_ == wrapper->hbarrier); | 549 | GNUNET_assert(b_ == wrapper->hbarrier); |
555 | switch (status) | 550 | switch (status) |
556 | { | ||
557 | case GNUNET_TESTBED_BARRIERSTATUS_ERROR: | ||
558 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
559 | "Initialising barrier `%s' failed at a sub-controller: %s\n", | ||
560 | barrier->name, | ||
561 | (NULL != emsg) ? emsg : "NULL"); | ||
562 | cancel_wrappers (barrier); | ||
563 | if (NULL == emsg) | ||
564 | emsg = "Initialisation failed at a sub-controller"; | ||
565 | barrier->status = GNUNET_TESTBED_BARRIERSTATUS_ERROR; | ||
566 | send_barrier_status_msg (barrier, emsg); | ||
567 | return; | ||
568 | case GNUNET_TESTBED_BARRIERSTATUS_CROSSED: | ||
569 | if (GNUNET_TESTBED_BARRIERSTATUS_INITIALISED != barrier->status) | ||
570 | { | 551 | { |
571 | GNUNET_break_op (0); | 552 | case GNUNET_TESTBED_BARRIERSTATUS_ERROR: |
553 | LOG(GNUNET_ERROR_TYPE_ERROR, | ||
554 | "Initialising barrier `%s' failed at a sub-controller: %s\n", | ||
555 | barrier->name, | ||
556 | (NULL != emsg) ? emsg : "NULL"); | ||
557 | cancel_wrappers(barrier); | ||
558 | if (NULL == emsg) | ||
559 | emsg = "Initialisation failed at a sub-controller"; | ||
560 | barrier->status = GNUNET_TESTBED_BARRIERSTATUS_ERROR; | ||
561 | send_barrier_status_msg(barrier, emsg); | ||
572 | return; | 562 | return; |
573 | } | 563 | |
574 | barrier->num_wbarriers_reached++; | 564 | case GNUNET_TESTBED_BARRIERSTATUS_CROSSED: |
575 | if ((barrier->num_wbarriers_reached == barrier->num_wbarriers) | 565 | if (GNUNET_TESTBED_BARRIERSTATUS_INITIALISED != barrier->status) |
576 | && (LOCAL_QUORUM_REACHED (barrier))) | 566 | { |
577 | { | 567 | GNUNET_break_op(0); |
578 | barrier->status = GNUNET_TESTBED_BARRIERSTATUS_CROSSED; | 568 | return; |
579 | send_barrier_status_msg (barrier, NULL); | 569 | } |
580 | } | 570 | barrier->num_wbarriers_reached++; |
581 | return; | 571 | if ((barrier->num_wbarriers_reached == barrier->num_wbarriers) |
582 | case GNUNET_TESTBED_BARRIERSTATUS_INITIALISED: | 572 | && (LOCAL_QUORUM_REACHED(barrier))) |
583 | if (0 != barrier->status) | 573 | { |
584 | { | 574 | barrier->status = GNUNET_TESTBED_BARRIERSTATUS_CROSSED; |
585 | GNUNET_break_op (0); | 575 | send_barrier_status_msg(barrier, NULL); |
576 | } | ||
577 | return; | ||
578 | |||
579 | case GNUNET_TESTBED_BARRIERSTATUS_INITIALISED: | ||
580 | if (0 != barrier->status) | ||
581 | { | ||
582 | GNUNET_break_op(0); | ||
583 | return; | ||
584 | } | ||
585 | barrier->num_wbarriers_inited++; | ||
586 | if (barrier->num_wbarriers_inited == barrier->num_wbarriers) | ||
587 | { | ||
588 | barrier->status = GNUNET_TESTBED_BARRIERSTATUS_INITIALISED; | ||
589 | send_barrier_status_msg(barrier, NULL); | ||
590 | } | ||
586 | return; | 591 | return; |
587 | } | 592 | } |
588 | barrier->num_wbarriers_inited++; | ||
589 | if (barrier->num_wbarriers_inited == barrier->num_wbarriers) | ||
590 | { | ||
591 | barrier->status = GNUNET_TESTBED_BARRIERSTATUS_INITIALISED; | ||
592 | send_barrier_status_msg (barrier, NULL); | ||
593 | } | ||
594 | return; | ||
595 | } | ||
596 | } | 593 | } |
597 | 594 | ||
598 | 595 | ||
@@ -603,15 +600,15 @@ wbarrier_status_cb (void *cls, | |||
603 | * @param cls barrier | 600 | * @param cls barrier |
604 | */ | 601 | */ |
605 | static void | 602 | static void |
606 | fwd_tout_barrier_init (void *cls) | 603 | fwd_tout_barrier_init(void *cls) |
607 | { | 604 | { |
608 | struct Barrier *barrier = cls; | 605 | struct Barrier *barrier = cls; |
609 | 606 | ||
610 | cancel_wrappers (barrier); | 607 | cancel_wrappers(barrier); |
611 | barrier->status = GNUNET_TESTBED_BARRIERSTATUS_ERROR; | 608 | barrier->status = GNUNET_TESTBED_BARRIERSTATUS_ERROR; |
612 | send_barrier_status_msg (barrier, | 609 | send_barrier_status_msg(barrier, |
613 | "Timedout while propagating barrier initialisation\n"); | 610 | "Timedout while propagating barrier initialisation\n"); |
614 | remove_barrier (barrier); | 611 | remove_barrier(barrier); |
615 | } | 612 | } |
616 | 613 | ||
617 | 614 | ||
@@ -624,8 +621,8 @@ fwd_tout_barrier_init (void *cls) | |||
624 | * @return #GNUNET_OK if @a msg is well-formed | 621 | * @return #GNUNET_OK if @a msg is well-formed |
625 | */ | 622 | */ |
626 | int | 623 | int |
627 | check_barrier_init (void *cls, | 624 | check_barrier_init(void *cls, |
628 | const struct GNUNET_TESTBED_BarrierInit *msg) | 625 | const struct GNUNET_TESTBED_BarrierInit *msg) |
629 | { | 626 | { |
630 | return GNUNET_OK; /* always well-formed */ | 627 | return GNUNET_OK; /* always well-formed */ |
631 | } | 628 | } |
@@ -643,8 +640,8 @@ check_barrier_init (void *cls, | |||
643 | * @param msg the actual message | 640 | * @param msg the actual message |
644 | */ | 641 | */ |
645 | void | 642 | void |
646 | handle_barrier_init (void *cls, | 643 | handle_barrier_init(void *cls, |
647 | const struct GNUNET_TESTBED_BarrierInit *msg) | 644 | const struct GNUNET_TESTBED_BarrierInit *msg) |
648 | { | 645 | { |
649 | struct GNUNET_SERVICE_Client *client = cls; | 646 | struct GNUNET_SERVICE_Client *client = cls; |
650 | char *name; | 647 | char *name; |
@@ -657,81 +654,82 @@ handle_barrier_init (void *cls, | |||
657 | uint16_t msize; | 654 | uint16_t msize; |
658 | 655 | ||
659 | if (NULL == GST_context) | 656 | if (NULL == GST_context) |
660 | { | 657 | { |
661 | GNUNET_break_op (0); | 658 | GNUNET_break_op(0); |
662 | GNUNET_SERVICE_client_drop (client); | 659 | GNUNET_SERVICE_client_drop(client); |
663 | return; | 660 | return; |
664 | } | 661 | } |
665 | if (client != GST_context->client) | 662 | if (client != GST_context->client) |
666 | { | 663 | { |
667 | GNUNET_break_op (0); | 664 | GNUNET_break_op(0); |
668 | GNUNET_SERVICE_client_drop (client); | 665 | GNUNET_SERVICE_client_drop(client); |
669 | return; | 666 | return; |
670 | } | 667 | } |
671 | msize = ntohs (msg->header.size); | 668 | msize = ntohs(msg->header.size); |
672 | name_len = (size_t) msize - sizeof (struct GNUNET_TESTBED_BarrierInit); | 669 | name_len = (size_t)msize - sizeof(struct GNUNET_TESTBED_BarrierInit); |
673 | name = GNUNET_malloc (name_len + 1); | 670 | name = GNUNET_malloc(name_len + 1); |
674 | GNUNET_memcpy (name, msg->name, name_len); | 671 | GNUNET_memcpy(name, msg->name, name_len); |
675 | GNUNET_CRYPTO_hash (name, name_len, &hash); | 672 | GNUNET_CRYPTO_hash(name, name_len, &hash); |
676 | LOG_DEBUG ("Received BARRIER_INIT for barrier `%s'\n", | 673 | LOG_DEBUG("Received BARRIER_INIT for barrier `%s'\n", |
677 | name); | 674 | name); |
678 | if (GNUNET_YES == | 675 | if (GNUNET_YES == |
679 | GNUNET_CONTAINER_multihashmap_contains (barrier_map, | 676 | GNUNET_CONTAINER_multihashmap_contains(barrier_map, |
680 | &hash)) | 677 | &hash)) |
681 | { | 678 | { |
682 | send_client_status_msg (client, | 679 | send_client_status_msg(client, |
683 | name, | 680 | name, |
684 | GNUNET_TESTBED_BARRIERSTATUS_ERROR, | 681 | GNUNET_TESTBED_BARRIERSTATUS_ERROR, |
685 | "A barrier with the same name already exists"); | 682 | "A barrier with the same name already exists"); |
686 | GNUNET_free (name); | 683 | GNUNET_free(name); |
687 | GNUNET_SERVICE_client_continue (client); | 684 | GNUNET_SERVICE_client_continue(client); |
688 | return; | 685 | return; |
689 | } | 686 | } |
690 | barrier = GNUNET_new (struct Barrier); | 687 | barrier = GNUNET_new(struct Barrier); |
691 | barrier->hash = hash; | 688 | barrier->hash = hash; |
692 | barrier->quorum = msg->quorum; | 689 | barrier->quorum = msg->quorum; |
693 | barrier->name = name; | 690 | barrier->name = name; |
694 | barrier->mc = client; | 691 | barrier->mc = client; |
695 | GNUNET_assert (GNUNET_OK == | 692 | GNUNET_assert(GNUNET_OK == |
696 | GNUNET_CONTAINER_multihashmap_put (barrier_map, | 693 | GNUNET_CONTAINER_multihashmap_put(barrier_map, |
697 | &barrier->hash, | 694 | &barrier->hash, |
698 | barrier, | 695 | barrier, |
699 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)); | 696 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)); |
700 | GNUNET_SERVICE_client_continue (client); | 697 | GNUNET_SERVICE_client_continue(client); |
701 | /* Propagate barrier init to subcontrollers */ | 698 | /* Propagate barrier init to subcontrollers */ |
702 | for (cnt = 0; cnt < GST_slave_list_size; cnt++) | 699 | for (cnt = 0; cnt < GST_slave_list_size; cnt++) |
703 | { | ||
704 | if (NULL == (slave = GST_slave_list[cnt])) | ||
705 | continue; | ||
706 | if (NULL == slave->controller) | ||
707 | { | 700 | { |
708 | GNUNET_break (0);/* May happen when we are connecting to the controller */ | 701 | if (NULL == (slave = GST_slave_list[cnt])) |
709 | continue; | 702 | continue; |
703 | if (NULL == slave->controller) | ||
704 | { | ||
705 | GNUNET_break(0);/* May happen when we are connecting to the controller */ | ||
706 | continue; | ||
707 | } | ||
708 | wrapper = GNUNET_new(struct WBarrier); | ||
709 | wrapper->barrier = barrier; | ||
710 | wrapper->controller = slave->controller; | ||
711 | GNUNET_CONTAINER_DLL_insert_tail(barrier->whead, | ||
712 | barrier->wtail, | ||
713 | wrapper); | ||
714 | barrier->num_wbarriers++; | ||
715 | wrapper->hbarrier = GNUNET_TESTBED_barrier_init_(wrapper->controller, | ||
716 | barrier->name, | ||
717 | barrier->quorum, | ||
718 | &wbarrier_status_cb, | ||
719 | wrapper, | ||
720 | GNUNET_NO); | ||
710 | } | 721 | } |
711 | wrapper = GNUNET_new (struct WBarrier); | ||
712 | wrapper->barrier = barrier; | ||
713 | wrapper->controller = slave->controller; | ||
714 | GNUNET_CONTAINER_DLL_insert_tail (barrier->whead, | ||
715 | barrier->wtail, | ||
716 | wrapper); | ||
717 | barrier->num_wbarriers++; | ||
718 | wrapper->hbarrier = GNUNET_TESTBED_barrier_init_ (wrapper->controller, | ||
719 | barrier->name, | ||
720 | barrier->quorum, | ||
721 | &wbarrier_status_cb, | ||
722 | wrapper, | ||
723 | GNUNET_NO); | ||
724 | } | ||
725 | if (NULL == barrier->whead) /* No further propagation */ | 722 | if (NULL == barrier->whead) /* No further propagation */ |
726 | { | 723 | { |
727 | barrier->status = GNUNET_TESTBED_BARRIERSTATUS_INITIALISED; | 724 | barrier->status = GNUNET_TESTBED_BARRIERSTATUS_INITIALISED; |
728 | LOG_DEBUG ("Sending GNUNET_TESTBED_BARRIERSTATUS_INITIALISED for barrier `%s'\n", | 725 | LOG_DEBUG("Sending GNUNET_TESTBED_BARRIERSTATUS_INITIALISED for barrier `%s'\n", |
729 | barrier->name); | 726 | barrier->name); |
730 | send_barrier_status_msg (barrier, NULL); | 727 | send_barrier_status_msg(barrier, NULL); |
731 | }else | 728 | } |
732 | barrier->tout_task = GNUNET_SCHEDULER_add_delayed (MESSAGE_SEND_TIMEOUT (30), | 729 | else |
733 | &fwd_tout_barrier_init, | 730 | barrier->tout_task = GNUNET_SCHEDULER_add_delayed(MESSAGE_SEND_TIMEOUT(30), |
734 | barrier); | 731 | &fwd_tout_barrier_init, |
732 | barrier); | ||
735 | } | 733 | } |
736 | 734 | ||
737 | 735 | ||
@@ -743,8 +741,8 @@ handle_barrier_init (void *cls, | |||
743 | * @return #GNUNET_OK if @a msg is well-formed | 741 | * @return #GNUNET_OK if @a msg is well-formed |
744 | */ | 742 | */ |
745 | int | 743 | int |
746 | check_barrier_cancel (void *cls, | 744 | check_barrier_cancel(void *cls, |
747 | const struct GNUNET_TESTBED_BarrierCancel *msg) | 745 | const struct GNUNET_TESTBED_BarrierCancel *msg) |
748 | { | 746 | { |
749 | return GNUNET_OK; /* all are well-formed */ | 747 | return GNUNET_OK; /* all are well-formed */ |
750 | } | 748 | } |
@@ -762,8 +760,8 @@ check_barrier_cancel (void *cls, | |||
762 | * @param msg the actual message | 760 | * @param msg the actual message |
763 | */ | 761 | */ |
764 | void | 762 | void |
765 | handle_barrier_cancel (void *cls, | 763 | handle_barrier_cancel(void *cls, |
766 | const struct GNUNET_TESTBED_BarrierCancel *msg) | 764 | const struct GNUNET_TESTBED_BarrierCancel *msg) |
767 | { | 765 | { |
768 | struct GNUNET_SERVICE_Client *client = cls; | 766 | struct GNUNET_SERVICE_Client *client = cls; |
769 | char *name; | 767 | char *name; |
@@ -773,42 +771,42 @@ handle_barrier_cancel (void *cls, | |||
773 | uint16_t msize; | 771 | uint16_t msize; |
774 | 772 | ||
775 | if (NULL == GST_context) | 773 | if (NULL == GST_context) |
776 | { | 774 | { |
777 | GNUNET_break_op (0); | 775 | GNUNET_break_op(0); |
778 | GNUNET_SERVICE_client_drop (client); | 776 | GNUNET_SERVICE_client_drop(client); |
779 | return; | 777 | return; |
780 | } | 778 | } |
781 | if (client != GST_context->client) | 779 | if (client != GST_context->client) |
782 | { | 780 | { |
783 | GNUNET_break_op (0); | 781 | GNUNET_break_op(0); |
784 | GNUNET_SERVICE_client_drop (client); | 782 | GNUNET_SERVICE_client_drop(client); |
785 | return; | 783 | return; |
786 | } | 784 | } |
787 | msize = ntohs (msg->header.size); | 785 | msize = ntohs(msg->header.size); |
788 | name_len = msize - sizeof (struct GNUNET_TESTBED_BarrierCancel); | 786 | name_len = msize - sizeof(struct GNUNET_TESTBED_BarrierCancel); |
789 | name = GNUNET_malloc (name_len + 1); | 787 | name = GNUNET_malloc(name_len + 1); |
790 | GNUNET_memcpy (name, | 788 | GNUNET_memcpy(name, |
791 | msg->name, | 789 | msg->name, |
792 | name_len); | 790 | name_len); |
793 | LOG_DEBUG ("Received BARRIER_CANCEL for barrier `%s'\n", | 791 | LOG_DEBUG("Received BARRIER_CANCEL for barrier `%s'\n", |
794 | name); | 792 | name); |
795 | GNUNET_CRYPTO_hash (name, | 793 | GNUNET_CRYPTO_hash(name, |
796 | name_len, | 794 | name_len, |
797 | &hash); | 795 | &hash); |
798 | if (GNUNET_NO == | 796 | if (GNUNET_NO == |
799 | GNUNET_CONTAINER_multihashmap_contains (barrier_map, | 797 | GNUNET_CONTAINER_multihashmap_contains(barrier_map, |
800 | &hash)) | 798 | &hash)) |
801 | { | 799 | { |
802 | GNUNET_break_op (0); | 800 | GNUNET_break_op(0); |
803 | GNUNET_SERVICE_client_drop (client); | 801 | GNUNET_SERVICE_client_drop(client); |
804 | return; | 802 | return; |
805 | } | 803 | } |
806 | barrier = GNUNET_CONTAINER_multihashmap_get (barrier_map, | 804 | barrier = GNUNET_CONTAINER_multihashmap_get(barrier_map, |
807 | &hash); | 805 | &hash); |
808 | GNUNET_assert (NULL != barrier); | 806 | GNUNET_assert(NULL != barrier); |
809 | cancel_wrappers (barrier); | 807 | cancel_wrappers(barrier); |
810 | remove_barrier (barrier); | 808 | remove_barrier(barrier); |
811 | GNUNET_SERVICE_client_continue (client); | 809 | GNUNET_SERVICE_client_continue(client); |
812 | } | 810 | } |
813 | 811 | ||
814 | 812 | ||
@@ -820,34 +818,34 @@ handle_barrier_cancel (void *cls, | |||
820 | * @return #GNUNET_OK if @a msg is well-formed | 818 | * @return #GNUNET_OK if @a msg is well-formed |
821 | */ | 819 | */ |
822 | int | 820 | int |
823 | check_barrier_status (void *cls, | 821 | check_barrier_status(void *cls, |
824 | const struct GNUNET_TESTBED_BarrierStatusMsg *msg) | 822 | const struct GNUNET_TESTBED_BarrierStatusMsg *msg) |
825 | { | 823 | { |
826 | uint16_t msize; | 824 | uint16_t msize; |
827 | uint16_t name_len; | 825 | uint16_t name_len; |
828 | const char *name; | 826 | const char *name; |
829 | enum GNUNET_TESTBED_BarrierStatus status; | 827 | enum GNUNET_TESTBED_BarrierStatus status; |
830 | 828 | ||
831 | msize = ntohs (msg->header.size) - sizeof (*msg); | 829 | msize = ntohs(msg->header.size) - sizeof(*msg); |
832 | status = ntohs (msg->status); | 830 | status = ntohs(msg->status); |
833 | if (GNUNET_TESTBED_BARRIERSTATUS_CROSSED != status) | 831 | if (GNUNET_TESTBED_BARRIERSTATUS_CROSSED != status) |
834 | { | 832 | { |
835 | GNUNET_break_op (0); /* current we only expect BARRIER_CROSSED | 833 | GNUNET_break_op(0); /* current we only expect BARRIER_CROSSED |
836 | status message this way */ | 834 | status message this way */ |
837 | return GNUNET_SYSERR; | 835 | return GNUNET_SYSERR; |
838 | } | 836 | } |
839 | name = msg->data; | 837 | name = msg->data; |
840 | name_len = ntohs (msg->name_len); | 838 | name_len = ntohs(msg->name_len); |
841 | if ((name_len + 1) != msize) | 839 | if ((name_len + 1) != msize) |
842 | { | 840 | { |
843 | GNUNET_break_op (0); | 841 | GNUNET_break_op(0); |
844 | return GNUNET_SYSERR; | 842 | return GNUNET_SYSERR; |
845 | } | 843 | } |
846 | if ('\0' != name[name_len]) | 844 | if ('\0' != name[name_len]) |
847 | { | 845 | { |
848 | GNUNET_break_op (0); | 846 | GNUNET_break_op(0); |
849 | return GNUNET_SYSERR; | 847 | return GNUNET_SYSERR; |
850 | } | 848 | } |
851 | return GNUNET_OK; | 849 | return GNUNET_OK; |
852 | } | 850 | } |
853 | 851 | ||
@@ -861,8 +859,8 @@ check_barrier_status (void *cls, | |||
861 | * @param msg the actual message | 859 | * @param msg the actual message |
862 | */ | 860 | */ |
863 | void | 861 | void |
864 | handle_barrier_status (void *cls, | 862 | handle_barrier_status(void *cls, |
865 | const struct GNUNET_TESTBED_BarrierStatusMsg *msg) | 863 | const struct GNUNET_TESTBED_BarrierStatusMsg *msg) |
866 | { | 864 | { |
867 | struct GNUNET_SERVICE_Client *client = cls; | 865 | struct GNUNET_SERVICE_Client *client = cls; |
868 | struct Barrier *barrier; | 866 | struct Barrier *barrier; |
@@ -874,48 +872,48 @@ handle_barrier_status (void *cls, | |||
874 | struct GNUNET_MQ_Envelope *env; | 872 | struct GNUNET_MQ_Envelope *env; |
875 | 873 | ||
876 | if (NULL == GST_context) | 874 | if (NULL == GST_context) |
877 | { | 875 | { |
878 | GNUNET_break_op (0); | 876 | GNUNET_break_op(0); |
879 | GNUNET_SERVICE_client_drop (client); | 877 | GNUNET_SERVICE_client_drop(client); |
880 | return; | 878 | return; |
881 | } | 879 | } |
882 | if (client != GST_context->client) | 880 | if (client != GST_context->client) |
883 | { | 881 | { |
884 | GNUNET_break_op (0); | 882 | GNUNET_break_op(0); |
885 | GNUNET_SERVICE_client_drop (client); | 883 | GNUNET_SERVICE_client_drop(client); |
886 | return; | 884 | return; |
887 | } | 885 | } |
888 | name = msg->data; | 886 | name = msg->data; |
889 | name_len = ntohs (msg->name_len); | 887 | name_len = ntohs(msg->name_len); |
890 | LOG_DEBUG ("Received BARRIER_STATUS for barrier `%s'\n", | 888 | LOG_DEBUG("Received BARRIER_STATUS for barrier `%s'\n", |
891 | name); | 889 | name); |
892 | GNUNET_CRYPTO_hash (name, | 890 | GNUNET_CRYPTO_hash(name, |
893 | name_len, | 891 | name_len, |
894 | &key); | 892 | &key); |
895 | barrier = GNUNET_CONTAINER_multihashmap_get (barrier_map, | 893 | barrier = GNUNET_CONTAINER_multihashmap_get(barrier_map, |
896 | &key); | 894 | &key); |
897 | if (NULL == barrier) | 895 | if (NULL == barrier) |
898 | { | 896 | { |
899 | GNUNET_break_op (0); | 897 | GNUNET_break_op(0); |
900 | GNUNET_SERVICE_client_drop (client); | 898 | GNUNET_SERVICE_client_drop(client); |
901 | return; | 899 | return; |
902 | } | 900 | } |
903 | GNUNET_SERVICE_client_continue (client); | 901 | GNUNET_SERVICE_client_continue(client); |
904 | for(client_ctx = barrier->head; NULL != client_ctx; client_ctx = client_ctx->next) /* Notify peers */ | 902 | for (client_ctx = barrier->head; NULL != client_ctx; client_ctx = client_ctx->next) /* Notify peers */ |
905 | { | 903 | { |
906 | env = GNUNET_MQ_msg_copy (&msg->header); | 904 | env = GNUNET_MQ_msg_copy(&msg->header); |
907 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client_ctx->client), | 905 | GNUNET_MQ_send(GNUNET_SERVICE_client_get_mq(client_ctx->client), |
908 | env); | 906 | env); |
909 | } | 907 | } |
910 | /** | 908 | /** |
911 | * The wrapper barriers do not echo the barrier status, so we have to do it | 909 | * The wrapper barriers do not echo the barrier status, so we have to do it |
912 | * here | 910 | * here |
913 | */ | 911 | */ |
914 | for (wrapper = barrier->whead; NULL != wrapper; wrapper = wrapper->next) | 912 | for (wrapper = barrier->whead; NULL != wrapper; wrapper = wrapper->next) |
915 | { | 913 | { |
916 | GNUNET_TESTBED_queue_message_ (wrapper->controller, | 914 | GNUNET_TESTBED_queue_message_(wrapper->controller, |
917 | GNUNET_copy_message (&msg->header)); | 915 | GNUNET_copy_message(&msg->header)); |
918 | } | 916 | } |
919 | } | 917 | } |
920 | 918 | ||
921 | /* end of gnunet-service-testbed_barriers.c */ | 919 | /* end of gnunet-service-testbed_barriers.c */ |