diff -r 3c4c3d48a835 tools/xenstore/xs.c --- a/tools/xenstore/xs.c Thu Aug 26 11:16:56 2010 +0100 +++ b/tools/xenstore/xs.c Mon Aug 30 09:31:27 2010 -0400 @@ -271,6 +271,7 @@ { #ifdef USE_PTHREAD if (h->read_thr_exists) { + h->read_thr_exists = 0; pthread_cancel(h->read_thr); pthread_join(h->read_thr, NULL); } @@ -666,9 +667,15 @@ mutex_lock(&h->watch_mutex); +#ifdef USE_PTHREAD /* Wait on the condition variable for a watch to fire. */ while (list_empty(&h->watch_list) && read_thread_exists(h)) condvar_wait(&h->watch_condvar, &h->watch_mutex, h); +#else + while (list_empty(&h->watch_list)) + read_message(h); +#endif + if (!read_thread_exists(h)) { mutex_unlock(&h->watch_mutex); errno = EINVAL; @@ -966,13 +973,8 @@ { struct xs_handle *h = arg; - while (read_message(h) != -1) - continue; - - /* Kick anyone waiting for a reply */ - pthread_mutex_lock(&h->request_mutex); - h->read_thr_exists = 0; - pthread_mutex_unlock(&h->request_mutex); + while (h->read_thr_exists) + read_message(h); pthread_mutex_lock(&h->reply_mutex); pthread_cond_signal(&h->reply_condvar);