GNUnet  0.10.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 84 of file testbed_api_barriers.c.

References GNUNET_OK.

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

◆ 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 103 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.

105 {
106  struct GNUNET_TESTBED_BarrierWaitHandle *h = cls;
107 
109  "Got barrier status %d\n",
110  (int) ntohs (msg->status));
111  switch (ntohs (msg->status))
112  {
114  h->cb (h->cb_cls,
115  h->name,
116  GNUNET_SYSERR);
117  break;
119  h->cb (h->cb_cls,
120  h->name,
121  GNUNET_SYSERR);
122  GNUNET_break (0);
123  break;
125  h->cb (h->cb_cls,
126  h->name,
127  GNUNET_OK);
128  break;
129  default:
130  GNUNET_break_op (0);
131  h->cb (h->cb_cls,
132  h->name,
133  GNUNET_SYSERR);
134  break;
135  }
137 }
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:78
#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:94
uint16_t status
status.
Definition: testbed.h:872
#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:79
#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 149 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().

151 {
152  struct GNUNET_TESTBED_BarrierWaitHandle *h = cls;
153 
154  h->cb (h->cb_cls,
155  h->name,
156  GNUNET_SYSERR);
158 }
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:94
GNUNET_TESTBED_barrier_wait_cb cb
The barrier wait callback.
void * cb_cls
The closure for cb.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
char * name
The name of the barrier.
Here is the call graph for this function:
Here is the caller graph for this function: