.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,
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;
}
if (result == HTK_ASYNC) {
return;
}
+ --filter_running;
hook = filter_hook_for_result(filter, result);
async_handler(context, hook);
}
#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;
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.
*/
static bool config_refresh(void *mconfig)
{
+ if (filter_running > 0) {
+ sighup = true;
+ sleep(1);
+ return true;
+ }
return config_reload(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;