diff options
-rw-r--r-- | src/afb-hreq.c | 4 | ||||
-rw-r--r-- | src/afb-hsrv.c | 4 | ||||
-rw-r--r-- | src/afb-hsrv.h | 1 | ||||
-rw-r--r-- | src/afb-session.c | 2 | ||||
-rw-r--r-- | src/afb-supervision.c | 17 | ||||
-rw-r--r-- | src/afb-supervision.h | 5 | ||||
-rw-r--r-- | src/afb-trace.c | 2 | ||||
-rw-r--r-- | src/main-afb-daemon.c | 2 |
8 files changed, 23 insertions, 14 deletions
diff --git a/src/afb-hreq.c b/src/afb-hreq.c index fa16565a..54c097e0 100644 --- a/src/afb-hreq.c +++ b/src/afb-hreq.c @@ -36,6 +36,7 @@ #include "afb-msg-json.h" #include "afb-context.h" #include "afb-hreq.h" +#include "afb-hsrv.h" #include "afb-session.h" #include "afb-cred.h" #include "verbose.h" @@ -168,10 +169,9 @@ static void afb_hreq_reply_v(struct afb_hreq *hreq, unsigned status, struct MHD_ hreq->replied = 1; if (hreq->suspended != 0) { - extern void run_micro_httpd(struct afb_hsrv *hsrv); MHD_resume_connection (hreq->connection); hreq->suspended = 0; - run_micro_httpd(hreq->hsrv); + afb_hsrv_run(hreq->hsrv); } } diff --git a/src/afb-hsrv.c b/src/afb-hsrv.c index 3bca5839..efa74f4b 100644 --- a/src/afb-hsrv.c +++ b/src/afb-hsrv.c @@ -263,7 +263,7 @@ static void do_run(int signum, void *arg) fdev_set_events(hsrv->fdev, EPOLLIN); } -void run_micro_httpd(struct afb_hsrv *hsrv) +void afb_hsrv_run(struct afb_hsrv *hsrv) { fdev_set_events(hsrv->fdev, 0); if (jobs_queue(hsrv, 0, do_run, hsrv) < 0) @@ -272,7 +272,7 @@ void run_micro_httpd(struct afb_hsrv *hsrv) static void listen_callback(void *hsrv, uint32_t revents, struct fdev *fdev) { - run_micro_httpd(hsrv); + afb_hsrv_run(hsrv); } static int new_client_handler(void *cls, const struct sockaddr *addr, socklen_t addrlen) diff --git a/src/afb-hsrv.h b/src/afb-hsrv.h index c03894aa..f72fc3b0 100644 --- a/src/afb-hsrv.h +++ b/src/afb-hsrv.h @@ -32,3 +32,4 @@ extern int afb_hsrv_add_alias(struct afb_hsrv *hsrv, const char *prefix, int dir extern int afb_hsrv_add_alias_root(struct afb_hsrv *hsrv, const char *prefix, struct locale_root *root, int priority, int relax); extern int afb_hsrv_add_handler(struct afb_hsrv *hsrv, const char *prefix, int (*handler) (struct afb_hreq *, void *), void *data, int priority); +extern void afb_hsrv_run(struct afb_hsrv *hsrv); diff --git a/src/afb-session.c b/src/afb-session.c index 16fc69bb..adfed2ad 100644 --- a/src/afb-session.c +++ b/src/afb-session.c @@ -59,7 +59,7 @@ struct cookie struct afb_session { struct afb_session *next; /**< link to the next */ - unsigned refcount; /**< external reference count of the session */ + unsigned refcount; /**< count of reference to the session */ int timeout; /**< timeout of the session */ time_t expiration; /**< expiration time of the token */ pthread_mutex_t mutex; /**< mutex of the session */ diff --git a/src/afb-supervision.c b/src/afb-supervision.c index 84c302f6..2482a082 100644 --- a/src/afb-supervision.c +++ b/src/afb-supervision.c @@ -51,8 +51,6 @@ #include "wrap-json.h" #include "jobs.h" -extern struct afb_config *main_config; - /* api and apiset name */ static const char supervision_apiname[] = AFS_SUPERVISION_APINAME; static const char supervisor_apiname[] = AFS_SUPERVISOR_APINAME; @@ -64,7 +62,10 @@ static const char supervisor_socket_path[] = AFS_SUPERVISION_SOCKET; static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; /* the standard apiset */ -extern struct afb_apiset *main_apiset; +static struct { + struct afb_apiset *apiset; + struct afb_config *config; +} global; /* the supervision apiset (not exported) */ static struct afb_apiset *supervision_apiset; @@ -237,7 +238,7 @@ static void on_sighup(int signum) /** * initialize the supervision */ -int afb_supervision_init() +int afb_supervision_init(struct afb_apiset *apiset, struct afb_config *config) { int rc; struct sigaction sa; @@ -263,6 +264,10 @@ int afb_supervision_init() return rc; } + /* init the globals */ + global.apiset = apiset; + global.config = config; + /* get SIGHUP */ memset(&sa, 0, sizeof sa); sa.sa_handler = on_sighup; @@ -346,7 +351,7 @@ static void on_supervision_call(void *closure, struct afb_xreq *xreq) afb_xreq_reply(xreq, list, NULL, NULL); break; case Config: - afb_xreq_reply(xreq, afb_config_json(main_config), NULL, NULL); + afb_xreq_reply(xreq, afb_config_json(global.config), NULL, NULL); break; case Trace: if (!trace) @@ -372,7 +377,7 @@ static void on_supervision_call(void *closure, struct afb_xreq *xreq) if (wrap_json_unpack(args, "{ss ss s?o*}", "api", &api, "verb", &verb, "args", &sub)) afb_xreq_reply(xreq, NULL, "error", "bad request"); else { - xapi = afb_apiset_lookup_started(main_apiset, api, 1); + xapi = afb_apiset_lookup_started(global.apiset, api, 1); if (!xapi) afb_xreq_reply_unknown_api(xreq); else { diff --git a/src/afb-supervision.h b/src/afb-supervision.h index 5ffd432e..0acf7f6e 100644 --- a/src/afb-supervision.h +++ b/src/afb-supervision.h @@ -18,4 +18,7 @@ #pragma once -extern int afb_supervision_init(); +struct afb_apiset; +struct afb_config; + +extern int afb_supervision_init(struct afb_apiset *apiset, struct afb_config *config); diff --git a/src/afb-trace.c b/src/afb-trace.c index 0e285e14..dd6e863c 100644 --- a/src/afb-trace.c +++ b/src/afb-trace.c @@ -1739,7 +1739,7 @@ int afb_trace_add(afb_req_t req, struct json_object *args, struct afb_trace *tra } /* drop traces */ -extern int afb_trace_drop(afb_req_t req, struct json_object *args, struct afb_trace *trace) +int afb_trace_drop(afb_req_t req, struct json_object *args, struct afb_trace *trace) { int rc; struct context context; diff --git a/src/main-afb-daemon.c b/src/main-afb-daemon.c index 4be6cc53..75d51901 100644 --- a/src/main-afb-daemon.c +++ b/src/main-afb-daemon.c @@ -580,7 +580,7 @@ static void start(int signum, void *arg) goto error; } #if defined(WITH_SUPERVISION) - if (afb_supervision_init() < 0) { + if (afb_supervision_init(main_apiset, main_config) < 0) { ERROR("failed to setup supervision"); goto error; } |