GNUnet  0.20.0
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 argument 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.

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

References GNUNET_SCHEDULER_cancel(), GNUNET_TESTBED_barrier_wait_cancel(), tt, and wh.

Referenced by run().

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 argument 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.

82 {
83  GNUNET_break (NULL == cls);
84  wh = NULL;
86 }
uint16_t status
See PRISM_STATUS_*-constants.
@ GNUNET_OK
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.

References GNUNET_break, GNUNET_OK, status, and wh.

Referenced by do_wait().

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.

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 argument to GNUNET_TESTBED_barrier_wait().
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.

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

Referenced by run().

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.

119 {
120  unsigned int rsec;
121 
123  10);
126  rsec),
127  &do_wait,
128  NULL);
130 }
static void do_wait(void *cls)
Task to wait for the barrier.
static void do_shutdown(void *cls)
Dummy task callback to keep us running forever.
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
@ GNUNET_CRYPTO_QUALITY_NONCE
Randomness for IVs etc.
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,...
Definition: scheduler.c:1334
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:1272
#define GNUNET_TIME_UNIT_SECONDS
One second.
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:484

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(), GNUNET_TIME_UNIT_SECONDS, and tt.

Referenced by main().

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.

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 GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *config)
Main run function.
enum GNUNET_GenericReturnValue 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,...
Definition: program.c:400
Definition of a command line option.

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

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.

Referenced by do_shutdown(), do_wait(), and run().