From: Sven M. Hallberg Date: Thu, 11 Sep 2014 19:53:02 +0000 (+0200) Subject: process change events in the order they are received X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=59e603d00947dfa0ee068c6ec15742fa75c44a27;p=catta process change events in the order they are received --- 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));