summaryrefslogtreecommitdiffstats
path: root/mdstat.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2008-08-19 06:55:07 +0200
committerNeilBrown <neilb@suse.de>2008-08-19 06:55:07 +0200
commit0b5ec75e011e986286c2a6f9f3491427e9bde446 (patch)
tree2199e993575d996938fe53b5980f9f8c141dec31 /mdstat.c
parentMake metadata updates from manage to monitor 'synchronous' (diff)
downloadmdadm-0b5ec75e011e986286c2a6f9f3491427e9bde446.tar.xz
mdadm-0b5ec75e011e986286c2a6f9f3491427e9bde446.zip
Fix mdstat_wait_fd
It didn't necessarily wait for the fd. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'mdstat.c')
-rw-r--r--mdstat.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/mdstat.c b/mdstat.c
index 4bb29d85..00714b48 100644
--- a/mdstat.c
+++ b/mdstat.c
@@ -260,25 +260,31 @@ void mdstat_wait(int seconds)
{
fd_set fds;
struct timeval tm;
+ int maxfd = 0;
FD_ZERO(&fds);
- if (mdstat_fd >= 0)
+ if (mdstat_fd >= 0) {
FD_SET(mdstat_fd, &fds);
+ maxfd = mdstat_fd;
+ }
tm.tv_sec = seconds;
tm.tv_usec = 0;
- select(mdstat_fd >2 ? mdstat_fd+1:3, NULL, NULL, &fds, &tm);
+ select(maxfd + 1, NULL, NULL, &fds, &tm);
}
void mdstat_wait_fd(int fd, const sigset_t *sigmask)
{
fd_set fds, rfds;
+ int maxfd = fd;
FD_ZERO(&fds);
FD_ZERO(&rfds);
if (mdstat_fd >= 0)
FD_SET(mdstat_fd, &fds);
FD_SET(fd, &rfds);
+ if (mdstat_fd > maxfd)
+ maxfd = mdstat_fd;
- pselect(mdstat_fd >2 ? mdstat_fd+1:3, &rfds, NULL, &fds,
+ pselect(maxfd + 1, &rfds, NULL, &fds,
NULL, sigmask);
}