}
static int
-check_state(int fd, struct directio_context *ct, int sync)
+check_state(int fd, struct directio_context *ct, int sync, int timeout_secs)
{
struct timespec timeout = { .tv_nsec = 5 };
struct io_event event;
if (fstat(fd, &sb) == 0) {
LOG(4, "called for %x", (unsigned) sb.st_rdev);
}
- if (sync) {
+ if (sync > 0) {
LOG(4, "called in synchronous mode");
- timeout.tv_sec = ASYNC_TIMEOUT_SEC;
+ timeout.tv_sec = timeout_secs;
timeout.tv_nsec = 0;
}
strerror(errno));
rc = PATH_UNCHECKED;
} else if (r < 1L) {
- if (ct->running > ASYNC_TIMEOUT_SEC || sync) {
+ if (ct->running > timeout_secs || sync) {
LOG(3, "abort check on timeout");
rc = PATH_DOWN;
} else {
if (!ct)
return PATH_UNCHECKED;
- ret = check_state(c->fd, ct, c->sync);
+ ret = check_state(c->fd, ct, c->sync, c->timeout);
switch (ret)
{