Index: sys/dev/xen/xenstore/xenstore.c =================================================================== --- sys/dev/xen/xenstore/xenstore.c +++ sys/dev/xen/xenstore/xenstore.c @@ -1700,6 +1700,15 @@ } } +int +xs_is_locked(void) +{ + struct thread *td; + + td = sx_xholder(&xs.request_mutex); + return (td == NULL); +} + void xs_lock(void) { Index: sys/dev/xen/xenstore/xenstore_dev.c =================================================================== --- sys/dev/xen/xenstore/xenstore_dev.c +++ sys/dev/xen/xenstore/xenstore_dev.c @@ -128,6 +128,13 @@ if (error != 0) return (error); + while(!xs_is_locked()) + { + error = tsleep(u, PCATCH, "xsdwrite", hz/10); + if (error && error != EWOULDBLOCK) + return (error); + } + if ((len + u->len) > sizeof(u->u.buffer)) return (EINVAL); Index: sys/xen/xenstore/xenstorevar.h =================================================================== --- sys/xen/xenstore/xenstorevar.h +++ sys/xen/xenstore/xenstorevar.h @@ -339,6 +339,11 @@ struct sbuf *xs_join(const char *, const char *); /** + * decide whether the xenstore request mutex is locked or not + */ +int xs_is_locked(void); + +/** * Lock the xenstore request mutex. */ void xs_lock(void);