2003-09-08 17:37:23 +00:00
|
|
|
#include "io_internal.h"
|
|
|
|
|
|
|
|
int64 io_timeouted() {
|
|
|
|
tai6464 now;
|
|
|
|
static long ptr;
|
|
|
|
io_entry* e;
|
|
|
|
long alen=array_length(&io_fds,sizeof(io_entry));
|
|
|
|
taia_now(&now);
|
|
|
|
++ptr;
|
|
|
|
if (ptr>=alen) ptr=0;
|
|
|
|
e=array_get(&io_fds,sizeof(io_entry),ptr);
|
|
|
|
if (!e) return -1;
|
2003-10-02 23:30:53 +00:00
|
|
|
for (;ptr<alen; ++ptr,++e) {
|
|
|
|
if (e->inuse && e->timeout.sec.x && taia_less(&e->timeout,&now))
|
2003-09-08 17:37:23 +00:00
|
|
|
return ptr;
|
2003-10-02 23:30:53 +00:00
|
|
|
}
|
2007-01-26 14:16:14 +00:00
|
|
|
ptr=-1; /* this is for really pathological cases, where more
|
2007-01-24 18:28:39 +00:00
|
|
|
connections come in all the time and so the timeout
|
|
|
|
handling does not trigger initially */
|
2003-09-08 17:37:23 +00:00
|
|
|
return -1;
|
|
|
|
}
|