WARNING - OLD ARCHIVES

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/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [PATCH] libxenstore: fix threading bug which cause xend

To: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH] libxenstore: fix threading bug which cause xend startup hang
From: Ian Campbell <Ian.Campbell@xxxxxxxxxx>
Date: Fri, 10 Sep 2010 18:42:30 +0100
Cc: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Fri, 10 Sep 2010 10:44:42 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <19594.25527.652366.155193@xxxxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: Citrix Systems, Inc.
References: <19594.25262.241563.656571@xxxxxxxxxxxxxxxxxxxxxxxx> <19594.25527.652366.155193@xxxxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
On Fri, 2010-09-10 at 17:58 +0100, Ian Jackson wrote: 
> I wrote:
> > If a multithreaded caller creates a thread which calls xs_read_watch,
> > before it has set any watches with xs_watch, the thread in
> > xs_read_watch will enter read_message and sit reading the xenstored fd
> > without the appropriate locks held.  Other threads can then
> > concurrently read the xenstored fd, which naturally does not work very
> > well.
> 
> While I was investigating this, I noticed that xs_fileno, which is
> used by numerous applications to be able to select() waiting for
> xenstore watches, always returns -1 and has done so since
> 7268:2144de6eabcc "Make libxenstore thread-safe" in October 2008.
> 
> This is because nothing ever creates the pipe implied by watch_pipe.
> xs_fileno should do so

Doesn't the call to pipe(2) in:
        if ((h->watch_pipe[0] == -1) && (pipe(h->watch_pipe) != -1)) 
do it?

> (and care should be taken that locking is
> appropriate, which needs some thought).

It seems to only be accessed under watch_mutex, apart from get_handle()
xs_daemon_destroy_postfork() and xs_daemon_close() which I guess are
safe.

Ian.


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel