2 This file is part of GNUnet.
3 Copyright (C) 2007, 2008, 2009, 2016 GNUnet e.V.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
18 #include "gnunet_util_lib.h"
19 #include "gnunet_protocols.h"
22 static int special_ret = 0;
25 * Handler for STOP message.
27 * @param cls client identification of the client
28 * @param message the actual message
31 handle_stop (void *cls,
32 const struct GNUNET_MessageHeader *message)
34 struct GNUNET_SERVICE_Client *client = cls;
36 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
37 _("Initiating shutdown as requested by client.\n"));
38 GNUNET_SERVICE_client_persist (client);
39 GNUNET_SCHEDULER_shutdown ();
40 /* ARM won't exponentially increase restart delay if we
41 * terminate normally. This changes the return code.
48 * Callback called when a client connects to the service.
50 * @param cls closure for the service
51 * @param c the new client that connected to the service
52 * @param mq the message queue used to send messages to the client
56 client_connect_cb (void *cls,
57 struct GNUNET_SERVICE_Client *c,
58 struct GNUNET_MQ_Handle *mq)
65 * Callback called when a client disconnected from the service
67 * @param cls closure for the service
68 * @param c the client that disconnected
69 * @param internal_cls should be equal to @a c
72 client_disconnect_cb (void *cls,
73 struct GNUNET_SERVICE_Client *c,
76 GNUNET_assert (c == internal_cls);
82 const struct GNUNET_CONFIGURATION_Handle *cfg,
83 struct GNUNET_SERVICE_Handle *service)
90 * Define "main" method using service macro.
94 GNUNET_SERVICE_OPTION_NONE,
97 &client_disconnect_cb,
99 GNUNET_MQ_hd_fixed_size (stop,
100 GNUNET_MESSAGE_TYPE_ARM_STOP,
101 struct GNUNET_MessageHeader,
103 GNUNET_MQ_handler_end ());
107 * MINIMIZE heap size (way below 128k) since this process doesn't need much.
109 void __attribute__ ((destructor))
110 GNUNET_mockup_done ()