summaryrefslogtreecommitdiff
path: root/Grow.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2011-07-27 17:26:12 +1000
committerNeilBrown <neilb@suse.de>2011-07-27 17:26:12 +1000
commit6560987b25a88f78ed53d37525d363c126a07b79 (patch)
treec75a1faafac1760242e49852211f9596f0fc4d5c /Grow.c
parent656b6b5a55adb1fd223d82478c333264af52877a (diff)
Grow: ensure clean abort if we cannot read the 'completed' file.
If a read of 'completed' returns an error, select will never fail, so this loop would never exit. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'Grow.c')
-rw-r--r--Grow.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/Grow.c b/Grow.c
index e4fc2221..1aab1132 100644
--- a/Grow.c
+++ b/Grow.c
@@ -2725,15 +2725,21 @@ check_progress:
int rv = -2;
tv.tv_sec = 10;
tv.tv_usec = 0;
- while (fd >= 0 && rv < 0) {
+ while (fd >= 0 && rv < 0 && tv.tv_sec > 0) {
fd_set rfds;
FD_ZERO(&rfds);
FD_SET(fd, &rfds);
if (select(fd+1, NULL, NULL, &rfds, &tv) != 1)
break;
- if (sysfs_fd_get_ll(fd, &completed) >= 0)
+ switch (sysfs_fd_get_ll(fd, &completed)) {
+ case 0:
/* all good again */
rv = 1;
+ break;
+ case -2: /* read error - abort */
+ tv.tv_sec = 0;
+ break;
+ }
}
if (fd >= 0)
close(fd);