GNUnet  0.11.x
Data Structures | Macros | Functions
testbed_api_barriers.c File Reference

API implementation for testbed barriers. More...

#include "platform.h"
#include "gnunet_testbed_service.h"
#include "testbed_api.h"
Include dependency graph for testbed_api_barriers.c:

Go to the source code of this file.

Data Structures

struct  GNUNET_TESTBED_BarrierWaitHandle
 Barrier wait handle. More...
 

Macros

#define LOG(type, ...)   GNUNET_log_from (type, "testbed-api-barriers", __VA_ARGS__);
 Logging shorthand. More...
 
#define LOG_DEBUG(...)   LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__);
 Debug logging shorthand. More...
 

Functions

static int check_status (void *cls, const struct GNUNET_TESTBED_BarrierStatusMsg *msg)
 Check if barrier status message is well-formed. More...
 
static void handle_status (void *cls, const struct GNUNET_TESTBED_BarrierStatusMsg *msg)
 Type of a function to call when we receive a message from the service. More...
 
static void mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
 Generic error handler, called with the appropriate error code and the same closure specified at the creation of the message queue. More...
 
struct GNUNET_TESTBED_BarrierWaitHandleGNUNET_TESTBED_barrier_wait (const char *name, GNUNET_TESTBED_barrier_wait_cb cb, void *cb_cls)
 Wait for a barrier to be crossed. More...
 
void GNUNET_TESTBED_barrier_wait_cancel (struct GNUNET_TESTBED_BarrierWaitHandle *h)
 Cancel a barrier wait handle. More...
 

Detailed Description

API implementation for testbed barriers.

Author
Sree Harsha Totakura sreeh.nosp@m.arsh.nosp@m.a@tot.nosp@m.akur.nosp@m.a.in

Definition in file testbed_api_barriers.c.

Macro Definition Documentation

◆ LOG

#define LOG (   type,
  ... 
)    GNUNET_log_from (type, "testbed-api-barriers", __VA_ARGS__);

Logging shorthand.

Definition at line 33 of file testbed_api_barriers.c.

Referenced by GNUNET_TESTBED_barrier_wait().

◆ LOG_DEBUG

#define LOG_DEBUG (   ...)    LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__);

Debug logging shorthand.

Definition at line 39 of file testbed_api_barriers.c.

Function Documentation

◆ check_status()

static int check_status ( void *  cls,
const struct GNUNET_TESTBED_BarrierStatusMsg msg 
)
static

Check if barrier status message is well-formed.

Parameters
clsclosure
msgreceived message
Returns
GNUNET_OK if the message is well-formed.

Definition at line 83 of file testbed_api_barriers.c.

References GNUNET_OK.

85 {
86  /* FIXME: this fails to actually check that the message
87  follows the protocol spec (0-terminations!). However,
88  not critical as #handle_status() doesn't interpret the
89  variable-size part anyway right now. */
90  return GNUNET_OK;
91 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75

◆ handle_status()

static void handle_status ( void *  cls,
const struct GNUNET_TESTBED_BarrierStatusMsg msg 
)
static

Type of a function to call when we receive a message from the service.

Parameters
clsclosure
msgreceived message

Definition at line 102 of file testbed_api_barriers.c.

References GNUNET_TESTBED_BarrierWaitHandle::cb, GNUNET_TESTBED_BarrierWaitHandle::cb_cls, GNUNET_break, GNUNET_break_op, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_OK, GNUNET_SYSERR, GNUNET_TESTBED_barrier_wait_cancel(), GNUNET_TESTBED_BARRIERSTATUS_CROSSED, GNUNET_TESTBED_BARRIERSTATUS_ERROR, GNUNET_TESTBED_BARRIERSTATUS_INITIALISED, h, GNUNET_TESTBED_BarrierWaitHandle::name, and GNUNET_TESTBED_BarrierStatusMsg::status.

104 {
105  struct GNUNET_TESTBED_BarrierWaitHandle *h = cls;
106 
108  "Got barrier status %d\n",
109  (int) ntohs (msg->status));
110  switch (ntohs (msg->status))
111  {
113  h->cb (h->cb_cls,
114  h->name,
115  GNUNET_SYSERR);
116  break;
117 
119  h->cb (h->cb_cls,
120  h->name,
121  GNUNET_SYSERR);
122  GNUNET_break (0);
123  break;
124 
126  h->cb (h->cb_cls,
127  h->name,
128  GNUNET_OK);
129  break;
130 
131  default:
132  GNUNET_break_op (0);
133  h->cb (h->cb_cls,
134  h->name,
135  GNUNET_SYSERR);
136  break;
137  }
139 }
void GNUNET_TESTBED_barrier_wait_cancel(struct GNUNET_TESTBED_BarrierWaitHandle *h)
Cancel a barrier wait handle.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
uint16_t status
status.
Definition: testbed.h:831
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
GNUNET_TESTBED_barrier_wait_cb cb
The barrier wait callback.
void * cb_cls
The closure for cb.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
#define GNUNET_log(kind,...)
Barrier initialised successfully.
char * name
The name of the barrier.
Here is the call graph for this function:

◆ mq_error_handler()

static void mq_error_handler ( void *  cls,
enum GNUNET_MQ_Error  error 
)
static

Generic error handler, called with the appropriate error code and the same closure specified at the creation of the message queue.

Not every message queue implementation supports an error handler.

Parameters
clsclosure with the struct GNUNET_TESTBED_BarrierWaitHandle *
errorerror code

Definition at line 151 of file testbed_api_barriers.c.

References GNUNET_TESTBED_BarrierWaitHandle::cb, GNUNET_TESTBED_BarrierWaitHandle::cb_cls, GNUNET_SYSERR, GNUNET_TESTBED_barrier_wait_cancel(), h, and GNUNET_TESTBED_BarrierWaitHandle::name.

Referenced by GNUNET_TESTBED_barrier_wait().

153 {
154  struct GNUNET_TESTBED_BarrierWaitHandle *h = cls;
155 
156  h->cb (h->cb_cls,
157  h->name,
158  GNUNET_SYSERR);
160 }
void GNUNET_TESTBED_barrier_wait_cancel(struct GNUNET_TESTBED_BarrierWaitHandle *h)
Cancel a barrier wait handle.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
GNUNET_TESTBED_barrier_wait_cb cb
The barrier wait callback.
void * cb_cls
The closure for cb.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
char * name
The name of the barrier.
Here is the call graph for this function:
Here is the caller graph for this function: