barrier handling at the testbed controller More...
#include "platform.h"
#include "gnunet-service-testbed.h"
#include "gnunet-service-testbed_barriers.h"
#include "testbed_api.h"
Go to the source code of this file.
Data Structures | |
struct | ClientCtx |
Context to be associated with each client. More... | |
struct | WBarrier |
Wrapper around Barrier handle. More... | |
struct | Barrier |
Barrier. More... | |
Macros | |
#define | MESSAGE_SEND_TIMEOUT(s) GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, s) |
timeout for outgoing message transmissions in seconds More... | |
#define | LOCAL_QUORUM_REACHED(barrier) ((barrier->quorum * GST_num_local_peers) <= (barrier->nreached * 100)) |
Test to see if local peers have reached the required quorum of a barrier. More... | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "testbed-barriers", __VA_ARGS__) |
Logging shorthand. More... | |
Functions | |
static void | remove_barrier (struct Barrier *barrier) |
Function to remove a barrier from the barrier map and cleanup resources occupied by a barrier. More... | |
static void | cancel_wrappers (struct Barrier *barrier) |
Cancels all subcontroller barrier handles. More... | |
static void | send_client_status_msg (struct GNUNET_SERVICE_Client *client, const char *name, enum GNUNET_TESTBED_BarrierStatus status, const char *emsg) |
Send a status message about a barrier to the given client. More... | |
static void | send_barrier_status_msg (struct Barrier *barrier, const char *emsg) |
Sends a barrier failed message. More... | |
static int | check_barrier_wait (void *cls, const struct GNUNET_TESTBED_BarrierWait *msg) |
Check GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_WAIT messages. More... | |
static void | handle_barrier_wait (void *cls, const struct GNUNET_TESTBED_BarrierWait *msg) |
Message handler for GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_WAIT messages. More... | |
static void * | connect_cb (void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq) |
Function called when a client connects to the testbed-barrier service. More... | |
static void | disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *client, void *app_ctx) |
Functions with this signature are called whenever a client is disconnected on the network level. More... | |
void | GST_barriers_init (struct GNUNET_CONFIGURATION_Handle *cfg) |
Function to initialise barriers component. More... | |
static int | barrier_destroy_iterator (void *cls, const struct GNUNET_HashCode *key, void *value) |
Iterator over hash map entries. More... | |
void | GST_barriers_destroy () |
Function to stop the barrier service. More... | |
static void | wbarrier_status_cb (void *cls, const char *name, struct GNUNET_TESTBED_Barrier *b_, enum GNUNET_TESTBED_BarrierStatus status, const char *emsg) |
Functions of this type are to be given as callback argument to GNUNET_TESTBED_barrier_init(). More... | |
static void | fwd_tout_barrier_init (void *cls) |
Function called upon timeout while waiting for a response from the subcontrollers to barrier init message. More... | |
int | check_barrier_init (void *cls, const struct GNUNET_TESTBED_BarrierInit *msg) |
Check GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_INIT messages. More... | |
void | handle_barrier_init (void *cls, const struct GNUNET_TESTBED_BarrierInit *msg) |
Message handler for GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_INIT messages. More... | |
int | check_barrier_cancel (void *cls, const struct GNUNET_TESTBED_BarrierCancel *msg) |
Check GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_CANCEL messages. More... | |
void | handle_barrier_cancel (void *cls, const struct GNUNET_TESTBED_BarrierCancel *msg) |
Message handler for GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_CANCEL messages. More... | |
int | check_barrier_status (void *cls, const struct GNUNET_TESTBED_BarrierStatusMsg *msg) |
Check GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS messages. More... | |
void | handle_barrier_status (void *cls, const struct GNUNET_TESTBED_BarrierStatusMsg *msg) |
Message handler for GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS messages. More... | |
Variables | |
static struct GNUNET_CONTAINER_MultiHashMap * | barrier_map |
Hashtable handle for storing initialised barriers. More... | |
static struct GNUNET_SERVICE_Handle * | ctx |
Service context. More... | |
barrier handling at the testbed controller
Definition in file gnunet-service-testbed_barriers.c.
#define MESSAGE_SEND_TIMEOUT | ( | s | ) | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, s) |
timeout for outgoing message transmissions in seconds
Definition at line 36 of file gnunet-service-testbed_barriers.c.
#define LOCAL_QUORUM_REACHED | ( | barrier | ) | ((barrier->quorum * GST_num_local_peers) <= (barrier->nreached * 100)) |
Test to see if local peers have reached the required quorum of a barrier.
Definition at line 43 of file gnunet-service-testbed_barriers.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "testbed-barriers", __VA_ARGS__) |
Logging shorthand.
Definition at line 54 of file gnunet-service-testbed_barriers.c.
|
static |
Function to remove a barrier from the barrier map and cleanup resources occupied by a barrier.
barrier | the barrier handle |
Definition at line 228 of file gnunet-service-testbed_barriers.c.
References ClientCtx::barrier, barrier_map, ctx, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multihashmap_remove(), GNUNET_free, GNUNET_YES, Barrier::hash, Barrier::head, Barrier::name, and Barrier::tail.
Referenced by barrier_destroy_iterator(), fwd_tout_barrier_init(), and handle_barrier_cancel().
|
static |
Cancels all subcontroller barrier handles.
barrier | the local barrier |
Definition at line 254 of file gnunet-service-testbed_barriers.c.
References WBarrier::barrier, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_TESTBED_barrier_cancel(), WBarrier::hbarrier, Barrier::whead, and Barrier::wtail.
Referenced by barrier_destroy_iterator(), fwd_tout_barrier_init(), handle_barrier_cancel(), and wbarrier_status_cb().
|
static |
Send a status message about a barrier to the given client.
client | the client to send the message to |
name | the barrier name |
status | the status of the barrier |
emsg | the error message; should be non-NULL for status=GNUNET_TESTBED_BARRIERSTATUS_ERROR |
Definition at line 279 of file gnunet-service-testbed_barriers.c.
References env, GNUNET_assert, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_SERVICE_client_get_mq(), GNUNET_TESTBED_BARRIERSTATUS_ERROR, msg, name, GNUNET_TESTBED_BarrierStatusMsg::name_len, and status.
Referenced by handle_barrier_init(), and send_barrier_status_msg().
|
static |
Sends a barrier failed message.
barrier | the corresponding barrier |
emsg | the error message; should be non-NULL for status=GNUNET_TESTBED_BARRIERSTATUS_ERROR |
Definition at line 317 of file gnunet-service-testbed_barriers.c.
References GNUNET_assert, Barrier::mc, Barrier::name, send_client_status_msg(), and Barrier::status.
Referenced by fwd_tout_barrier_init(), handle_barrier_init(), handle_barrier_wait(), and wbarrier_status_cb().
|
static |
Check GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_WAIT messages.
cls | identification of the client |
msg | the actual message |
Definition at line 335 of file gnunet-service-testbed_barriers.c.
References GNUNET_OK.
|
static |
Message handler for GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_WAIT messages.
This message should come from peers or a shared helper service using the testbed-barrier client API (
This handler is queued in the main service and will handle the messages sent either from the testbed driver or from a high level controller
cls | identification of the client |
msg | the actual message |
Definition at line 354 of file gnunet-service-testbed_barriers.c.
References ClientCtx::barrier, barrier_map, ClientCtx::client, GNUNET_break, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CRYPTO_hash(), GNUNET_free, GNUNET_malloc, GNUNET_memcpy, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_TESTBED_BARRIERSTATUS_CROSSED, Barrier::head, key, LOCAL_QUORUM_REACHED, LOG_DEBUG, msg, name, Barrier::nreached, Barrier::num_wbarriers, Barrier::num_wbarriers_reached, send_barrier_status_msg(), GNUNET_MessageHeader::size, Barrier::status, and Barrier::tail.
|
static |
Function called when a client connects to the testbed-barrier service.
cls | NULL |
client | the connecting client |
mq | queue to talk to client |
struct ClientCtx
Definition at line 420 of file gnunet-service-testbed_barriers.c.
References ClientCtx::client, GNUNET_new, and LOG_DEBUG.
Referenced by GST_barriers_init().
|
static |
Functions with this signature are called whenever a client is disconnected on the network level.
cls | closure |
client | identification of the client; NULL for the last call when the server is destroyed |
Definition at line 442 of file gnunet-service-testbed_barriers.c.
References ClientCtx::barrier, GNUNET_CONTAINER_DLL_remove, GNUNET_free, Barrier::head, LOG_DEBUG, and Barrier::tail.
Referenced by GST_barriers_init().
void GST_barriers_init | ( | struct GNUNET_CONFIGURATION_Handle * | cfg | ) |
Function to initialise barriers component.
cfg | the configuration to use for initialisation |
Definition at line 467 of file gnunet-service-testbed_barriers.c.
References barrier_map, cfg, connect_cb(), ctx, disconnect_cb(), GNUNET_CONTAINER_multihashmap_create(), GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_WAIT, GNUNET_MQ_handler_end, GNUNET_MQ_hd_var_size, GNUNET_SERVICE_start(), GNUNET_YES, and LOG_DEBUG.
Referenced by testbed_run().
|
static |
Iterator over hash map entries.
cls | closure |
key | current key code |
value | value in the hash map |
Definition at line 500 of file gnunet-service-testbed_barriers.c.
References cancel_wrappers(), GNUNET_assert, GNUNET_YES, remove_barrier(), and value.
Referenced by GST_barriers_destroy().
void GST_barriers_destroy | ( | void | ) |
Function to stop the barrier service.
Definition at line 517 of file gnunet-service-testbed_barriers.c.
References barrier_destroy_iterator(), barrier_map, ctx, GNUNET_assert, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_SERVICE_stop(), and GNUNET_SYSERR.
Referenced by shutdown_task().
|
static |
Functions of this type are to be given as callback argument to GNUNET_TESTBED_barrier_init().
The callback will be called when status information is available for the barrier.
cls | the closure given to GNUNET_TESTBED_barrier_init() |
name | the name of the barrier |
b_ | the barrier handle |
status | status of the barrier; GNUNET_OK if the barrier is crossed; GNUNET_SYSERR upon error |
emsg | if the status were to be GNUNET_SYSERR, this parameter has the error message |
Definition at line 545 of file gnunet-service-testbed_barriers.c.
References WBarrier::barrier, cancel_wrappers(), GNUNET_assert, GNUNET_break_op, GNUNET_ERROR_TYPE_ERROR, GNUNET_TESTBED_BARRIERSTATUS_CROSSED, GNUNET_TESTBED_BARRIERSTATUS_ERROR, GNUNET_TESTBED_BARRIERSTATUS_INITIALISED, WBarrier::hbarrier, LOCAL_QUORUM_REACHED, LOG, Barrier::name, Barrier::num_wbarriers, Barrier::num_wbarriers_inited, Barrier::num_wbarriers_reached, send_barrier_status_msg(), Barrier::status, and status.
Referenced by handle_barrier_init().
|
static |
Function called upon timeout while waiting for a response from the subcontrollers to barrier init message.
cls | barrier |
Definition at line 608 of file gnunet-service-testbed_barriers.c.
References cancel_wrappers(), GNUNET_TESTBED_BARRIERSTATUS_ERROR, remove_barrier(), send_barrier_status_msg(), and Barrier::status.
Referenced by handle_barrier_init().
int check_barrier_init | ( | void * | cls, |
const struct GNUNET_TESTBED_BarrierInit * | msg | ||
) |
Check GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_INIT messages.
cls | identification of the client |
msg | the actual message |
Definition at line 628 of file gnunet-service-testbed_barriers.c.
References GNUNET_OK.
void handle_barrier_init | ( | void * | cls, |
const struct GNUNET_TESTBED_BarrierInit * | msg | ||
) |
Message handler for GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_INIT messages.
This message should always come from a parent controller or the testbed API if we are the root controller.
This handler is queued in the main service and will handle the messages sent either from the testbed driver or from a high level controller
cls | identification of the client |
msg | the actual message |
Definition at line 647 of file gnunet-service-testbed_barriers.c.
References WBarrier::barrier, barrier_map, Context::client, WBarrier::controller, Slave::controller, fwd_tout_barrier_init(), GNUNET_assert, GNUNET_break, GNUNET_break_op, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_CONTAINER_multihashmap_contains(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_CRYPTO_hash(), GNUNET_free, GNUNET_malloc, GNUNET_memcpy, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_delayed(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_TESTBED_barrier_init_(), GNUNET_TESTBED_BARRIERSTATUS_ERROR, GNUNET_TESTBED_BARRIERSTATUS_INITIALISED, GNUNET_YES, GST_context, GST_slave_list, GST_slave_list_size, Barrier::hash, WBarrier::hbarrier, LOG_DEBUG, Barrier::mc, MESSAGE_SEND_TIMEOUT, msg, name, Barrier::name, Barrier::num_wbarriers, Barrier::quorum, send_barrier_status_msg(), send_client_status_msg(), GNUNET_MessageHeader::size, Barrier::status, Barrier::tout_task, wbarrier_status_cb(), Barrier::whead, and Barrier::wtail.
int check_barrier_cancel | ( | void * | cls, |
const struct GNUNET_TESTBED_BarrierCancel * | msg | ||
) |
Check GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_CANCEL messages.
cls | identification of the client |
msg | the actual message |
Definition at line 750 of file gnunet-service-testbed_barriers.c.
References GNUNET_OK.
void handle_barrier_cancel | ( | void * | cls, |
const struct GNUNET_TESTBED_BarrierCancel * | msg | ||
) |
Message handler for GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_CANCEL messages.
This message should always come from a parent controller or the testbed API if we are the root controller.
This handler is queued in the main service and will handle the messages sent either from the testbed driver or from a high level controller
cls | identification of the client |
msg | the actual message |
Definition at line 769 of file gnunet-service-testbed_barriers.c.
References barrier_map, cancel_wrappers(), Context::client, GNUNET_assert, GNUNET_break_op, GNUNET_CONTAINER_multihashmap_contains(), GNUNET_CONTAINER_multihashmap_get(), GNUNET_CRYPTO_hash(), GNUNET_free, GNUNET_malloc, GNUNET_memcpy, GNUNET_NO, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GST_context, LOG_DEBUG, msg, name, remove_barrier(), and GNUNET_MessageHeader::size.
int check_barrier_status | ( | void * | cls, |
const struct GNUNET_TESTBED_BarrierStatusMsg * | msg | ||
) |
Check GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS messages.
cls | identification of the client |
msg | the actual message |
Definition at line 829 of file gnunet-service-testbed_barriers.c.
References GNUNET_break_op, GNUNET_OK, GNUNET_SYSERR, GNUNET_TESTBED_BARRIERSTATUS_CROSSED, msg, name, GNUNET_MessageHeader::size, and status.
void handle_barrier_status | ( | void * | cls, |
const struct GNUNET_TESTBED_BarrierStatusMsg * | msg | ||
) |
Message handler for GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS messages.
This handler is queued in the main service and will handle the messages sent either from the testbed driver or from a high level controller
cls | identification of the client |
msg | the actual message |
The wrapper barriers do not echo the barrier status, so we have to do it here
Definition at line 870 of file gnunet-service-testbed_barriers.c.
References barrier_map, Context::client, ClientCtx::client, WBarrier::controller, env, GNUNET_break_op, GNUNET_CONTAINER_multihashmap_get(), GNUNET_copy_message(), GNUNET_CRYPTO_hash(), GNUNET_MQ_msg_copy(), GNUNET_MQ_send(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_SERVICE_client_get_mq(), GNUNET_TESTBED_queue_message_(), GST_context, Barrier::head, key, LOG_DEBUG, msg, name, ClientCtx::next, WBarrier::next, and Barrier::whead.
|
static |
Hashtable handle for storing initialised barriers.
Definition at line 213 of file gnunet-service-testbed_barriers.c.
Referenced by GST_barriers_destroy(), GST_barriers_init(), handle_barrier_cancel(), handle_barrier_init(), handle_barrier_status(), handle_barrier_wait(), and remove_barrier().
|
static |
Service context.
Definition at line 218 of file gnunet-service-testbed_barriers.c.
Referenced by GST_barriers_destroy(), GST_barriers_init(), and remove_barrier().