[PATCH 1/2] poller: allow safely remove pollers in any time

Aleksey Kuleshov rndfax at yandex.ru
Thu Mar 3 07:17:09 PST 2016


---
 common/poller.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/common/poller.c b/common/poller.c
index 32795b6..7cec5d4 100644
--- a/common/poller.c
+++ b/common/poller.c
@@ -15,6 +15,7 @@
 
 static LIST_HEAD(poller_list);
 static int poller_active;
+static struct poller_struct *next;
 
 int poller_register(struct poller_struct *poller)
 {
@@ -33,6 +34,10 @@ int poller_unregister(struct poller_struct *poller)
 		return -ENODEV;
 
 
+	if (&next->list == &poller->list) {
+		next = list_entry(next->list.next, struct poller_struct, list);
+	}
+
 	list_del(&poller->list);
 	poller->registered = 0;
 
@@ -107,14 +112,14 @@ int poller_async_unregister(struct poller_async *pa)
 
 void poller_call(void)
 {
-	struct poller_struct *poller, *tmp;
+	struct poller_struct *poller;
 
 	if (poller_active)
 		return;
 
 	poller_active = 1;
 
-	list_for_each_entry_safe(poller, tmp, &poller_list, list)
+	list_for_each_entry_safe(poller, next, &poller_list, list)
 		poller->func(poller);
 
 	poller_active = 0;
-- 
2.6.2




More information about the barebox mailing list