GNUnet 0.21.2
mockup-service.c File Reference
#include "platform.h"
#include <stdlib.h>
#include "gnunet_util_lib.h"
#include "gnunet_protocols.h"
Include dependency graph for mockup-service.c:

Go to the source code of this file.

Functions

static void handle_stop (void *cls, const struct GNUNET_MessageHeader *message)
 Handler for STOP message. More...
 
static void * client_connect_cb (void *cls, struct GNUNET_SERVICE_Client *c, struct GNUNET_MQ_Handle *mq)
 Callback called when a client connects to the service. More...
 
static void client_disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *c, void *internal_cls)
 Callback called when a client disconnected from the service. More...
 
static void run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_SERVICE_Handle *service)
 
 GNUNET_SERVICE_MAIN ("do-nothing", GNUNET_SERVICE_OPTION_NONE, &run, &client_connect_cb, &client_disconnect_cb, NULL, GNUNET_MQ_hd_fixed_size(stop, GNUNET_MESSAGE_TYPE_ARM_STOP, struct GNUNET_MessageHeader, NULL), GNUNET_MQ_handler_end())
 Define "main" method using service macro. More...
 
void __attribute__ ((destructor))
 MINIMIZE heap size (way below 128k) since this process doesn't need much. More...
 

Variables

static int special_ret = 0
 

Function Documentation

◆ handle_stop()

static void handle_stop ( void *  cls,
const struct GNUNET_MessageHeader message 
)
static

Handler for STOP message.

Parameters
clsclient identification of the client
messagethe actual message

Definition at line 36 of file mockup-service.c.

37{
38 struct GNUNET_SERVICE_Client *client = cls;
39
40 (void) message;
42 _ ("Initiating shutdown as requested by client.\n"));
45 /* ARM won't exponentially increase restart delay if we
46 * terminate normally. This changes the return code.
47 */
48 special_ret = 1;
49}
#define GNUNET_log(kind,...)
@ GNUNET_ERROR_TYPE_INFO
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:567
void GNUNET_SERVICE_client_persist(struct GNUNET_SERVICE_Client *c)
Set the persist option on this client.
Definition: service.c:2559
static int special_ret
#define _(String)
GNU gettext support macro.
Definition: platform.h:178
Handle to a client that is connected to a service.
Definition: service.c:246

References _, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_SCHEDULER_shutdown(), GNUNET_SERVICE_client_persist(), and special_ret.

Here is the call graph for this function:

◆ client_connect_cb()

static void * client_connect_cb ( void *  cls,
struct GNUNET_SERVICE_Client c,
struct GNUNET_MQ_Handle mq 
)
static

Callback called when a client connects to the service.

Parameters
clsclosure for the service
cthe new client that connected to the service
mqthe message queue used to send messages to the client
Returns
c

Definition at line 61 of file mockup-service.c.

64{
65 (void) cls;
66 (void) mq;
67 return c;
68}
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5

References mq.

◆ client_disconnect_cb()

static void client_disconnect_cb ( void *  cls,
struct GNUNET_SERVICE_Client c,
void *  internal_cls 
)
static

Callback called when a client disconnected from the service.

Parameters
clsclosure for the service
cthe client that disconnected
internal_clsshould be equal to c

Definition at line 79 of file mockup-service.c.

82{
83 (void) cls;
84 GNUNET_assert (c == internal_cls);
85}
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.

References GNUNET_assert.

◆ run()

static void run ( void *  cls,
const struct GNUNET_CONFIGURATION_Handle cfg,
struct GNUNET_SERVICE_Handle service 
)
static

Definition at line 89 of file mockup-service.c.

92{
93 (void) cls;
94 (void) cfg;
95 (void) service;
96 /* nothing to do */
97}
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:109
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.

References cfg, and service.

◆ GNUNET_SERVICE_MAIN()

GNUNET_SERVICE_MAIN ( "do-nothing"  ,
GNUNET_SERVICE_OPTION_NONE  ,
run,
client_connect_cb,
client_disconnect_cb,
NULL  ,
GNUNET_MQ_hd_fixed_size(stop, GNUNET_MESSAGE_TYPE_ARM_STOP, struct GNUNET_MessageHeader, NULL)  ,
GNUNET_MQ_handler_end()   
)

Define "main" method using service macro.

◆ __attribute__()

void __attribute__ ( (destructor)  )

MINIMIZE heap size (way below 128k) since this process doesn't need much.

Definition at line 119 of file mockup-service.c.

121{
122 _exit (special_ret);
123}

References special_ret.

Variable Documentation

◆ special_ret

int special_ret = 0
static

Definition at line 27 of file mockup-service.c.

Referenced by __attribute__(), and handle_stop().