diff options
Diffstat (limited to 'src/testbed/gnunet-service-testbed_barriers.c')
-rw-r--r-- | src/testbed/gnunet-service-testbed_barriers.c | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/src/testbed/gnunet-service-testbed_barriers.c b/src/testbed/gnunet-service-testbed_barriers.c index bffafd7ae..634f0a07a 100644 --- a/src/testbed/gnunet-service-testbed_barriers.c +++ b/src/testbed/gnunet-service-testbed_barriers.c | |||
@@ -21,7 +21,7 @@ | |||
21 | /** | 21 | /** |
22 | * @file testbed/gnunet-service-testbed_barriers.c | 22 | * @file testbed/gnunet-service-testbed_barriers.c |
23 | * @brief barrier handling at the testbed controller | 23 | * @brief barrier handling at the testbed controller |
24 | * @author Sree Harsha Totakura <sreeharsha@totakura.in> | 24 | * @author Sree Harsha Totakura <sreeharsha@totakura.in> |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include "gnunet-service-testbed.h" | 27 | #include "gnunet-service-testbed.h" |
@@ -200,12 +200,12 @@ struct Barrier | |||
200 | * Identifier for the timeout task | 200 | * Identifier for the timeout task |
201 | */ | 201 | */ |
202 | GNUNET_SCHEDULER_TaskIdentifier tout_task; | 202 | GNUNET_SCHEDULER_TaskIdentifier tout_task; |
203 | 203 | ||
204 | /** | 204 | /** |
205 | * The status of this barrier | 205 | * The status of this barrier |
206 | */ | 206 | */ |
207 | enum GNUNET_TESTBED_BarrierStatus status; | 207 | enum GNUNET_TESTBED_BarrierStatus status; |
208 | 208 | ||
209 | /** | 209 | /** |
210 | * Number of barriers wrapped in the above DLL | 210 | * Number of barriers wrapped in the above DLL |
211 | */ | 211 | */ |
@@ -235,7 +235,7 @@ struct Barrier | |||
235 | * Quorum percentage to be reached | 235 | * Quorum percentage to be reached |
236 | */ | 236 | */ |
237 | uint8_t quorum; | 237 | uint8_t quorum; |
238 | 238 | ||
239 | }; | 239 | }; |
240 | 240 | ||
241 | 241 | ||
@@ -261,7 +261,7 @@ static struct GNUNET_SERVICE_Context *ctx; | |||
261 | * @param buf where the callee should write the message | 261 | * @param buf where the callee should write the message |
262 | * @return number of bytes written to buf | 262 | * @return number of bytes written to buf |
263 | */ | 263 | */ |
264 | static size_t | 264 | static size_t |
265 | transmit_ready_cb (void *cls, size_t size, void *buf) | 265 | transmit_ready_cb (void *cls, size_t size, void *buf) |
266 | { | 266 | { |
267 | struct ClientCtx *ctx = cls; | 267 | struct ClientCtx *ctx = cls; |
@@ -276,7 +276,7 @@ transmit_ready_cb (void *cls, size_t size, void *buf) | |||
276 | { | 276 | { |
277 | GNUNET_assert (NULL != ctx->client); | 277 | GNUNET_assert (NULL != ctx->client); |
278 | GNUNET_SERVER_client_drop (ctx->client); | 278 | GNUNET_SERVER_client_drop (ctx->client); |
279 | ctx->client = NULL; | 279 | ctx->client = NULL; |
280 | return 0; | 280 | return 0; |
281 | } | 281 | } |
282 | mq = ctx->mq_head; | 282 | mq = ctx->mq_head; |
@@ -306,7 +306,7 @@ queue_message (struct ClientCtx *ctx, struct GNUNET_MessageHeader *msg) | |||
306 | { | 306 | { |
307 | struct MessageQueue *mq; | 307 | struct MessageQueue *mq; |
308 | struct GNUNET_SERVER_Client *client = ctx->client; | 308 | struct GNUNET_SERVER_Client *client = ctx->client; |
309 | 309 | ||
310 | mq = GNUNET_malloc (sizeof (struct MessageQueue)); | 310 | mq = GNUNET_malloc (sizeof (struct MessageQueue)); |
311 | mq->msg = msg; | 311 | mq->msg = msg; |
312 | LOG_DEBUG ("Queueing message of type %u, size %u for sending\n", | 312 | LOG_DEBUG ("Queueing message of type %u, size %u for sending\n", |
@@ -328,12 +328,12 @@ static void | |||
328 | cleanup_clientctx (struct ClientCtx *ctx) | 328 | cleanup_clientctx (struct ClientCtx *ctx) |
329 | { | 329 | { |
330 | struct MessageQueue *mq; | 330 | struct MessageQueue *mq; |
331 | 331 | ||
332 | if (NULL != ctx->client) | 332 | if (NULL != ctx->client) |
333 | { | 333 | { |
334 | GNUNET_SERVER_client_set_user_context_ (ctx->client, NULL, 0); | 334 | GNUNET_SERVER_client_set_user_context_ (ctx->client, NULL, 0); |
335 | GNUNET_SERVER_client_drop (ctx->client); | 335 | GNUNET_SERVER_client_drop (ctx->client); |
336 | } | 336 | } |
337 | if (NULL != ctx->tx) | 337 | if (NULL != ctx->tx) |
338 | GNUNET_SERVER_notify_transmit_ready_cancel (ctx->tx); | 338 | GNUNET_SERVER_notify_transmit_ready_cancel (ctx->tx); |
339 | if (NULL != (mq = ctx->mq_head)) | 339 | if (NULL != (mq = ctx->mq_head)) |
@@ -356,7 +356,7 @@ static void | |||
356 | remove_barrier (struct Barrier *barrier) | 356 | remove_barrier (struct Barrier *barrier) |
357 | { | 357 | { |
358 | struct ClientCtx *ctx; | 358 | struct ClientCtx *ctx; |
359 | 359 | ||
360 | GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove (barrier_map, | 360 | GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove (barrier_map, |
361 | &barrier->hash, | 361 | &barrier->hash, |
362 | barrier)); | 362 | barrier)); |
@@ -397,7 +397,7 @@ cancel_wrappers (struct Barrier *barrier) | |||
397 | * @param name the barrier name | 397 | * @param name the barrier name |
398 | * @param status the status of the barrier | 398 | * @param status the status of the barrier |
399 | * @param emsg the error message; should be non-NULL for | 399 | * @param emsg the error message; should be non-NULL for |
400 | * status=GNUNET_TESTBED_BARRIERSTATUS_ERROR | 400 | * status=GNUNET_TESTBED_BARRIERSTATUS_ERROR |
401 | */ | 401 | */ |
402 | static void | 402 | static void |
403 | send_client_status_msg (struct GNUNET_SERVER_Client *client, | 403 | send_client_status_msg (struct GNUNET_SERVER_Client *client, |
@@ -431,7 +431,7 @@ send_client_status_msg (struct GNUNET_SERVER_Client *client, | |||
431 | * | 431 | * |
432 | * @param barrier the corresponding barrier | 432 | * @param barrier the corresponding barrier |
433 | * @param emsg the error message; should be non-NULL for | 433 | * @param emsg the error message; should be non-NULL for |
434 | * status=GNUNET_TESTBED_BARRIERSTATUS_ERROR | 434 | * status=GNUNET_TESTBED_BARRIERSTATUS_ERROR |
435 | */ | 435 | */ |
436 | static void | 436 | static void |
437 | send_barrier_status_msg (struct Barrier *barrier, const char *emsg) | 437 | send_barrier_status_msg (struct Barrier *barrier, const char *emsg) |
@@ -464,7 +464,7 @@ handle_barrier_wait (void *cls, struct GNUNET_SERVER_Client *client, | |||
464 | struct GNUNET_HashCode key; | 464 | struct GNUNET_HashCode key; |
465 | size_t name_len; | 465 | size_t name_len; |
466 | uint16_t msize; | 466 | uint16_t msize; |
467 | 467 | ||
468 | msize = ntohs (message->size); | 468 | msize = ntohs (message->size); |
469 | if (msize <= sizeof (struct GNUNET_TESTBED_BarrierWait)) | 469 | if (msize <= sizeof (struct GNUNET_TESTBED_BarrierWait)) |
470 | { | 470 | { |
@@ -500,7 +500,7 @@ handle_barrier_wait (void *cls, struct GNUNET_SERVER_Client *client, | |||
500 | GNUNET_SERVER_client_keep (client); | 500 | GNUNET_SERVER_client_keep (client); |
501 | client_ctx->barrier = barrier; | 501 | client_ctx->barrier = barrier; |
502 | GNUNET_CONTAINER_DLL_insert_tail (barrier->head, barrier->tail, client_ctx); | 502 | GNUNET_CONTAINER_DLL_insert_tail (barrier->head, barrier->tail, client_ctx); |
503 | GNUNET_SERVER_client_set_user_context (client, client_ctx); | 503 | GNUNET_SERVER_client_set_user_context (client, client_ctx); |
504 | } | 504 | } |
505 | barrier->nreached++; | 505 | barrier->nreached++; |
506 | if ((barrier->num_wbarriers_reached == barrier->num_wbarriers) | 506 | if ((barrier->num_wbarriers_reached == barrier->num_wbarriers) |
@@ -525,7 +525,7 @@ static void | |||
525 | disconnect_cb (void *cls, struct GNUNET_SERVER_Client *client) | 525 | disconnect_cb (void *cls, struct GNUNET_SERVER_Client *client) |
526 | { | 526 | { |
527 | struct ClientCtx *client_ctx; | 527 | struct ClientCtx *client_ctx; |
528 | 528 | ||
529 | if (NULL == client) | 529 | if (NULL == client) |
530 | return; | 530 | return; |
531 | client_ctx = GNUNET_SERVER_client_get_user_context (client, struct ClientCtx); | 531 | client_ctx = GNUNET_SERVER_client_get_user_context (client, struct ClientCtx); |
@@ -554,7 +554,7 @@ GST_barriers_init (struct GNUNET_CONFIGURATION_Handle *cfg) | |||
554 | GNUNET_SERVICE_OPTION_MANUAL_SHUTDOWN); | 554 | GNUNET_SERVICE_OPTION_MANUAL_SHUTDOWN); |
555 | srv = GNUNET_SERVICE_get_server (ctx); | 555 | srv = GNUNET_SERVICE_get_server (ctx); |
556 | GNUNET_SERVER_add_handlers (srv, message_handlers); | 556 | GNUNET_SERVER_add_handlers (srv, message_handlers); |
557 | GNUNET_SERVER_disconnect_notify (srv, &disconnect_cb, NULL); | 557 | GNUNET_SERVER_disconnect_notify (srv, &disconnect_cb, NULL); |
558 | } | 558 | } |
559 | 559 | ||
560 | 560 | ||
@@ -568,7 +568,7 @@ GST_barriers_init (struct GNUNET_CONFIGURATION_Handle *cfg) | |||
568 | * iterate, | 568 | * iterate, |
569 | * #GNUNET_NO if not. | 569 | * #GNUNET_NO if not. |
570 | */ | 570 | */ |
571 | static int | 571 | static int |
572 | barrier_destroy_iterator (void *cls, | 572 | barrier_destroy_iterator (void *cls, |
573 | const struct GNUNET_HashCode *key, | 573 | const struct GNUNET_HashCode *key, |
574 | void *value) | 574 | void *value) |
@@ -612,7 +612,7 @@ GST_barriers_destroy () | |||
612 | * @param emsg if the status were to be GNUNET_SYSERR, this parameter has the | 612 | * @param emsg if the status were to be GNUNET_SYSERR, this parameter has the |
613 | * error messsage | 613 | * error messsage |
614 | */ | 614 | */ |
615 | static void | 615 | static void |
616 | wbarrier_status_cb (void *cls, const char *name, | 616 | wbarrier_status_cb (void *cls, const char *name, |
617 | struct GNUNET_TESTBED_Barrier *b_, | 617 | struct GNUNET_TESTBED_Barrier *b_, |
618 | enum GNUNET_TESTBED_BarrierStatus status, | 618 | enum GNUNET_TESTBED_BarrierStatus status, |
@@ -679,7 +679,7 @@ static void | |||
679 | fwd_tout_barrier_init (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 679 | fwd_tout_barrier_init (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
680 | { | 680 | { |
681 | struct Barrier *barrier = cls; | 681 | struct Barrier *barrier = cls; |
682 | 682 | ||
683 | cancel_wrappers (barrier); | 683 | cancel_wrappers (barrier); |
684 | barrier->status = GNUNET_TESTBED_BARRIERSTATUS_ERROR; | 684 | barrier->status = GNUNET_TESTBED_BARRIERSTATUS_ERROR; |
685 | send_barrier_status_msg (barrier, | 685 | send_barrier_status_msg (barrier, |
@@ -713,7 +713,7 @@ GST_handle_barrier_init (void *cls, struct GNUNET_SERVER_Client *client, | |||
713 | size_t name_len; | 713 | size_t name_len; |
714 | unsigned int cnt; | 714 | unsigned int cnt; |
715 | uint16_t msize; | 715 | uint16_t msize; |
716 | 716 | ||
717 | if (NULL == GST_context) | 717 | if (NULL == GST_context) |
718 | { | 718 | { |
719 | GNUNET_break_op (0); | 719 | GNUNET_break_op (0); |
@@ -741,7 +741,7 @@ GST_handle_barrier_init (void *cls, struct GNUNET_SERVER_Client *client, | |||
741 | LOG_DEBUG ("Received BARRIER_INIT for barrier `%s'\n", name); | 741 | LOG_DEBUG ("Received BARRIER_INIT for barrier `%s'\n", name); |
742 | if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains (barrier_map, &hash)) | 742 | if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains (barrier_map, &hash)) |
743 | { | 743 | { |
744 | 744 | ||
745 | send_client_status_msg (client, name, GNUNET_TESTBED_BARRIERSTATUS_ERROR, | 745 | send_client_status_msg (client, name, GNUNET_TESTBED_BARRIERSTATUS_ERROR, |
746 | "A barrier with the same name already exists"); | 746 | "A barrier with the same name already exists"); |
747 | GNUNET_free (name); | 747 | GNUNET_free (name); |
@@ -821,7 +821,7 @@ GST_handle_barrier_cancel (void *cls, struct GNUNET_SERVER_Client *client, | |||
821 | GNUNET_break_op (0); | 821 | GNUNET_break_op (0); |
822 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 822 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
823 | return; | 823 | return; |
824 | } | 824 | } |
825 | if (client != GST_context->client) | 825 | if (client != GST_context->client) |
826 | { | 826 | { |
827 | GNUNET_break_op (0); | 827 | GNUNET_break_op (0); |
@@ -850,7 +850,7 @@ GST_handle_barrier_cancel (void *cls, struct GNUNET_SERVER_Client *client, | |||
850 | GNUNET_assert (NULL != barrier); | 850 | GNUNET_assert (NULL != barrier); |
851 | cancel_wrappers (barrier); | 851 | cancel_wrappers (barrier); |
852 | remove_barrier (barrier); | 852 | remove_barrier (barrier); |
853 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 853 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
854 | } | 854 | } |
855 | 855 | ||
856 | 856 | ||
@@ -868,20 +868,20 @@ GST_handle_barrier_status (void *cls, struct GNUNET_SERVER_Client *client, | |||
868 | const struct GNUNET_MessageHeader *message) | 868 | const struct GNUNET_MessageHeader *message) |
869 | { | 869 | { |
870 | const struct GNUNET_TESTBED_BarrierStatusMsg *msg; | 870 | const struct GNUNET_TESTBED_BarrierStatusMsg *msg; |
871 | struct Barrier *barrier; | 871 | struct Barrier *barrier; |
872 | struct ClientCtx *client_ctx; | 872 | struct ClientCtx *client_ctx; |
873 | const char *name; | 873 | const char *name; |
874 | struct GNUNET_HashCode key; | 874 | struct GNUNET_HashCode key; |
875 | enum GNUNET_TESTBED_BarrierStatus status; | 875 | enum GNUNET_TESTBED_BarrierStatus status; |
876 | uint16_t msize; | 876 | uint16_t msize; |
877 | uint16_t name_len; | 877 | uint16_t name_len; |
878 | 878 | ||
879 | if (NULL == GST_context) | 879 | if (NULL == GST_context) |
880 | { | 880 | { |
881 | GNUNET_break_op (0); | 881 | GNUNET_break_op (0); |
882 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 882 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
883 | return; | 883 | return; |
884 | } | 884 | } |
885 | if (client != GST_context->client) | 885 | if (client != GST_context->client) |
886 | { | 886 | { |
887 | GNUNET_break_op (0); | 887 | GNUNET_break_op (0); |