This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
Home Products Support Community News


[Xen-changelog] [xen-unstable] xs: avoid pthread_join deadlock in xs_dae

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] xs: avoid pthread_join deadlock in xs_daemon_close
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 14 May 2010 00:40:26 -0700
Delivery-date: Fri, 14 May 2010 00:41:10 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1273650553 -3600
# Node ID 9de69d816b11dd656595c1c4a5383d19a650334f
# Parent  2dd3141b3e3e6987f18ba54ff7f2b9bf4f061903
xs: avoid pthread_join deadlock in xs_daemon_close

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@xxxxxxxxxx>
 tools/xenstore/xs.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff -r 2dd3141b3e3e -r 9de69d816b11 tools/xenstore/xs.c
--- a/tools/xenstore/xs.c       Wed May 12 08:48:14 2010 +0100
+++ b/tools/xenstore/xs.c       Wed May 12 08:49:13 2010 +0100
@@ -260,16 +260,16 @@ void xs_daemon_destroy_postfork(struct x
 void xs_daemon_close(struct xs_handle *h)
-       mutex_lock(&h->request_mutex);
-       mutex_lock(&h->reply_mutex);
-       mutex_lock(&h->watch_mutex);
        if (h->read_thr_exists) {
                pthread_join(h->read_thr, NULL);
+       mutex_lock(&h->request_mutex);
+       mutex_lock(&h->reply_mutex);
+       mutex_lock(&h->watch_mutex);

Xen-changelog mailing list

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] xs: avoid pthread_join deadlock in xs_daemon_close, Xen patchbot-unstable <=