diff options
-rw-r--r-- | src/include/gnunet_service_lib.h | 7 | ||||
-rw-r--r-- | src/util/service.c | 23 |
2 files changed, 28 insertions, 2 deletions
diff --git a/src/include/gnunet_service_lib.h b/src/include/gnunet_service_lib.h index 6109d6e5e..49f9cd68b 100644 --- a/src/include/gnunet_service_lib.h +++ b/src/include/gnunet_service_lib.h | |||
@@ -403,6 +403,13 @@ GNUNET_SERVICE_register_ ( | |||
403 | #endif | 403 | #endif |
404 | 404 | ||
405 | /** | 405 | /** |
406 | * Run the mainloop in a monolithic libgnunet. | ||
407 | * Must be called such that services are actually launched. | ||
408 | */ | ||
409 | void | ||
410 | GNUNET_SERVICE_main (void); | ||
411 | |||
412 | /** | ||
406 | * Suspend accepting connections from the listen socket temporarily. | 413 | * Suspend accepting connections from the listen socket temporarily. |
407 | * Resume activity using #GNUNET_SERVICE_resume. | 414 | * Resume activity using #GNUNET_SERVICE_resume. |
408 | * | 415 | * |
diff --git a/src/util/service.c b/src/util/service.c index 194251af2..baa8a3378 100644 --- a/src/util/service.c +++ b/src/util/service.c | |||
@@ -2143,6 +2143,8 @@ struct ServiceHandleList | |||
2143 | 2143 | ||
2144 | struct GNUNET_SERVICE_Handle *sh; | 2144 | struct GNUNET_SERVICE_Handle *sh; |
2145 | }; | 2145 | }; |
2146 | static struct ServiceHandleList *hll_head = NULL; | ||
2147 | static struct ServiceHandleList *hll_tail = NULL; | ||
2146 | 2148 | ||
2147 | int | 2149 | int |
2148 | GNUNET_SERVICE_register_ (const char *service_name, | 2150 | GNUNET_SERVICE_register_ (const char *service_name, |
@@ -2153,8 +2155,6 @@ GNUNET_SERVICE_register_ (const char *service_name, | |||
2153 | void *cls, | 2155 | void *cls, |
2154 | const struct GNUNET_MQ_MessageHandler *handlers) | 2156 | const struct GNUNET_MQ_MessageHandler *handlers) |
2155 | { | 2157 | { |
2156 | static struct ServiceHandleList *hll_head = NULL; | ||
2157 | static struct ServiceHandleList *hll_tail = NULL; | ||
2158 | struct ServiceHandleList *hle; | 2158 | struct ServiceHandleList *hle; |
2159 | struct GNUNET_CONFIGURATION_Handle *cfg; | 2159 | struct GNUNET_CONFIGURATION_Handle *cfg; |
2160 | struct GNUNET_SERVICE_Handle *sh = GNUNET_new (struct GNUNET_SERVICE_Handle); | 2160 | struct GNUNET_SERVICE_Handle *sh = GNUNET_new (struct GNUNET_SERVICE_Handle); |
@@ -2233,6 +2233,25 @@ fail: | |||
2233 | return err ? GNUNET_SYSERR : sh->ret; | 2233 | return err ? GNUNET_SYSERR : sh->ret; |
2234 | } | 2234 | } |
2235 | 2235 | ||
2236 | static void | ||
2237 | launch_registered_services (void *cls) | ||
2238 | { | ||
2239 | (void) cls; | ||
2240 | struct ServiceHandleList *shl; | ||
2241 | |||
2242 | for (shl = hll_head; NULL != shl; shl = shl->next) | ||
2243 | { | ||
2244 | GNUNET_SCHEDULER_add_now (&service_main, shl->sh); | ||
2245 | } | ||
2246 | |||
2247 | // FIXME sometime we need to cleanup the shl. Shutdown task? | ||
2248 | } | ||
2249 | |||
2250 | void | ||
2251 | GNUNET_SERVICE_main (void) | ||
2252 | { | ||
2253 | GNUNET_SCHEDULER_run (&launch_registered_services, NULL); | ||
2254 | } | ||
2236 | 2255 | ||
2237 | /** | 2256 | /** |
2238 | * Suspend accepting connections from the listen socket temporarily. | 2257 | * Suspend accepting connections from the listen socket temporarily. |