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.

51 lines
1.3 KiB

18 years ago
  1. #include <unistd.h>
  2. #include <sys/time.h>
  3. #include <errno.h>
  4. #include "io_internal.h"
  5. void io_wantwrite_really(int64 d, io_entry* e);
  6. int64 io_canwrite() {
  7. io_entry* e;
  8. if (first_writeable==-1)
  9. #ifdef HAVE_SIGIO
  10. {
  11. if (alt_firstwrite>=0 && (e=iarray_get(&io_fds,alt_firstwrite)) && e->canwrite) {
  12. debug_printf(("io_canwrite: normal write queue is empty, swapping in alt write queue (starting with %ld)\n",alt_firstwrite));
  13. first_writeable=alt_firstwrite;
  14. alt_firstwrite=-1;
  15. } else
  16. return -1;
  17. }
  18. #else
  19. return -1;
  20. #endif
  21. for (;;) {
  22. int64 r;
  23. e=iarray_get(&io_fds,first_writeable);
  24. if (!e) break;
  25. r=first_writeable;
  26. first_writeable=e->next_write;
  27. e->next_write=-1;
  28. debug_printf(("io_canwrite: dequeue %lld from normal write queue (next is %ld)\n",r,first_writeable));
  29. if (e->wantwrite &&
  30. #ifdef __MINGW32__
  31. (e->canwrite || e->sendfilequeued==1)
  32. #else
  33. e->canwrite
  34. #endif
  35. ) {
  36. #ifdef HAVE_SIGIO
  37. e->next_write=alt_firstwrite;
  38. alt_firstwrite=r;
  39. debug_printf(("io_canwrite: enqueue %ld in alt write queue (next is %ld)\n",alt_firstwrite,e->next_write));
  40. if (io_waitmode!=_SIGIO)
  41. #endif
  42. e->canwrite=0;
  43. if (!e->kernelwantwrite)
  44. io_wantwrite_really(r,e);
  45. return r;
  46. }
  47. }
  48. return -1;
  49. }