From: Ian Jackson Subject: Re: [PATCH v2] libxl: Atomicaly check backend state and set it to 5 at device_remove Date: Tue, 21 Feb 2012 12:28:00 +0000 Message-ID: <20291.36304.150241.181511@mariner.uk.xensource.com> References: <1b95948228b84c986764.1326548473@loki.upc.es> <20290.29364.583732.682392@mariner.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Roger Pau =?iso-8859-1?Q?Monn=E9?= Cc: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org Roger Pau Monn=E9 writes ("Re: [Xen-devel] [PATCH v2] libxl: Atomicaly chec= k backend state and set it to 5 at device_remove"): > Also I've found myself using a lot a construction like the following: > = > - check xenstore path > - If path value is different than x > - Set up a watch > - Wait for events. > = > And I'm afraid it's not concurrent safe, since someone can perform a > bunch of xenstore changes in the space between setting the watch, and > wait for events. The watcher will only get notified of the last > xenstore change, but not all changes that happened between. xenstore is not a message-passing protocol in that way. There is no way to be sure that you see all the intermediate values of a particular xenstore node. The required approach is for the protocol not to care about intermediate values, or for the "sender" to coordinate with the "receiver" somehow. If all you mean is that you worry about the path changing between the first read and the setting up of the watch, then you're fine: every watch is guaranteed to fire once right after you set it up, so your watch handler function will definitely read the path again and you won't sit waiting for an event that never comes. Ian.