Skip to content

Commit 7997d76

Browse files
committed
add some notes about libev
1 parent 5a49dbc commit 7997d76

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/libev/libev-select-notes.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# libev select backend notes
2+
3+
## Build composition
4+
- `libev_la_SOURCES` only lists `ev.c` and `event.c` because `ev.c` directly
5+
`#include`s the backend implementations such as `ev_select.c`. This means the
6+
select backend is compiled whenever `ev.c` is built, without needing to list
7+
the backend sources separately.
8+
9+
## Signal handling and readiness notification
10+
- When a signal arrives, `ev_sighandler()` invokes `ev_feed_signal()`, which
11+
records the pending signal and calls `evpipe_write()` to wake the loop via the
12+
self-pipe using the async-signal-safe `write()` system call.
13+
- The select backend copies the tracked fd sets before calling `select()`.
14+
If `select()` returns with `EINTR`, the backend simply returns to the main
15+
loop. Because the self-pipe write occurred before the interruption completes,
16+
the pipe remains readable and will be observed on the next poll iteration,
17+
ensuring the readiness notification is delivered.
18+
- `select_poll()` also detects `EBADF` and `ENOMEM`, reporting them via
19+
libev’s error helpers, and it retries interrupted `read()`/`write()` calls to
20+
drain or signal the pipe, so the loop cannot miss the wakeup due to transient
21+
EINTR interruptions.

0 commit comments

Comments
 (0)