aboutsummaryrefslogtreecommitdiffstats
path: root/extras/mini-os/blkfront.c
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2008-05-06 13:34:52 +0100
committerKeir Fraser <keir.fraser@citrix.com>2008-05-06 13:34:52 +0100
commitcc489fb3c4f2d523cba4b8b13d2bf83564de8254 (patch)
treec1c5303e97b6a35ce3693489d27c1dd378593e4e /extras/mini-os/blkfront.c
parentea1c7a7225787dcda405a1a75a1e982624f1ef1a (diff)
downloadxen-cc489fb3c4f2d523cba4b8b13d2bf83564de8254.tar.gz
xen-cc489fb3c4f2d523cba4b8b13d2bf83564de8254.tar.bz2
xen-cc489fb3c4f2d523cba4b8b13d2bf83564de8254.zip
minios: fix thread safety of xenbus watches by requiring callers to
provide their own queue of events, because else we can not dispatch to watchers running in parallel. Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
Diffstat (limited to 'extras/mini-os/blkfront.c')
-rw-r--r--extras/mini-os/blkfront.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/extras/mini-os/blkfront.c b/extras/mini-os/blkfront.c
index 8588518607..84914346f9 100644
--- a/extras/mini-os/blkfront.c
+++ b/extras/mini-os/blkfront.c
@@ -50,6 +50,8 @@ struct blkfront_dev {
char *backend;
struct blkfront_info info;
+ xenbus_event_queue events;
+
#ifdef HAVE_LIBC
int fd;
#endif
@@ -101,6 +103,8 @@ struct blkfront_dev *init_blkfront(char *nodename, struct blkfront_info *info)
dev->ring_ref = gnttab_grant_access(dev->dom,virt_to_mfn(s),0);
+ dev->events = NULL;
+
// FIXME: proper frees on failures
again:
err = xenbus_transaction_start(&xbt);
@@ -166,11 +170,9 @@ done:
snprintf(path, sizeof(path), "%s/state", dev->backend);
- xenbus_watch_path(XBT_NIL, path);
+ xenbus_watch_path_token(XBT_NIL, path, path, &dev->events);
- xenbus_wait_for_value(path,"4");
-
- xenbus_unwatch_path(XBT_NIL, path);
+ xenbus_wait_for_value(path, "4", &dev->events);
snprintf(path, sizeof(path), "%s/info", dev->backend);
dev->info.info = xenbus_read_integer(path);
@@ -211,10 +213,12 @@ void shutdown_blkfront(struct blkfront_dev *dev)
snprintf(path, sizeof(path), "%s/state", dev->backend);
err = xenbus_printf(XBT_NIL, nodename, "state", "%u", 5); /* closing */
- xenbus_wait_for_value(path,"5");
+ xenbus_wait_for_value(path, "5", &dev->events);
err = xenbus_printf(XBT_NIL, nodename, "state", "%u", 6);
- xenbus_wait_for_value(path,"6");
+ xenbus_wait_for_value(path, "6", &dev->events);
+
+ xenbus_unwatch_path(XBT_NIL, path);
unbind_evtchn(dev->evtchn);