From: Florent Bruneau Date: Sun, 12 Oct 2008 09:44:38 +0000 (+0200) Subject: Don't reload when an asynchronous filter is running. X-Git-Url: http://git.madism.org/?a=commitdiff_plain;h=aecafec904f393ee0ab902272a947d8be5bec36f;p=apps%2Fpfixtools.git Don't reload when an asynchronous filter is running. Signed-off-by: Florent Bruneau --- diff --git a/postlicyd/filter.c b/postlicyd/filter.c index 7861af4..1ba19b5 100644 --- a/postlicyd/filter.c +++ b/postlicyd/filter.c @@ -63,6 +63,8 @@ static const filter_hook_t async_hook = { .filter_id = 0 }; +uint32_t filter_running = 0; + filter_type_t filter_register(const char *type, filter_constructor_t constructor, filter_destructor_t destructor, filter_runner_t runner, filter_context_constructor_t context_constructor, @@ -220,11 +222,13 @@ const filter_hook_t *filter_run(const filter_t *filter, const query_t *query, filter_context_t *context) { debug("running filter %s (%s)", filter->name, ftokens[filter->type]); + ++filter_running; filter_result_t res = runners[filter->type](filter, query, context); if (res == HTK_ASYNC) { context->current_filter = filter; } else { + --filter_running; context->current_filter = NULL; } @@ -319,6 +323,7 @@ void filter_post_async_result(filter_context_t *context, filter_result_t result) if (result == HTK_ASYNC) { return; } + --filter_running; hook = filter_hook_for_result(filter, result); async_handler(context, hook); } diff --git a/postlicyd/filter.h b/postlicyd/filter.h index 10effbc..dcbaecb 100644 --- a/postlicyd/filter.h +++ b/postlicyd/filter.h @@ -43,6 +43,7 @@ #include "query.h" #include "array.h" + typedef filter_token filter_type_t; typedef hook_token filter_result_t; typedef param_token filter_param_id_t; @@ -119,6 +120,10 @@ typedef void (*filter_context_destructor_t)(void*); typedef void (*filter_async_handler_t)(filter_context_t *context, const filter_hook_t *result); +/** Number of filter currently running. + */ +extern uint32_t filter_running; + /* Registration. */ diff --git a/postlicyd/main-postlicyd.c b/postlicyd/main-postlicyd.c index b71bebf..86db97a 100644 --- a/postlicyd/main-postlicyd.c +++ b/postlicyd/main-postlicyd.c @@ -73,6 +73,11 @@ static void query_stopper(void *data) static bool config_refresh(void *mconfig) { + if (filter_running > 0) { + sighup = true; + sleep(1); + return true; + } return config_reload(mconfig); } @@ -159,6 +164,10 @@ static bool policy_process(server_t *pcy, const config_t *mconfig) static int policy_run(server_t *pcy, void* vconfig) { + if (sighup) { + return 0; + } + int search_offs = MAX(0, (int)(pcy->ibuf.len - 1)); int nb = buffer_read(&pcy->ibuf, pcy->fd, -1); const char *eoq;