ia64/xen-unstable

changeset 5891:5f0446907501

Fix case where watch callback unregisters itself: do not try to ack it
Signed-off-by: Rusty Russel <rusty@rustcorp.com.au>
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Tue Jul 26 17:27:26 2005 +0000 (2005-07-26)
parents 26e4e952c385
children 69beaae8a1fa
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	Tue Jul 26 17:25:57 2005 +0000
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c	Tue Jul 26 17:27:26 2005 +0000
     1.3 @@ -485,6 +485,8 @@ int register_xenbus_watch(struct xenbus_
     1.4  	return err;
     1.5  }
     1.6  
     1.7 +static struct xenbus_watch *watch_callback;
     1.8 +
     1.9  void unregister_xenbus_watch(struct xenbus_watch *watch)
    1.10  {
    1.11  	char token[sizeof(watch) * 2 + 1];
    1.12 @@ -496,6 +498,10 @@ void unregister_xenbus_watch(struct xenb
    1.13  	err = xs_unwatch(watch->node, token);
    1.14  	list_del(&watch->list);
    1.15  
    1.16 +	/* Make sure watch thread knows we unwatched, so don't ack. */
    1.17 +	if (watch_callback == watch)
    1.18 +		watch_callback = NULL;
    1.19 +
    1.20  	if (err)
    1.21  		printk(KERN_WARNING "XENBUS Failed to release watch %s: %i\n",
    1.22  		       watch->node, err);
    1.23 @@ -523,13 +529,16 @@ static int watch_thread(void *unused)
    1.24  
    1.25  			w = find_watch(token);
    1.26  			BUG_ON(!w);
    1.27 +			watch_callback = w;
    1.28  			w->callback(w, node);
    1.29 -			/* FIXME: Only ack if it wasn't deleted. */
    1.30 -			err = xs_acknowledge_watch(token);
    1.31 -			if (err)
    1.32 -				printk(KERN_WARNING
    1.33 -				       "XENBUS acknowledge %s failed %i\n",
    1.34 -				       node, err);
    1.35 +
    1.36 +			if (watch_callback) {
    1.37 +				err = xs_acknowledge_watch(token);
    1.38 +				if (err)
    1.39 +					printk(KERN_WARNING
    1.40 +					       "XENBUS ack %s fail %i\n",
    1.41 +					       node, err);
    1.42 +			}
    1.43  			kfree(node);
    1.44  		} else
    1.45  			printk(KERN_WARNING "XENBUS xs_read_watch: %li\n",