Mirror of :pserver:cvs@cvs.fefe.de:/cvs libowfat https://www.fefe.de/libowfat/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
710 B

18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
15 years ago
18 years ago
  1. #include "io_internal.h"
  2. int64 io_timeouted() {
  3. tai6464 now;
  4. static size_t ptr;
  5. io_entry* e;
  6. size_t alen=iarray_length(&io_fds);
  7. taia_now(&now);
  8. ++ptr;
  9. if (ptr>=alen) ptr=0;
  10. e=iarray_get(&io_fds,ptr);
  11. if (!e) return -1;
  12. for (;ptr<alen; ++ptr,++e) {
  13. if (e->inuse && e->timeout.sec.x && taia_less(&e->timeout,&now)) {
  14. /* we have a timeout */
  15. if ((e->canread&&e->wantread) || (e->canwrite&&e->wantwrite))
  16. continue; /* don't count it if we can signal something else */
  17. return ptr;
  18. }
  19. }
  20. ptr=-1; /* this is for really pathological cases, where more
  21. connections come in all the time and so the timeout
  22. handling does not trigger initially */
  23. return -1;
  24. }