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.
 
 
 
 

61 lines
1.4 KiB

  1. #include <unistd.h>
  2. #include <sys/time.h>
  3. #include <errno.h>
  4. #include "io_internal.h"
  5. #ifdef __MINGW32__
  6. #include <stdio.h>
  7. #endif
  8. void io_wantread_really(int64 d, io_entry* e);
  9. int64 io_canread() {
  10. io_entry* e;
  11. if (first_readable==-1)
  12. #ifdef HAVE_SIGIO
  13. {
  14. if (alt_firstread>=0 && (e=iarray_get(&io_fds,alt_firstread)) && e->canread) {
  15. debug_printf(("io_canread: normal read queue is empty, swapping in alt read queue (starting with %ld)\n",alt_firstread));
  16. first_readable=alt_firstread;
  17. alt_firstread=-1;
  18. } else
  19. return -1;
  20. }
  21. #else
  22. return -1;
  23. #endif
  24. for (;;) {
  25. int64 r;
  26. e=iarray_get(&io_fds,first_readable);
  27. if (!e) break;
  28. r=first_readable;
  29. first_readable=e->next_read;
  30. e->next_read=-1;
  31. debug_printf(("io_canread: dequeue %lld from normal read queue (next is %ld)\n",r,first_readable));
  32. #ifdef __MINGW32__
  33. // printf("event on %d: wr %d rq %d aq %d\n",(int)r,e->wantread,e->readqueued,e->acceptqueued);
  34. #endif
  35. if (e->wantread &&
  36. #ifdef __MINGW32__
  37. (e->canread || e->acceptqueued==1 || e->readqueued==1)
  38. #else
  39. e->canread
  40. #endif
  41. ) {
  42. #ifdef HAVE_SIGIO
  43. e->next_read=alt_firstread;
  44. alt_firstread=r;
  45. debug_printf(("io_canread: enqueue %ld in alt read queue (next is %ld)\n",alt_firstread,e->next_read));
  46. if (io_waitmode!=_SIGIO)
  47. #endif
  48. e->canread=0;
  49. if (!e->kernelwantread)
  50. io_wantread_really(r,e);
  51. return r;
  52. }
  53. }
  54. return -1;
  55. }