make io_waituntil actually take an "until", not a "how long"

fix io_timeouted to ignore fds where no timeout has been set
master
leitner 22 years ago
parent 3279ca84f8
commit 97043d279f

@ -5,6 +5,7 @@
the integer scan routines should only write *dest if they actually the integer scan routines should only write *dest if they actually
scanned something scanned something
io_sendfile and iob_send should return -1 to -3 just like io_trywrite io_sendfile and iob_send should return -1 to -3 just like io_trywrite
make io_waituntil actually take an "until", not a "how long"
0.16: 0.16:
add buffer_fromsa (make buffer from stralloc) add buffer_fromsa (make buffer from stralloc)

@ -10,8 +10,9 @@ int64 io_timeouted() {
if (ptr>=alen) ptr=0; if (ptr>=alen) ptr=0;
e=array_get(&io_fds,sizeof(io_entry),ptr); e=array_get(&io_fds,sizeof(io_entry),ptr);
if (!e) return -1; if (!e) return -1;
for (;ptr<alen; ++ptr,++e) for (;ptr<alen; ++ptr,++e) {
if (e->inuse && taia_less(&e->timeout,&now)) if (e->inuse && e->timeout.sec.x && taia_less(&e->timeout,&now))
return ptr; return ptr;
}
return -1; return -1;
} }

@ -7,9 +7,10 @@
void io_waituntil(tai6464 t) { void io_waituntil(tai6464 t) {
uint64 x,y; uint64 x,y;
tai6464 now; tai6464 now,diff;
taia_now(&now); taia_now(&now);
if (!umult64(now.sec.x,1000,&x) || (y=x+now.nano/10000000)<x) taia_sub(&diff,&t,&now);
if (!umult64(diff.sec.x,1000,&x) || (y=x+diff.nano/10000000)<x)
y=-1; /* overflow; wait indefinitely */ y=-1; /* overflow; wait indefinitely */
io_waituntil2(y); io_waituntil2(y);
} }

Loading…
Cancel
Save