From f53d7284d19bb304db3a4275ca7e595c81e3dd33 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Tue, 22 Sep 2015 15:33:01 +0200 Subject: [PATCH] added new hook type for asynchronous path --- server/include/hooks.h | 1 + server/src/path.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/server/include/hooks.h b/server/include/hooks.h index a8994d726..8cc8094ae 100644 --- a/server/include/hooks.h +++ b/server/include/hooks.h @@ -54,6 +54,7 @@ enum hook_type { HOOK_PRE, /**< Called when a new packet of messages (samples) was received. */ HOOK_POST, /**< Called after each message (sample) of a packet was processed. */ HOOK_MSG, /**< Called for each message (sample) in a packet. */ + HOOK_ASYNC, /**< Called asynchronously with fixed rate (see path::rate). */ HOOK_PERIODIC, /**< Called periodically. Period is set by global 'stats' option in the configuration file. */ diff --git a/server/src/path.c b/server/src/path.c index 2143d68b3..7586bbb5b 100644 --- a/server/src/path.c +++ b/server/src/path.c @@ -54,8 +54,12 @@ static void * path_run_async(void *arg) struct path *p = arg; /* Block until 1/p->rate seconds elapsed */ - while (timerfd_wait(p->tfd)) + while (timerfd_wait(p->tfd)) { + if (path_run_hook(p, HOOK_ASYNC)) + continue; + path_write(p); + } return NULL; }