diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-10-07 14:06:00 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-10-07 14:06:00 +0000 |
commit | cb0b94bf09c45e690591140d4422b69e1db412cb (patch) | |
tree | 250b1d0fee40ee3400ba28c8f3c44901da89bb0a /src/include/gnunet_service_lib.h | |
parent | 551918714f3b0de77ef729e23bf80e1313d3c99d (diff) | |
download | gnunet-cb0b94bf09c45e690591140d4422b69e1db412cb.tar.gz gnunet-cb0b94bf09c45e690591140d4422b69e1db412cb.zip |
sketch new service start/stop API as needed for testbed
Diffstat (limited to 'src/include/gnunet_service_lib.h')
-rw-r--r-- | src/include/gnunet_service_lib.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/include/gnunet_service_lib.h b/src/include/gnunet_service_lib.h index 9c7009ef4..31abe0ab6 100644 --- a/src/include/gnunet_service_lib.h +++ b/src/include/gnunet_service_lib.h | |||
@@ -249,6 +249,60 @@ typedef void | |||
249 | 249 | ||
250 | 250 | ||
251 | /** | 251 | /** |
252 | * Low-level function to start a service if the scheduler | ||
253 | * is already running. Should only be used directly in | ||
254 | * special cases. | ||
255 | * | ||
256 | * The function will launch the service with the name @a service_name | ||
257 | * using the @a service_options to configure its shutdown | ||
258 | * behavior. When clients connect or disconnect, the respective | ||
259 | * @a connect_cb or @a disconnect_cb functions will be called. For | ||
260 | * messages received from the clients, the respective @a handlers will | ||
261 | * be invoked; for the closure of the handlers we use the return value | ||
262 | * from the @a connect_cb invocation of the respective client. | ||
263 | * | ||
264 | * Each handler MUST call #GNUNET_SERVICE_client_continue() after each | ||
265 | * message to receive further messages from this client. If | ||
266 | * #GNUNET_SERVICE_client_continue() is not called within a short | ||
267 | * time, a warning will be logged. If delays are expected, services | ||
268 | * should call #GNUNET_SERVICE_client_disable_continue_warning() to | ||
269 | * disable the warning. | ||
270 | * | ||
271 | * Clients sending invalid messages (based on @a handlers) will be | ||
272 | * dropped. Additionally, clients can be dropped at any time using | ||
273 | * #GNUNET_SERVICE_client_drop(). | ||
274 | * | ||
275 | * The service must be stopped using #GNUNET_SERVICE_stoP(). | ||
276 | * | ||
277 | * @param service_name name of the service to run | ||
278 | * @param cfg configuration to use | ||
279 | * @param connect_cb function to call whenever a client connects | ||
280 | * @param disconnect_cb function to call whenever a client disconnects | ||
281 | * @param cls closure argument for @a connect_cb and @a disconnect_cb | ||
282 | * @param handlers NULL-terminated array of message handlers for the service, | ||
283 | * the closure will be set to the value returned by | ||
284 | * the @a connect_cb for the respective connection | ||
285 | * @return NULL on error | ||
286 | */ | ||
287 | struct GNUNET_SERVICE_Handle * | ||
288 | GNUNET_SERVICE_starT (const char *service_name, | ||
289 | const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
290 | GNUNET_SERVICE_ConnectHandler connect_cb, | ||
291 | GNUNET_SERVICE_DisconnectHandler disconnect_cb, | ||
292 | void *cls, | ||
293 | const struct GNUNET_MQ_MessageHandler *handlers); | ||
294 | |||
295 | |||
296 | /** | ||
297 | * Stops a service that was started with #GNUNET_SERVICE_starT(). | ||
298 | * | ||
299 | * @param srv service to stop | ||
300 | */ | ||
301 | void | ||
302 | GNUNET_SERVICE_stoP (struct GNUNET_SERVICE_Handle *srv); | ||
303 | |||
304 | |||
305 | /** | ||
252 | * Creates the "main" function for a GNUnet service. You | 306 | * Creates the "main" function for a GNUnet service. You |
253 | * should almost always use the #GNUNET_SERVICE_MAIN macro | 307 | * should almost always use the #GNUNET_SERVICE_MAIN macro |
254 | * instead of calling this function directly (except | 308 | * instead of calling this function directly (except |