GNUnet  0.19.5
Testbed Logger service

Submit data to the testbed logger service. More...

Collaboration diagram for Testbed Logger service:

Typedefs

typedef void(* GNUNET_TESTBED_LOGGER_FlushCompletion) (void *cls, size_t size)
 Functions of this type are called to notify a successful transmission of the message to the logger service. More...
 

Functions

struct GNUNET_TESTBED_LOGGER_HandleGNUNET_TESTBED_LOGGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
 Connect to the testbed logger service. More...
 
void GNUNET_TESTBED_LOGGER_disconnect (struct GNUNET_TESTBED_LOGGER_Handle *h)
 Disconnect from the logger service. More...
 
void GNUNET_TESTBED_LOGGER_write (struct GNUNET_TESTBED_LOGGER_Handle *h, const void *data, size_t size)
 Send data to be logged to the logger service. More...
 
void GNUNET_TESTBED_LOGGER_flush (struct GNUNET_TESTBED_LOGGER_Handle *h, GNUNET_TESTBED_LOGGER_FlushCompletion cb, void *cb_cls)
 Flush the buffered data to the logger service. More...
 
void GNUNET_TESTBED_LOGGER_flush_cancel (struct GNUNET_TESTBED_LOGGER_Handle *h)
 Cancel notification upon flush. More...
 

Detailed Description

Submit data to the testbed logger service.

Typedef Documentation

◆ GNUNET_TESTBED_LOGGER_FlushCompletion

typedef void(* GNUNET_TESTBED_LOGGER_FlushCompletion) (void *cls, size_t size)

Functions of this type are called to notify a successful transmission of the message to the logger service.

Parameters
clsthe closure given to GNUNET_TESTBED_LOGGER_send()
sizethe amount of data sent

Definition at line 82 of file gnunet_testbed_logger_service.h.

Function Documentation

◆ GNUNET_TESTBED_LOGGER_connect()

struct GNUNET_TESTBED_LOGGER_Handle* GNUNET_TESTBED_LOGGER_connect ( const struct GNUNET_CONFIGURATION_Handle cfg)

Connect to the testbed logger service.

Parameters
cfgconfiguration to use
Returns
the handle which can be used for sending data to the service; NULL upon any error

Definition at line 223 of file testbed_logger_api.c.

224 {
226 
229  "testbed-logger",
230  NULL,
232  h);
233  if (NULL == h->mq)
234  {
235  GNUNET_free (h);
236  return NULL;
237  }
238  return h;
239 }
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
Definition: client.c:1057
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_MQ_Handle * mq
Our connection to the ARM service.
Definition: arm_api.c:107
Connection handle for the logger service.
static void mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
We got disconnected from the logger.

References cfg, GNUNET_CLIENT_connect(), GNUNET_free, GNUNET_new, h, GNUNET_ARM_Handle::mq, and mq_error_handler().

Here is the call graph for this function:

◆ GNUNET_TESTBED_LOGGER_disconnect()

void GNUNET_TESTBED_LOGGER_disconnect ( struct GNUNET_TESTBED_LOGGER_Handle h)

Disconnect from the logger service.

Also cancels any pending send handles.

Parameters
hthe logger handle
hthe logger handle

Definition at line 248 of file testbed_logger_api.c.

249 {
250  if (NULL != h->flush_completion_task)
251  {
252  GNUNET_SCHEDULER_cancel (h->flush_completion_task);
253  h->flush_completion_task = NULL;
254  }
255  if (0 != h->mq_len)
257  "Disconnect lost %u logger message[s]\n",
258  h->mq_len);
259  if (NULL != h->mq)
260  {
262  h->mq = NULL;
263  }
264  GNUNET_free (h);
265 }
@ GNUNET_ERROR_TYPE_WARNING
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:683
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:975
#define LOG(kind,...)
Generic logging shorthand.

References GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), h, LOG, and GNUNET_ARM_Handle::mq.

Here is the call graph for this function:

◆ GNUNET_TESTBED_LOGGER_write()

void GNUNET_TESTBED_LOGGER_write ( struct GNUNET_TESTBED_LOGGER_Handle h,
const void *  data,
size_t  size 
)

Send data to be logged to the logger service.

The data will be buffered and will be sent upon an explicit call to GNUNET_TESTBED_LOGGER_flush() or upon exceeding a threshold size.

Parameters
hthe logger handle
datathe data to send;
sizehow many bytes of data to send

Definition at line 278 of file testbed_logger_api.c.

281 {
282  if (NULL == h->mq)
283  return;
284  while (0 != size)
285  {
286  size_t fit_size = GNUNET_MIN (size,
287  BUFFER_SIZE - h->buse);
288  GNUNET_memcpy (&h->buf[h->buse],
289  data,
290  fit_size);
291  h->buse += fit_size;
292  data += fit_size;
293  size -= fit_size;
294  if (0 != size)
295  dispatch_buffer (h);
296  }
297 }
uint32_t data
The data value.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_MIN(a, b)
static unsigned int size
Size of the "table".
Definition: peer.c:68
#define BUFFER_SIZE
The size of the buffer we fill before sending out the message.
static void dispatch_buffer(struct GNUNET_TESTBED_LOGGER_Handle *h)
Send the buffered data to the service.

References BUFFER_SIZE, data, dispatch_buffer(), GNUNET_memcpy, GNUNET_MIN, h, GNUNET_ARM_Handle::mq, and size.

Referenced by handle_p2p_estimate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTBED_LOGGER_flush()

void GNUNET_TESTBED_LOGGER_flush ( struct GNUNET_TESTBED_LOGGER_Handle h,
GNUNET_TESTBED_LOGGER_FlushCompletion  cb,
void *  cb_cls 
)

Flush the buffered data to the logger service.

Parameters
hthe logger handle
cbthe callback to call after the data is flushed
cb_clsthe closure for cb

Definition at line 301 of file testbed_logger_api.c.

304 {
305  GNUNET_assert (NULL == h->cb);
306  h->cb = cb;
307  h->cb_cls = cb_cls;
308  if ((NULL == h->mq) ||
309  (0 == h->buse))
310  {
312  return;
313  }
314  dispatch_buffer (h);
315 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static void trigger_flush_notification(struct GNUNET_TESTBED_LOGGER_Handle *h)
Schedule the flush completion notification task.

References GNUNET_TESTBED_LOGGER_Handle::cb, GNUNET_TESTBED_LOGGER_Handle::cb_cls, dispatch_buffer(), GNUNET_assert, h, GNUNET_ARM_Handle::mq, and trigger_flush_notification().

Referenced by shutdown_task().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTBED_LOGGER_flush_cancel()

void GNUNET_TESTBED_LOGGER_flush_cancel ( struct GNUNET_TESTBED_LOGGER_Handle h)

Cancel notification upon flush.

Should only be used when the flush completion callback given to GNUNET_TESTBED_LOGGER_flush() is not already called.

Parameters
hthe logger handle

Definition at line 326 of file testbed_logger_api.c.

327 {
328  if (NULL != h->flush_completion_task)
329  {
330  GNUNET_SCHEDULER_cancel (h->flush_completion_task);
331  h->flush_completion_task = NULL;
332  }
333  h->cb = NULL;
334  h->cb_cls = NULL;
335 }

References GNUNET_SCHEDULER_cancel(), and h.

Here is the call graph for this function: