From 59e603d00947dfa0ee068c6ec15742fa75c44a27 Mon Sep 17 00:00:00 2001 From: "Sven M. Hallberg" Date: Thu, 11 Sep 2014 21:53:02 +0200 Subject: [PATCH] process change events in the order they are received --- include/catta/llist.h | 11 +++++++++++ src/iface-windows.c | 3 +-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/catta/llist.h b/include/catta/llist.h index a2321b6..59a7274 100644 --- a/include/catta/llist.h +++ b/include/catta/llist.h @@ -55,6 +55,17 @@ CATTA_C_DECL_BEGIN *_head = _item; \ } while (0) +/** Append an item to the list */ +#define CATTA_LLIST_APPEND(t,name,head,item) do { \ + t **_cur = &(head), *_prev, *_item = (item); \ + assert(_item); \ + while ((_prev = *_cur)) \ + _cur = &_prev->name##_next; \ + _item->name##_prev = _prev; \ + _item->name##_next = NULL; \ + *_cur = _item; \ + } while (0) + /** Remove an item from the list */ #define CATTA_LLIST_REMOVE(t,name,head,item) do { \ t **_head = &(head), *_item = (item); \ diff --git a/src/iface-windows.c b/src/iface-windows.c index c62e96a..b2b96a1 100644 --- a/src/iface-windows.c +++ b/src/iface-windows.c @@ -217,8 +217,7 @@ static void queue_event(CattaInterfaceMonitor *m, ChangeEvent *ev) if(!pthread_mutex_lock(&m->osdep.mutex)) { // queue the event - // XXX event ordering!! - CATTA_LLIST_PREPEND(ChangeEvent, event, m->osdep.events, ev); + CATTA_LLIST_APPEND(ChangeEvent, event, m->osdep.events, ev); // wake the handler writepipe(m->osdep.pipefd[1], &c, sizeof(c)); -- 2.39.5