DECLARE_WAIT_QUEUE_HEAD(xenbus_watch_queue);
struct xenbus_event_queue xenbus_events;
-static struct watch {
+struct watch {
char *token;
struct xenbus_event_queue *events;
- struct watch *next;
-} *watches;
+ MINIOS_LIST_ENTRY(watch) entry;
+};
+static MINIOS_LIST_HEAD(, watch) watches;
struct xenbus_req_info
{
int in_use:1;
xenstore_buf->rsp_cons += msg.len + sizeof(msg);
- for (watch = watches; watch; watch = watch->next)
+ MINIOS_LIST_FOREACH(watch, &watches, entry)
if (!strcmp(watch->token, event->token)) {
events = watch->events;
break;
watch->token = strdup(token);
watch->events = events;
- watch->next = watches;
- watches = watch;
+
+ MINIOS_LIST_INSERT_HEAD(&watches, watch, entry);
rep = xenbus_msg_reply(XS_WATCH, xbt, req, ARRAY_SIZE(req));
{token, strlen(token) + 1},
};
- struct watch *watch, **prev;
+ struct watch *watch;
char *msg;
if (msg) return msg;
free(rep);
- for (prev = &watches, watch = *prev; watch; prev = &watch->next, watch = *prev)
+ MINIOS_LIST_FOREACH(watch, &watches, entry)
if (!strcmp(watch->token, token)) {
free(watch->token);
- *prev = watch->next;
+ MINIOS_LIST_REMOVE(watch, entry);
free(watch);
break;
}