summaryrefslogtreecommitdiffstats
path: root/mdstat.c
diff options
context:
space:
mode:
authorBlazej Kucman <blazej.kucman@intel.com>2020-09-09 10:31:19 +0200
committerJes Sorensen <jsorensen@fb.com>2020-10-14 17:33:47 +0200
commitcab9c67d461c65a1138359f9f6d39636466b90e4 (patch)
treea35cdb61d64c9617daceea527f5fb73112b6490e /mdstat.c
parentMonitor: stop notifing about containers. (diff)
downloadmdadm-cab9c67d461c65a1138359f9f6d39636466b90e4.tar.xz
mdadm-cab9c67d461c65a1138359f9f6d39636466b90e4.zip
mdmonitor: set small delay once
If mdmonitor is awakened by event, set small delay once to deal with udev and mdadm. Signed-off-by: Blazej Kucman <blazej.kucman@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Diffstat (limited to 'mdstat.c')
-rw-r--r--mdstat.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/mdstat.c b/mdstat.c
index 48559e64..dd96cca7 100644
--- a/mdstat.c
+++ b/mdstat.c
@@ -302,7 +302,17 @@ void mdstat_close(void)
mdstat_fd = -1;
}
-void mdstat_wait(int seconds)
+/*
+ * function: mdstat_wait
+ * Description: Function waits for event on mdstat.
+ * Parameters:
+ * seconds - timeout for waiting
+ * Returns:
+ * > 0 - detected event
+ * 0 - timeout
+ * < 0 - detected error
+ */
+int mdstat_wait(int seconds)
{
fd_set fds;
struct timeval tm;
@@ -312,10 +322,12 @@ void mdstat_wait(int seconds)
FD_SET(mdstat_fd, &fds);
maxfd = mdstat_fd;
} else
- return;
+ return -1;
+
tm.tv_sec = seconds;
tm.tv_usec = 0;
- select(maxfd + 1, NULL, NULL, &fds, &tm);
+
+ return select(maxfd + 1, NULL, NULL, &fds, &tm);
}
void mdstat_wait_fd(int fd, const sigset_t *sigmask)