Doing a pthread_cancel and join on the reader thread while holding all
the request/reply/watch mutexes can deadlock if the thread needs to
take any of those mutexes to exit. Kill off the reader thread before
taking any mutexes (which should be redundant if we're
single-threaded at that point).
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
void xs_daemon_close(struct xs_handle *h)
{
- mutex_lock(&h->request_mutex);
- mutex_lock(&h->reply_mutex);
- mutex_lock(&h->watch_mutex);
-
#ifdef USE_PTHREAD
if (h->read_thr_exists) {
pthread_cancel(h->read_thr);
}
#endif
+ mutex_lock(&h->request_mutex);
+ mutex_lock(&h->reply_mutex);
+ mutex_lock(&h->watch_mutex);
+
close_free_msgs(h);
mutex_unlock(&h->request_mutex);