summaryrefslogtreecommitdiffstats
path: root/Monitor.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2013-07-01 05:28:13 +0200
committerNeilBrown <neilb@suse.de>2013-07-01 05:28:13 +0200
commitefc67e8e9fe430d5833236f16ea287ef363dadc5 (patch)
tree4da51e5aa6580aa3ae63eaf318fe16d93ad59163 /Monitor.c
parentrevert-reshape: make sure reshape_position is acceptable. (diff)
downloadmdadm-efc67e8e9fe430d5833236f16ea287ef363dadc5.tar.xz
mdadm-efc67e8e9fe430d5833236f16ea287ef363dadc5.zip
New function: sysfs_wait
We have several places that wait for activity on a sysfs file. Combine most of these into a single 'sysfs_wait' function. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'Monitor.c')
-rw-r--r--Monitor.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/Monitor.c b/Monitor.c
index 86df18c2..c1a5d60d 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -1050,17 +1050,12 @@ int WaitClean(char *dev, int sock, int verbose)
if (rv) {
int state_fd = sysfs_open(fd2devnm(fd), NULL, "array_state");
char buf[20];
- fd_set fds;
- struct timeval tm;
+ int delay = 5000;
/* minimize the safe_mode_delay and prepare to wait up to 5s
* for writes to quiesce
*/
sysfs_set_safemode(mdi, 1);
- tm.tv_sec = 5;
- tm.tv_usec = 0;
-
- FD_ZERO(&fds);
/* wait for array_state to be clean */
while (1) {
@@ -1069,8 +1064,7 @@ int WaitClean(char *dev, int sock, int verbose)
break;
if (sysfs_match_word(buf, clean_states) <= 4)
break;
- FD_SET(state_fd, &fds);
- rv = select(state_fd + 1, NULL, NULL, &fds, &tm);
+ rv = sysfs_wait(state_fd, &delay);
if (rv < 0 && errno != EINTR)
break;
lseek(state_fd, 0, SEEK_SET);