]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Wait for POLLPRI on /proc or /sys files.
authorNeilBrown <neilb@suse.de>
Tue, 14 Apr 2009 04:59:24 +0000 (14:59 +1000)
committerNeilBrown <neilb@suse.de>
Tue, 14 Apr 2009 04:59:24 +0000 (14:59 +1000)
From 2.6.30, /proc/mounts and various /sys files will
probably always returns 'readable' to select, so we will need
to wait on POLLPRI to get the 'new data is available' signal.

When using select, this corresponds to an 'exception', so
adjust calls to select accordingly.
In one case we sometimes wait on a socket and sometime on
/proc/mounts, so we need to test which.

Signed-off-by: NeilBrown <neilb@suse.de>
Monitor.c
mdstat.c
monitor.c

index af531294cc53c908ea7a1b88f7a1e0870c5c62bf..2677f7bf9d9c5f14243776c48237a945847104e7 100644 (file)
--- a/Monitor.c
+++ b/Monitor.c
@@ -706,7 +706,7 @@ int WaitClean(char *dev, int verbose)
                        if (sysfs_match_word(buf, clean_states) <= 4)
                                break;
                        FD_SET(state_fd, &fds);
-                       rv = select(state_fd + 1, &fds, NULL, NULL, &tm);
+                       rv = select(state_fd + 1, NULL, NULL, &fds, &tm);
                        if (rv < 0 && errno != EINTR)
                                break;
                        lseek(state_fd, 0, SEEK_SET);
index ebdfc67bf6d46705e1ebcb74212299b2aa47b66c..8de51cf755fa0e718f321d54c3714abd92f04cd9 100644 (file)
--- a/mdstat.c
+++ b/mdstat.c
@@ -280,8 +280,18 @@ void mdstat_wait_fd(int fd, const sigset_t *sigmask)
        FD_ZERO(&rfds);
        if (mdstat_fd >= 0)
                FD_SET(mdstat_fd, &fds);
-       if (fd >= 0)
-               FD_SET(fd, &rfds);
+       if (fd >= 0) {
+               struct stat stb;
+               fstat(fd, &stb);
+               if ((stb.st_mode & S_IFMT) == S_IFREG)
+                       /* Must be a /proc or /sys fd, so expect
+                        * POLLPRI
+                        * i.e. an 'exceptional' event.
+                        */
+                       FD_SET(fd, &fds);
+               else
+                       FD_SET(fd, &rfds);
+       }
        if (mdstat_fd > maxfd)
                maxfd = mdstat_fd;
 
index 3388d31c5c57aaab6d60fde1ef04e7dd940743eb..66fea80e808f0475293bc01807f5c0fcfe2226de 100644 (file)
--- a/monitor.c
+++ b/monitor.c
@@ -498,7 +498,7 @@ static int wait_and_act(struct supertype *container, int nowait)
                sigprocmask(SIG_UNBLOCK, NULL, &set);
                sigdelset(&set, SIGUSR1);
                monitor_loop_cnt |= 1;
-               rv = pselect(maxfd+1, &rfds, NULL, NULL, NULL, &set);
+               rv = pselect(maxfd+1, NULL, NULL, &rfds, NULL, &set);
                monitor_loop_cnt += 1;
                if (rv == -1 && errno == EINTR)
                        rv = 0;