summaryrefslogtreecommitdiff
path: root/lib/event.c
diff options
context:
space:
mode:
authorMark Stapp <mjs@labn.net>2023-07-11 16:03:38 -0400
committerMark Stapp <mjs@labn.net>2023-07-25 10:17:48 -0400
commitadca5c22c573f17b09b96a0994953c8f643fd301 (patch)
tree84894373c496a0279b3fc5eb944803c53bcb6c34 /lib/event.c
parent9e32b73634a8bbe893f2425ee89ee27651d93408 (diff)
* : include event ptr in event_execute api
Include an event ptr-to-ptr in the event_execute() api call, like the various schedule api calls. This allows the execute() api to cancel an existing scheduled task if that task is being executed inline. Signed-off-by: Mark Stapp <mjs@labn.net>
Diffstat (limited to 'lib/event.c')
-rw-r--r--lib/event.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/event.c b/lib/event.c
index a8eb89f48d..b971bd70e6 100644
--- a/lib/event.c
+++ b/lib/event.c
@@ -1491,9 +1491,9 @@ void event_cancel(struct event **thread)
cr->thread = *thread;
listnode_add(master->cancel_req, cr);
do_event_cancel(master);
- }
- *thread = NULL;
+ *thread = NULL;
+ }
}
/**
@@ -2066,10 +2066,15 @@ void event_call(struct event *thread)
/* Execute thread */
void _event_execute(const struct xref_eventsched *xref, struct event_loop *m,
- void (*func)(struct event *), void *arg, int val)
+ void (*func)(struct event *), void *arg, int val,
+ struct event **eref)
{
struct event *thread;
+ /* Cancel existing scheduled task TODO -- nice to do in 1 lock cycle */
+ if (eref)
+ event_cancel(eref);
+
/* Get or allocate new thread to execute. */
frr_with_mutex (&m->mtx) {
thread = thread_get(m, EVENT_EVENT, func, arg, xref);