From efd9601e15b030317eeda1618985bac34ebfcb9a Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Tue, 12 Jan 2016 13:50:21 +0100 Subject: poller: Fix async poller The async poller does not work as expected since it can happen that the async poller is removed from the list of pollers while we are iterating over the list. Even list_for_each_entry_safe does not help here since we may remove the next list element, but list_for_each_entry_safe only allows to remove the current list element. Rework the async poller so that it is registered with the poller framework on registration and then is only marked as active with poller_call_async(). This way we do not have to do list manipulations while running the pollers. Signed-off-by: Sascha Hauer --- include/poller.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include/poller.h') diff --git a/include/poller.h b/include/poller.h index cda5b5774b..35a2271d69 100644 --- a/include/poller.h +++ b/include/poller.h @@ -26,8 +26,12 @@ struct poller_async { void (*fn)(void *); void *ctx; uint64_t end; + int active; }; +int poller_async_register(struct poller_async *pa); +int poller_async_unregister(struct poller_async *pa); + int poller_call_async(struct poller_async *pa, uint64_t delay_ns, void (*fn)(void *), void *ctx); int poller_async_cancel(struct poller_async *pa); -- cgit v1.2.3