Questions tagged [epollet]

Epoll in Edge Trigger mode

The epoll Linux system call has two modes of operations. The "normal" mode, called level trigger mode, will report an event if it is currently active.

In edge trigger mode, the event will only be reported once. After being reported, that same fd will not be reported for that event until all pending data is consumed.

32 questions
19
votes
1 answer

TCP: When is EPOLLHUP generated?

Also see this question, unanswered as of now. There is a lot of confusion about EPOLLHUP, even in the man and Kernel docs. People seem to believe it is returned when polling on a descriptor locally closed for writing, i.e. shutdown(SHUT_WR), i.e.…
haelix
  • 4,245
  • 4
  • 34
  • 56
9
votes
1 answer

Are epoll events being watched when not epoll_waiting

I'm rather new to event based programming. I'm experimenting with epoll's edge-mode which apparently only signals files which have become ready for read/write (as opposed to level-mode which signals all ready files, regardless of whether there were…
Antoine
  • 13,494
  • 6
  • 40
  • 52
7
votes
2 answers

Using edge triggered epoll, should I loop over send?

I'm using epoll to write a media server. The fds are all set to non-blocking and I'm using edge-triggered events. I know for EPOLLIN I need to loop over reading the fd until EAGAIN is returned. But what about writing? When I want to write I queue…
Martin Redmond
  • 13,366
  • 6
  • 36
  • 32
6
votes
2 answers

One-shot *level*-triggered epoll(): Does EPOLLONESHOT imply EPOLLET?

Is it possible to use epoll in one-shot level-triggered mode? I couldn't find any information on it when I searched; it seems everyone uses edge-triggered mode.
user541686
  • 205,094
  • 128
  • 528
  • 886
3
votes
1 answer

How do "special" epoll flags correspond to kqueue ones?

I'm struggling to draw a parallel between epoll and kqueue flags, specifically EPOLLONESHOT EPOLLET EPOLLEXCLUSIVE and EV_CLEAR/EV_DISPATCH/EV_ONESHOT. I'm investigating the kqueue for the first time; I only had an experience with…
ghostmansd
  • 3,285
  • 5
  • 30
  • 44
3
votes
1 answer

Nested EPOLL FD

I find very limited information online about the behaviour of nested FDs. Lets say EPOLL FD1 is shared between EPOLL FD2 and FD3. So what would happen if epoll FD1 get an event Is it going to raise an event to both FD2 and Fd3 if it is added…
3
votes
1 answer

How to read multiple file descriptors using epoll_select with EPOLLET?

man epoll: The suggested way to use epoll as an edge-triggered (EPOLLET) interface is as follows: i with nonblocking file descriptors; and ii by waiting for an event only after read(2) or write(2) return EAGAIN. Imagine we have two fds:…
Vi.
  • 37,014
  • 18
  • 93
  • 148
3
votes
0 answers

Socket epoll: Will EPOLL_CTL_MOD reset the edge trigger?

Start by adding a socket to an epoll set for edge triggered reading: epoll_event ev = {}; ev.data.fd = sock; ev.events = EPOLLIN | EPOLLET; // edge triggered reading epoll_ctl(efd, EPOLL_CTL_ADD, sock, &ev); Now wait for data: result =…
selbie
  • 100,020
  • 15
  • 103
  • 173
3
votes
1 answer

Why EPOLLOUT changes how EPOLLIN is handled?

The documentation is unclear as to whether events are combined or not and my tests show that they are in some occasions but not always. Consider man 7 epoll: Since even with edge-triggered epoll, multiple events can be generated upon receipt of…
Douglas
  • 33
  • 1
  • 3
3
votes
3 answers

Epoll in EPOLLET mode returning 2 EPOLLIN before reading from the socket

The epoll manpage says that a fd registered with EPOLLET(edge triggered) shouldn't notify twice EPOLLIN if no read has been done. So after an EPOLLIN you need to empty the buffer before epoll_wait being able to return a new EPOLLIN on new data. …
Arkaitz Jimenez
  • 22,500
  • 11
  • 75
  • 105
3
votes
1 answer

epoll: losing some EPOLLOUT events?

This is how my server looks like: -WorkerThread(s): calls epoll_wait, accepts connections, sets fd nonblocking(EPOLLIN | EPOLLOUT | EPOLLET | EPOLLRDHUP) calls recv until EAGAIN on EPOLLIN event and pushes all data to global…
Mike Jackson
  • 183
  • 1
  • 12
2
votes
1 answer

epoll events do not raise SIGIO

Based on my research, you can add an epoll file descriptor to poll, select, or another epoll and it will return POLLIN if events are available. According to epoll(7): Q3 Is the epoll file descriptor itself poll/epoll/selectable? A3 Yes. …
user233009
  • 296
  • 2
  • 11
2
votes
1 answer

Blocking read on GPIO from Python: How to block using epoll() and select.EPOLLET

I'm experimenting with GPIO access from Python on an embedded system (ARM core), which is running linux built with Buildroot (kernel 4.1.15). I want my code to BLOCK waiting for a pin change on GPIO2 (i.e. I don't want to poll the pin by calling…
Jeremy
  • 1,083
  • 3
  • 13
  • 25
2
votes
1 answer

Is rearming file descriptors for epoll thread safe?

From this question I know that I can call epoll_ctl(2) while another thread is blocking on epoll_wait(2). I still have a question though. When using epoll with the EPOLLONESHOT flag only one event is fired and the fd has to be rearmed using…
Richard
  • 1,117
  • 11
  • 31
2
votes
2 answers

epoll - is EPOLLET prone to race conditions?

Process B epolls on the pipe (EPOLLIN|EPOLLET). Process A writes 1KiB in pipe. Process B wakes up. Process B reads 1KiB from the pipe. Process A writes 1KiB in pipe. Process B epolls on the pipe. The state of the pipe does not change during epoll,…
Hristo Venev
  • 972
  • 5
  • 17
1
2 3