--- IO-AIO/AIO.xs 2005/08/23 12:37:19 1.37 +++ IO-AIO/AIO.xs 2005/08/28 10:51:33 1.38 @@ -501,10 +501,10 @@ res = sbytes; } -# else +# endif +#else res = -1; errno = ENOSYS; -# endif #endif if (res < 0 @@ -519,11 +519,11 @@ char buf[4096]; res = 0; - for (;;) + while (count) { ssize_t cnt; - cnt = pread (ifd, buf, 4096, offset); + cnt = pread (ifd, buf, count > 4096 ? 4096 : count, offset); if (cnt <= 0) { @@ -541,6 +541,7 @@ offset += cnt; res += cnt; + count -= cnt; } }