36 #define MESSAGE_SEND_TIMEOUT(s) \
37 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, s)
43 #define LOCAL_QUORUM_REACHED(barrier) \
44 ((barrier->quorum * GST_num_local_peers) <= (barrier->nreached * 100))
54 #define LOG(kind, ...) \
55 GNUNET_log_from (kind, "testbed-barriers", __VA_ARGS__)
292 err_len = ((NULL == emsg) ? 0 : (strlen (emsg) + 1));
364 msize = ntohs (
msg->header.
size);
373 name[name_len] =
'\0';
377 LOG_DEBUG (
"Received BARRIER_WAIT for barrier `%s'\n",
389 if (NULL != client_ctx->
barrier)
426 LOG_DEBUG (
"Client connected to testbed-barrier service\n");
457 LOG_DEBUG (
"Client disconnected from testbed-barrier service\n");
477 LOG_DEBUG (
"Launching testbed-barrier service\n");
559 "Initialising barrier `%s' failed at a sub-controller: %s\n",
561 (NULL != emsg) ? emsg :
"NULL");
564 emsg =
"Initialisation failed at a sub-controller";
615 "Timedout while propagating barrier initialisation\n");
672 msize = ntohs (
msg->header.
size);
677 LOG_DEBUG (
"Received BARRIER_INIT for barrier `%s'\n",
686 "A barrier with the same name already exists");
692 barrier->
hash = hash;
695 barrier->
mc = client;
726 if (NULL == barrier->
whead)
730 "Sending GNUNET_TESTBED_BARRIERSTATUS_INITIALISED for barrier `%s'\n",
791 msize = ntohs (
msg->header.
size);
797 LOG_DEBUG (
"Received BARRIER_CANCEL for barrier `%s'\n",
837 msize = ntohs (
msg->header.
size) -
sizeof(*msg);
846 name_len = ntohs (
msg->name_len);
847 if ((name_len + 1) != msize)
852 if (
'\0' !=
name[name_len])
895 name_len = ntohs (
msg->name_len);
896 LOG_DEBUG (
"Received BARRIER_STATUS for barrier `%s'\n",
910 for (client_ctx = barrier->
head; NULL != client_ctx; client_ctx =
921 for (wrapper = barrier->
whead; NULL != wrapper; wrapper = wrapper->
next)
struct GNUNET_MQ_Handle * mq
struct GNUNET_MessageHeader * msg
struct GNUNET_MQ_Envelope * env
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
struct GNUNET_HashCode key
The key used in the DHT.
uint16_t status
See PRISM_STATUS_*-constants.
static char * value
Value of the record to add/remove.
#define LOG_DEBUG(...)
Debug logging shorthand.
struct Context * GST_context
The master context; generated with the first INIT message.
data structures shared amongst components of TESTBED service
#define MESSAGE_SEND_TIMEOUT(s)
timeout for outgoing message transmissions in seconds
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().
#define LOCAL_QUORUM_REACHED(barrier)
Test to see if local peers have reached the required quorum of a barrier.
int check_barrier_init(void *cls, const struct GNUNET_TESTBED_BarrierInit *msg)
Check GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_INIT messages.
void handle_barrier_cancel(void *cls, const struct GNUNET_TESTBED_BarrierCancel *msg)
Message handler for GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_CANCEL messages.
void handle_barrier_init(void *cls, const struct GNUNET_TESTBED_BarrierInit *msg)
Message handler for GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_INIT messages.
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.
static struct GNUNET_SERVICE_Handle * ctx
Service context.
static void handle_barrier_wait(void *cls, const struct GNUNET_TESTBED_BarrierWait *msg)
Message handler for GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_WAIT messages.
static void cancel_wrappers(struct Barrier *barrier)
Cancels all subcontroller barrier handles.
static int check_barrier_wait(void *cls, const struct GNUNET_TESTBED_BarrierWait *msg)
Check GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_WAIT messages.
int check_barrier_status(void *cls, const struct GNUNET_TESTBED_BarrierStatusMsg *msg)
Check GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS messages.
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.
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.
void GST_barriers_init(struct GNUNET_CONFIGURATION_Handle *cfg)
Function to initialise barriers component.
static void fwd_tout_barrier_init(void *cls)
Function called upon timeout while waiting for a response from the subcontrollers to barrier init mes...
static int barrier_destroy_iterator(void *cls, const struct GNUNET_HashCode *key, void *value)
Iterator over hash map entries.
static void remove_barrier(struct Barrier *barrier)
Function to remove a barrier from the barrier map and cleanup resources occupied by a barrier.
int check_barrier_cancel(void *cls, const struct GNUNET_TESTBED_BarrierCancel *msg)
Check GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_CANCEL messages.
void GST_barriers_destroy()
Function to stop the barrier service.
void handle_barrier_status(void *cls, const struct GNUNET_TESTBED_BarrierStatusMsg *msg)
Message handler for GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS messages.
#define LOG(kind,...)
Logging shorthand.
static struct GNUNET_CONTAINER_MultiHashMap * barrier_map
Hashtable handle for storing initialised barriers.
static void send_barrier_status_msg(struct Barrier *barrier, const char *emsg)
Sends a barrier failed message.
Interface for the barrier initialisation handler routine.
unsigned int GST_slave_list_size
The size of directly linked neighbours list.
struct Slave ** GST_slave_list
A list of directly linked neighbours.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_contains(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Check if the map contains any value under the given key (including values that are NULL).
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_remove(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Remove the given key-value pair from the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
void * GNUNET_CONTAINER_multihashmap_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST
, ' bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE...
void * cls
Closure for mv and cb.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_ERROR
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
struct GNUNET_MessageHeader * GNUNET_copy_message(const struct GNUNET_MessageHeader *msg)
Create a copy of the given message.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
struct GNUNET_MQ_Envelope * GNUNET_MQ_msg_copy(const struct GNUNET_MessageHeader *hdr)
Create a new envelope by copying an existing message.
#define GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS
Message for signalling status of a barrier.
#define GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_WAIT
Message sent by a peer when it has reached a barrier and is waiting for it to be crossed.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
void GNUNET_SERVICE_stop(struct GNUNET_SERVICE_Handle *srv)
Stops a service that was started with GNUNET_SERVICE_start().
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
struct GNUNET_SERVICE_Handle * GNUNET_SERVICE_start(const char *service_name, const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_SERVICE_ConnectHandler connect_cb, GNUNET_SERVICE_DisconnectHandler disconnect_cb, void *cls, const struct GNUNET_MQ_MessageHandler *handlers)
Low-level function to start a service if the scheduler is already running.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
GNUNET_TESTBED_BarrierStatus
Status of a barrier.
void GNUNET_TESTBED_barrier_cancel(struct GNUNET_TESTBED_Barrier *barrier)
Cancel a barrier.
@ GNUNET_TESTBED_BARRIERSTATUS_CROSSED
Barrier is crossed.
@ GNUNET_TESTBED_BARRIERSTATUS_ERROR
Error status.
@ GNUNET_TESTBED_BARRIERSTATUS_INITIALISED
Barrier initialised successfully.
uint8_t quorum
Quorum percentage to be reached.
struct GNUNET_SCHEDULER_Task * tout_task
Identifier for the timeout task.
struct WBarrier * wtail
DLL tail for the list of barrier handles.
struct GNUNET_HashCode hash
The hashcode of the barrier name.
unsigned int num_wbarriers_reached
Number of wrapped barriers reached so far.
unsigned int num_wbarriers
Number of barriers wrapped in the above DLL.
unsigned int nreached
Number of peers which have reached this barrier.
struct WBarrier * whead
DLL head for the list of barrier handles.
char * name
The name of the barrier.
enum GNUNET_TESTBED_BarrierStatus status
The status of this barrier.
struct ClientCtx * head
DLL head for the list of clients waiting for this barrier.
unsigned int num_wbarriers_inited
Number of wrapped barrier initialised so far.
struct ClientCtx * tail
DLL tail for the list of clients waiting for this barrier.
unsigned int nslaves
Number of slaves we have initialised this barrier.
struct GNUNET_SERVICE_Client * mc
The client handle to the master controller.
Context to be associated with each client.
struct ClientCtx * next
DLL next ptr.
struct Barrier * barrier
The barrier this client is waiting for.
struct GNUNET_SERVICE_Client * client
The client handle.
struct ClientCtx * prev
DLL prev ptr.
struct GNUNET_SERVICE_Client * client
The client handle associated with this context.
Internal representation of the hash map.
Handle to a message queue.
Message handler for a specific message type.
Entry in list of pending tasks.
Handle to a client that is connected to a service.
Message to cancel a barrier.
Message to initialise a barrier.
Message for signalling status changes of a barrier.
uint16_t name_len
strlen of the barrier name
Message sent from peers to the testbed-barrier service to indicate that they have reached a barrier a...
Handle to interact with a GNUnet testbed controller.
Structure representing a connected(directly-linked) controller.
struct GNUNET_TESTBED_Controller * controller
The controller handle.
Wrapper around Barrier handle.
uint8_t reached
Has this barrier been crossed?
struct Barrier * barrier
The local barrier associated with the creation of this wrapper.
struct WBarrier * next
DLL next pointer.
struct GNUNET_TESTBED_Barrier * hbarrier
The barrier handle from API.
struct WBarrier * prev
DLL prev pointer.
struct GNUNET_TESTBED_Controller * controller
Handle to the slave controller where this wrapper creates a barrier.
void GNUNET_TESTBED_queue_message_(struct GNUNET_TESTBED_Controller *controller, struct GNUNET_MessageHeader *msg)
Queues a message in send queue for sending to the service.
struct GNUNET_TESTBED_Barrier * GNUNET_TESTBED_barrier_init_(struct GNUNET_TESTBED_Controller *controller, const char *name, unsigned int quorum, GNUNET_TESTBED_barrier_status_cb cb, void *cls, int echo)
Initialise a barrier and call the given callback when the required percentage of peers (quorum) reach...
Interface for functions internally exported from testbed_api.c.