c - How does a socket event get propagated/converted to epoll? -


i curious how epoll_wait() receives event registered socket (with epoll_ctl()) ready read/write.

i believe glibc magically handles it.

then, there document describing how following events can triggered socket?

  1. epollpri
  2. epollrdnorm
  3. epollrdband
  4. epollwrnorm
  5. epollwrband
  6. epollmsg
  7. epollerr
  8. epollhup
  9. epollrdhup

p.s. trying paste enum epoll_events in sys/epoll.h on box here; stackoverflow thinks don't format code block correctly although wrapped pre , code tag, idea?

the glaring problem epoll documentation failure state in "bold caps" epoll events, are, in fact, identical poll (2) events. indeed, on kernel side epoll handles events in terms of older poll event names:

#define pollin     0x0001  // epollin #define pollpri    0x0002  // epollpri #define pollout    0x0004  // epollout #define pollerr    0x0008  // epollerr #define pollhup    0x0010  // epollhup #define pollnval   0x0020  // unused in epoll #define pollrdnorm 0x0040  // epollrdnorm #define pollrdband 0x0080  // epollrdband #define pollwrnorm 0x0100  // epollwrnorm #define pollwrband 0x0200  // epollwrband #define pollmsg    0x0400  // epollmsg #define pollremove 0x1000  // unused in epoll #define pollrdhup  0x2000  // epollrdhup 

then, brief inspection of kernel source reveals that:

  • epollin , epollrdnorm identical (epoll returns epollin | epollrdnorm when data available reading file descriptor).

  • epollout , epollwrnorm identical (epoll returns epollout | epollwrnorm when buffer space available writing).

  • epollrdband , epollwrband signal availability of out of band data on descriptor (on sockets data send msg_oob flag passed socket).

  • epollpri modifier flag , augments other event (such epollerr). it's use subsystem dependent, may mean different things depending on purpose associated file descriptor serves.

  • epollmsg appears unused kernel , appears serve no purpose.

  • epollrdhup signals peer had closed side of channel reading, may still receive data (handy establish no more request data coming in).

  • epollhup signals peer had closed side of channel.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -