GNUnet  0.10.x
Functions | Variables
mockup-service.c File Reference
#include <stdlib.h>
#include "platform.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.

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

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 }
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:517
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
Handle to a client that is connected to a service.
Definition: service.c:246
#define GNUNET_log(kind,...)
static int special_ret
void GNUNET_SERVICE_client_persist(struct GNUNET_SERVICE_Client *c)
Set the persist option on this client.
Definition: service.c:2411
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.

Referenced by run().

64 {
65  (void)cls;
66  (void)mq;
67  return c;
68 }
Here is the caller graph for this function:

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

References GNUNET_assert.

Referenced by run().

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

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

References client_connect_cb(), client_disconnect_cb(), GNUNET_MESSAGE_TYPE_ARM_STOP, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_SERVICE_MAIN(), and GNUNET_SERVICE_OPTION_NONE.

92 {
93  (void)cls;
94  (void)cfg;
95  (void)service;
96  /* nothing to do */
97 }
Here is the call graph for this function:

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

Referenced by run().

Here is the caller graph for this function:

◆ __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.

References special_ret.

120 {
121  _exit(special_ret);
122 }
static int 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().