GNUnet  0.10.x
Macros | Functions | Variables
gnunet-service-test-barriers.c File Reference

Daemon acting as a service for testing testbed barriers. More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testbed_service.h"
#include "test_testbed_api_barriers.h"
Include dependency graph for gnunet-service-test-barriers.c:

Go to the source code of this file.

Macros

#define LOG(type, ...)   GNUNET_log(type, __VA_ARGS__);
 logging short hand More...
 

Functions

static void do_shutdown (void *cls)
 Dummy task callback to keep us running forever. More...
 
static void barrier_wait_cb (void *cls, const char *name, int status)
 Functions of this type are to be given as acallback argumetn to GNUNET_TESTBED_barrier_wait(). More...
 
static void do_wait (void *cls)
 Task to wait for the barrier. More...
 
static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *config)
 Main run function. More...
 
int main (int argc, char **argv)
 Main. More...
 

Variables

static struct GNUNET_TESTBED_BarrierWaitHandlewh
 Our barrier wait handle. More...
 
static struct GNUNET_SCHEDULER_Tasktt
 

Detailed Description

Daemon acting as a service for testing testbed barriers.

It is started as a peer service and waits for a barrier to be crossed.

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

Definition in file gnunet-service-test-barriers.c.

Macro Definition Documentation

◆ LOG

#define LOG (   type,
  ... 
)    GNUNET_log(type, __VA_ARGS__);

logging short hand

Definition at line 36 of file gnunet-service-test-barriers.c.

Function Documentation

◆ do_shutdown()

static void do_shutdown ( void *  cls)
static

Dummy task callback to keep us running forever.

Parameters
clsNULL

Definition at line 53 of file gnunet-service-test-barriers.c.

References GNUNET_SCHEDULER_cancel(), and GNUNET_TESTBED_barrier_wait_cancel().

Referenced by run().

54 {
55  if (NULL != wh)
56  {
58  wh = NULL;
59  }
60  if (NULL != tt)
61  {
63  tt = NULL;
64  }
65 }
void GNUNET_TESTBED_barrier_wait_cancel(struct GNUNET_TESTBED_BarrierWaitHandle *h)
Cancel a barrier wait handle.
static struct GNUNET_SCHEDULER_Task * tt
static struct GNUNET_TESTBED_BarrierWaitHandle * wh
Our barrier wait handle.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:956
Here is the call graph for this function:
Here is the caller graph for this function:

◆ barrier_wait_cb()

static void barrier_wait_cb ( void *  cls,
const char *  name,
int  status 
)
static

Functions of this type are to be given as acallback argumetn to GNUNET_TESTBED_barrier_wait().

The callback will be called when the barrier corresponding given in GNUNET_TESTBED_barrier_wait() is crossed or cancelled.

Parameters
clsNULL
namethe barrier name
statusGNUNET_SYSERR in case of error while waiting for the barrier; GNUNET_OK if the barrier is crossed

Definition at line 79 of file gnunet-service-test-barriers.c.

References GNUNET_break, and GNUNET_OK.

Referenced by do_wait().

82 {
83  GNUNET_break(NULL == cls);
84  wh = NULL;
86 }
#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...
uint16_t status
See PRISM_STATUS_*-constants.
static struct GNUNET_TESTBED_BarrierWaitHandle * wh
Our barrier wait handle.
Here is the caller graph for this function:

◆ do_wait()

static void do_wait ( void *  cls)
static

Task to wait for the barrier.

Parameters
clsNULL
Returns

Definition at line 96 of file gnunet-service-test-barriers.c.

References barrier_wait_cb(), GNUNET_break, and GNUNET_TESTBED_barrier_wait().

Referenced by run().

97 {
98  tt = NULL;
99  wh = GNUNET_TESTBED_barrier_wait(TEST_BARRIER_NAME,
101  NULL);
102  GNUNET_break(NULL != wh);
103 }
static void barrier_wait_cb(void *cls, const char *name, int status)
Functions of this type are to be given as acallback argumetn to GNUNET_TESTBED_barrier_wait().
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct GNUNET_SCHEDULER_Task * tt
struct GNUNET_TESTBED_BarrierWaitHandle * GNUNET_TESTBED_barrier_wait(const char *name, GNUNET_TESTBED_barrier_wait_cb cb, void *cls)
Wait for a barrier to be crossed.
static struct GNUNET_TESTBED_BarrierWaitHandle * wh
Our barrier wait handle.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ run()

static void run ( void *  cls,
char *const *  args,
const char *  cfgfile,
const struct GNUNET_CONFIGURATION_Handle config 
)
static

Main run function.

Parameters
clsNULL
argsarguments passed to GNUNET_PROGRAM_run
cfgfilethe path to configuration file
configthe configuration file handle

Definition at line 115 of file gnunet-service-test-barriers.c.

References do_shutdown(), do_wait(), GNUNET_CRYPTO_QUALITY_NONCE, GNUNET_CRYPTO_random_u32(), GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_TIME_relative_multiply(), and GNUNET_TIME_UNIT_SECONDS.

Referenced by main().

119 {
120  unsigned int rsec;
121 
123  10);
125  rsec),
126  &do_wait,
127  NULL);
129 }
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received, or when GNUNET_SCHEDULER_shutdown() is being invoked.
Definition: scheduler.c:1284
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
#define GNUNET_TIME_UNIT_SECONDS
One second.
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.
Definition: scheduler.c:1237
Randomness for IVs etc.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
Definition: time.c:440
static struct GNUNET_SCHEDULER_Task * tt
static void do_shutdown(void *cls)
Dummy task callback to keep us running forever.
static void do_wait(void *cls)
Task to wait for the barrier.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Main.

Definition at line 137 of file gnunet-service-test-barriers.c.

References GNUNET_GETOPT_OPTION_END, GNUNET_PROGRAM_run(), ret, and run().

138 {
141  };
142  int ret;
143 
144  ret =
145  GNUNET_PROGRAM_run(argc, argv,
146  "test-barriers",
147  "nohelp",
148  options,
149  &run,
150  NULL);
151  return ret;
152 }
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
Definition of a command line option.
static int ret
Final status code.
Definition: gnunet-arm.c:89
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
int GNUNET_PROGRAM_run(int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration, parse options).
Definition: program.c:367
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *config)
Main run function.
Here is the call graph for this function:

Variable Documentation

◆ wh

◆ tt

struct GNUNET_SCHEDULER_Task* tt
static

Definition at line 44 of file gnunet-service-test-barriers.c.