Question

I have a few threads, waiting on the same epoll_fd with epoll_wait(). The descriptors within epoll set are setup in this way:

struct epoll_event event;
event.events = EPOLLIN | EPOLLONESHOT;
event.data.fd = fd;

The purpose of EPOLLONESHOT is to guarantee, that each descriptor is handled only in one thread at the same time. If one thread has received EPOLLIN event with specific fd, can the EPOLLHUP or EPOLLERR trigger event in another thread with the same fd?

I suggest they can't - since the descriptor is disabled due to EPOLLONESHOT. But if they can - can I use EPOLLRDHUP instead? Will it be triggered at least once when the descriptor becomes invalid/closed/disconnected by any means?

Was it helpful?

Solution

Seems like disabled descriptors don't receive EPOLLHUP.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top