GNUnet 0.22.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 (GNUNET_OS_project_data_gnunet(), "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 GNUNET_mockup_done (void)
 
void __attribute__ ((destructor))
 

Variables

static int special_ret
 

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.

38{
39 struct GNUNET_SERVICE_Client *client = cls;
40
41 (void) message;
43 "Initiating shutdown as requested by client.\n");
46 /* ARM won't exponentially increase restart delay if we
47 * terminate normally. This changes the return code.
48 */
49 special_ret = 1;
50}
#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:2493
static int special_ret
Handle to a client that is connected to a service.
Definition: service.c:249

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 62 of file mockup-service.c.

65{
66 (void) cls;
67 (void) mq;
68 return c;
69}
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 80 of file mockup-service.c.

83{
84 (void) cls;
85 GNUNET_assert (c == internal_cls);
86}
#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 90 of file mockup-service.c.

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

References cfg, and service.

◆ GNUNET_SERVICE_MAIN()

GNUNET_SERVICE_MAIN ( GNUNET_OS_project_data_gnunet()  ,
"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.

◆ GNUNET_mockup_done()

void GNUNET_mockup_done ( void  )

◆ __attribute__()

void __attribute__ ( (destructor)  )

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

122{
123 _exit (special_ret);
124}

References special_ret.

Variable Documentation

◆ special_ret

int special_ret
static

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

Referenced by __attribute__(), and handle_stop().