aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-10-07 14:06:00 +0000
committerChristian Grothoff <christian@grothoff.org>2016-10-07 14:06:00 +0000
commitcb0b94bf09c45e690591140d4422b69e1db412cb (patch)
tree250b1d0fee40ee3400ba28c8f3c44901da89bb0a /src
parent551918714f3b0de77ef729e23bf80e1313d3c99d (diff)
downloadgnunet-cb0b94bf09c45e690591140d4422b69e1db412cb.tar.gz
gnunet-cb0b94bf09c45e690591140d4422b69e1db412cb.zip
sketch new service start/stop API as needed for testbed
Diffstat (limited to 'src')
-rw-r--r--src/include/gnunet_service_lib.h54
-rw-r--r--src/util/service_new.c61
2 files changed, 115 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 */
287struct GNUNET_SERVICE_Handle *
288GNUNET_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 */
301void
302GNUNET_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
diff --git a/src/util/service_new.c b/src/util/service_new.c
index 9981ae4c6..cf871eb89 100644
--- a/src/util/service_new.c
+++ b/src/util/service_new.c
@@ -1536,6 +1536,67 @@ detach_terminal (struct GNUNET_SERVICE_Handle *sh)
1536 1536
1537 1537
1538/** 1538/**
1539 * Low-level function to start a service if the scheduler
1540 * is already running. Should only be used directly in
1541 * special cases.
1542 *
1543 * The function will launch the service with the name @a service_name
1544 * using the @a service_options to configure its shutdown
1545 * behavior. When clients connect or disconnect, the respective
1546 * @a connect_cb or @a disconnect_cb functions will be called. For
1547 * messages received from the clients, the respective @a handlers will
1548 * be invoked; for the closure of the handlers we use the return value
1549 * from the @a connect_cb invocation of the respective client.
1550 *
1551 * Each handler MUST call #GNUNET_SERVICE_client_continue() after each
1552 * message to receive further messages from this client. If
1553 * #GNUNET_SERVICE_client_continue() is not called within a short
1554 * time, a warning will be logged. If delays are expected, services
1555 * should call #GNUNET_SERVICE_client_disable_continue_warning() to
1556 * disable the warning.
1557 *
1558 * Clients sending invalid messages (based on @a handlers) will be
1559 * dropped. Additionally, clients can be dropped at any time using
1560 * #GNUNET_SERVICE_client_drop().
1561 *
1562 * The service must be stopped using #GNUNET_SERVICE_stoP().
1563 *
1564 * @param service_name name of the service to run
1565 * @param cfg configuration to use
1566 * @param connect_cb function to call whenever a client connects
1567 * @param disconnect_cb function to call whenever a client disconnects
1568 * @param cls closure argument for @a connect_cb and @a disconnect_cb
1569 * @param handlers NULL-terminated array of message handlers for the service,
1570 * the closure will be set to the value returned by
1571 * the @a connect_cb for the respective connection
1572 * @return NULL on error
1573 */
1574struct GNUNET_SERVICE_Handle *
1575GNUNET_SERVICE_starT (const char *service_name,
1576 const struct GNUNET_CONFIGURATION_Handle *cfg,
1577 GNUNET_SERVICE_ConnectHandler connect_cb,
1578 GNUNET_SERVICE_DisconnectHandler disconnect_cb,
1579 void *cls,
1580 const struct GNUNET_MQ_MessageHandler *handlers)
1581{
1582 GNUNET_break (0); // FIXME: not implemented
1583 return NULL;
1584}
1585
1586
1587/**
1588 * Stops a service that was started with #GNUNET_SERVICE_starT().
1589 *
1590 * @param srv service to stop
1591 */
1592void
1593GNUNET_SERVICE_stoP (struct GNUNET_SERVICE_Handle *srv)
1594{
1595 GNUNET_assert (0); // FIXME: not implemented
1596}
1597
1598
1599/**
1539 * Creates the "main" function for a GNUnet service. You 1600 * Creates the "main" function for a GNUnet service. You
1540 * should almost always use the #GNUNET_SERVICE_MAIN macro 1601 * should almost always use the #GNUNET_SERVICE_MAIN macro
1541 * instead of calling this function directly (except 1602 * instead of calling this function directly (except