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.
 
 
 
 

64 lines
1.2 KiB

  1. #include <unistd.h>
  2. #include <fcntl.h>
  3. #include <errno.h>
  4. #include "io_internal.h"
  5. #ifdef HAVE_KQUEUE
  6. #include <sys/types.h>
  7. #include <sys/event.h>
  8. #include <sys/time.h>
  9. #endif
  10. #ifdef HAVE_EPOLL
  11. #include <inttypes.h>
  12. #include <sys/epoll.h>
  13. #include <byte.h>
  14. #endif
  15. #ifdef HAVE_DEVPOLL
  16. #include <sys/types.h>
  17. #include <sys/socket.h>
  18. #include <sys/devpoll.h>
  19. #endif
  20. #ifdef DEBUG
  21. #include <assert.h>
  22. #else
  23. #define assert(x)
  24. #endif
  25. void io_dontwantread_really(int64 d, io_entry* e) {
  26. int newfd;
  27. (void)d;
  28. assert(e->kernelwantread);
  29. newfd=!e->kernelwantwrite;
  30. io_wanted_fds-=newfd;
  31. #ifdef HAVE_KQUEUE
  32. if (io_waitmode==KQUEUE) {
  33. struct kevent kev;
  34. struct timespec ts;
  35. EV_SET(&kev, d, EVFILT_READ, EV_DELETE, 0, 0, 0);
  36. ts.tv_sec=0; ts.tv_nsec=0;
  37. kevent(io_master,&kev,1,0,0,&ts);
  38. }
  39. #endif
  40. #ifdef HAVE_DEVPOLL
  41. if (io_waitmode==DEVPOLL) {
  42. struct pollfd x;
  43. x.fd=d;
  44. x.events=0;
  45. if (e->kernelwantwrite) x.events|=POLLOUT;
  46. if (!x.events) x.events=POLLREMOVE;
  47. write(io_master,&x,sizeof(x));
  48. }
  49. #endif
  50. e->wantread=0;
  51. e->kernelwantread=0;
  52. }
  53. void io_dontwantread(int64 d) {
  54. io_entry* e=iarray_get(&io_fds,d);
  55. if (e) {
  56. if (e->canread)
  57. io_dontwantread_really(d,e);
  58. e->wantread=0;
  59. }
  60. }