From: Keir Fraser Date: Wed, 7 Apr 2010 07:15:55 +0000 (+0100) Subject: mini-os: Fix frontend shutdown wait loop X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=2ec74ac1816160346a44dfba31b232a3b7f88fe9;p=people%2Fliuw%2Flibxenctrl-split%2Fmini-os.git mini-os: Fix frontend shutdown wait loop minios frontends must wait for backends to be shut down and reinitialized before freeing resources. Signed-off-by: Samuel Thibault --- diff --git a/blkfront.c b/blkfront.c index 9862fb9..f47aa69 100644 --- a/blkfront.c +++ b/blkfront.c @@ -289,7 +289,7 @@ void shutdown_blkfront(struct blkfront_dev *dev) goto close; } state = xenbus_read_integer(path); - if (state < XenbusStateClosed) { + while (state < XenbusStateClosed) { err = xenbus_wait_for_state_change(path, &state, &dev->events); if (err) free(err); } diff --git a/fbfront.c b/fbfront.c index fa4fc42..6d2268e 100644 --- a/fbfront.c +++ b/fbfront.c @@ -262,7 +262,7 @@ void shutdown_kbdfront(struct kbdfront_dev *dev) goto close_kbdfront; } state = xenbus_read_integer(path); - if (state < XenbusStateClosed) { + while (state < XenbusStateClosed) { err = xenbus_wait_for_state_change(path, &state, &dev->events); if (err) free(err); } @@ -272,8 +272,10 @@ void shutdown_kbdfront(struct kbdfront_dev *dev) XenbusStateInitialising, err); goto close_kbdfront; } - // does not work yet. - //xenbus_wait_for_value(path, "2", &dev->events); + err = NULL; + state = xenbus_read_integer(path); + while (err == NULL && (state < XenbusStateInitWait || state >= XenbusStateClosed)) + err = xenbus_wait_for_state_change(path, &state, &dev->events); close_kbdfront: if (err) free(err); @@ -660,8 +662,11 @@ void shutdown_fbfront(struct fbfront_dev *dev) XenbusStateInitialising, err); goto close_fbfront; } - // does not work yet - //xenbus_wait_for_value(path, "2", &dev->events); + + err = NULL; + state = xenbus_read_integer(path); + while (err == NULL && (state < XenbusStateInitWait || state >= XenbusStateClosed)) + err = xenbus_wait_for_state_change(path, &state, &dev->events); close_fbfront: if (err) free(err); diff --git a/netfront.c b/netfront.c index 47f87d1..491876f 100644 --- a/netfront.c +++ b/netfront.c @@ -546,7 +546,7 @@ void shutdown_netfront(struct netfront_dev *dev) goto close; } state = xenbus_read_integer(path); - if (state < XenbusStateClosed) { + while (state < XenbusStateClosed) { err = xenbus_wait_for_state_change(path, &state, &dev->events); if (err) free(err); } diff --git a/pcifront.c b/pcifront.c index ccbef3f..638fdb3 100644 --- a/pcifront.c +++ b/pcifront.c @@ -354,7 +354,7 @@ void shutdown_pcifront(struct pcifront_dev *dev) goto close_pcifront; } state = xenbus_read_integer(path); - if (state < XenbusStateClosed) { + while (state < XenbusStateClosed) { err = xenbus_wait_for_state_change(path, &state, &dev->events); free(err); }