Index: sys/kern/vfs_aio.c =================================================================== --- sys/kern/vfs_aio.c +++ sys/kern/vfs_aio.c @@ -2489,8 +2489,11 @@ ops->store_aiocb(aiocbp, NULL); - timo = 0; - if (ts) { + if (ts == NULL) { + timo = 0; + } else if (ts->tv_sec == 0 && ts->tv_nsec == 0) { + timo = -1; + } else { if ((ts->tv_nsec < 0) || (ts->tv_nsec >= 1000000000)) return (EINVAL); @@ -2507,14 +2510,20 @@ error = 0; cb = NULL; AIO_LOCK(ki); - while ((cb = TAILQ_FIRST(&ki->kaio_done)) == NULL) { - ki->kaio_flags |= KAIO_WAKEUP; - error = msleep(&p->p_aioinfo, AIO_MTX(ki), PRIBIO | PCATCH, - "aiowc", timo); - if (timo && error == ERESTART) - error = EINTR; - if (error) - break; + if (timo == -1) { + cb = TAILQ_FIRST(&ki->kaio_done); + if (cb == NULL) + error = EAGAIN; + } else { + while ((cb = TAILQ_FIRST(&ki->kaio_done)) == NULL) { + ki->kaio_flags |= KAIO_WAKEUP; + error = msleep(&p->p_aioinfo, AIO_MTX(ki), + PRIBIO | PCATCH, "aiowc", timo); + if (timo && error == ERESTART) + error = EINTR; + if (error) + break; + } } if (cb != NULL) {