ia64/xen-unstable

changeset 7585:ea6d9f29dff5

Watch events may get lost, the xenstored response races against the new
watch being added to the watch list in register_xenbus_watch(). Fixed
by adding the watch to the list unconditionally, and remove it in the
error case.
author kaf24@firebug.cl.cam.ac.uk
date Mon Oct 31 17:07:14 2005 +0100 (2005-10-31)
parents 8cc7ce549d00
children 8ded2066e16c 5ffe3f16aa52
files linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c	Mon Oct 31 10:45:31 2005 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c	Mon Oct 31 17:07:14 2005 +0100
     1.3 @@ -682,14 +682,15 @@ int register_xenbus_watch(struct xenbus_
     1.4  
     1.5  	spin_lock(&watches_lock);
     1.6  	BUG_ON(find_watch(token));
     1.7 +	list_add(&watch->list, &watches);
     1.8  	spin_unlock(&watches_lock);
     1.9  
    1.10  	err = xs_watch(watch->node, token);
    1.11  
    1.12  	/* Ignore errors due to multiple registration. */
    1.13 -	if ((err == 0) || (err == -EEXIST)) {
    1.14 +	if ((err != 0) && (err != -EEXIST)) {
    1.15  		spin_lock(&watches_lock);
    1.16 -		list_add(&watch->list, &watches);
    1.17 +		list_del(&watch->list);
    1.18  		spin_unlock(&watches_lock);
    1.19  	}
    1.20