From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Keir Fraser <keir.fraser@eu.citrix.com>
Cc: Xen-devel <xen-devel@lists.xensource.com>,
Stefano Stabellini <Stefano.Stabellini@eu.citrix.com>
Subject: [PATCH 2 of 2] xs: avoid pthread_join deadlock in xs_daemon_close
Date: Tue, 11 May 2010 15:03:47 -0700 [thread overview]
Message-ID: <4BE9D443.20106@goop.org> (raw)
In-Reply-To: <4BE9D3B9.2050206@goop.org>
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>
diff -r 84ee0559ddc1 tools/xenstore/xs.c
--- a/tools/xenstore/xs.c Tue May 11 14:55:14 2010 -0700
+++ b/tools/xenstore/xs.c Tue May 11 14:55:20 2010 -0700
@@ -260,10 +260,6 @@
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);
@@ -271,6 +267,10 @@
}
#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);
prev parent reply other threads:[~2010-05-11 22:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-11 22:01 Shutdown problems in xs.c Jeremy Fitzhardinge
2010-05-11 22:02 ` [PATCH 1 of 2] xs: make sure mutexes are cleaned up and memory freed if the read thread is cancelled Jeremy Fitzhardinge
2010-05-11 22:03 ` Jeremy Fitzhardinge [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4BE9D443.20106@goop.org \
--to=jeremy@goop.org \
--cc=Stefano.Stabellini@eu.citrix.com \
--cc=keir.fraser@eu.citrix.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).