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?
- epollpri
- epollrdnorm
- epollrdband
- epollwrnorm
- epollwrband
- epollmsg
- epollerr
- epollhup
- 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 returnsepollin | epollrdnorm
when data available reading file descriptor).epollout
,epollwrnorm
identical (epoll returnsepollout | epollwrnorm
when buffer space available writing).epollrdband
,epollwrband
signal availability of out of band data on descriptor (on sockets data sendmsg_oob
flag passed socket).epollpri
modifier flag , augments other event (suchepollerr
). 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
Post a Comment