From d780b84e5f58fc5c6aeece3d27dff1bce76964a3 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Wed, 30 Aug 2017 13:31:20 +0200 Subject: [PATCH] api: properly initialise job queue for worker thread --- lib/api.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/api.c b/lib/api.c index c748c2f9c..84e8b5e7b 100644 --- a/lib/api.c +++ b/lib/api.c @@ -28,6 +28,7 @@ #include "web.h" #include "config.h" #include "assert.h" +#include "memory.h" #include "compat.h" /* Forward declarations */ @@ -225,9 +226,17 @@ int api_http_protocol_cb(struct lws *wsi, enum lws_callback_reasons reason, void int api_init(struct api *a, struct super_node *sn) { + int ret; + info("Initialize API sub-system"); - list_init(&a->sessions); + ret = list_init(&a->sessions); + if (ret) + return ret; + + ret = queue_signalled_init(&a->pending, 1024, &memtype_heap, 0); + if (ret) + return ret; a->super_node = sn; a->state = STATE_INITIALIZED; @@ -237,7 +246,13 @@ int api_init(struct api *a, struct super_node *sn) int api_destroy(struct api *a) { + int ret; + assert(a->state != STATE_STARTED); + + ret = queue_signalled_destroy(&a->pending); + if (ret) + return ret; a->state = STATE_DESTROYED;