diff --git a/io/io_tryreadtimeout.c b/io/io_tryreadtimeout.c index 5c41bcb..e123703 100644 --- a/io/io_tryreadtimeout.c +++ b/io/io_tryreadtimeout.c @@ -10,7 +10,7 @@ int64 io_tryreadtimeout(int64 d,char* buf,int64 len) { tai6464 x; io_entry* e=array_get(&io_fds,sizeof(io_entry),d); taia_now(&x); - if (taia_less(&x,&e->timeout)) { + if (!taia_less(&x,&e->timeout)) { errno=ETIMEDOUT; r=-2; } diff --git a/io/io_trywritetimeout.c b/io/io_trywritetimeout.c index 75b4894..e0761c5 100644 --- a/io/io_trywritetimeout.c +++ b/io/io_trywritetimeout.c @@ -10,7 +10,7 @@ int64 io_trywritetimeout(int64 d,const char* buf,int64 len) { tai6464 x; io_entry* e=array_get(&io_fds,sizeof(io_entry),d); taia_now(&x); - if (taia_less(&x,&e->timeout)) { + if (!taia_less(&x,&e->timeout)) { errno=ETIMEDOUT; r=-2; } diff --git a/test/io4.c b/test/io4.c index 7194356..62fa6fc 100644 --- a/test/io4.c +++ b/test/io4.c @@ -17,6 +17,7 @@ main() { taia_addsec(&t,&t,1); if (!io_fd(pfd[0])) return 111; io_timeout(pfd[0],t); + sleep(2); if ((r=io_tryreadtimeout(pfd[0],buf,sizeof buf))!=-2) { buffer_puts(buffer_2,"io_tryreadtimeout returned "); buffer_putlonglong(buffer_2,r);