Clarify purpose of epoll FD test

This commit is contained in:
Thomas Leonard 2023-03-07 10:27:11 +00:00
parent eab55876f3
commit 4cc9e1360e

View File

@ -6,7 +6,10 @@
open Eio.Std
```
## Closing an FD removes it from epoll
## Closing an FD removes it from the multiplexer
Closing an FD automatically removes it from epoll's set, meaning that you have
to re-add it using `EPOLL_CTL_ADD`, not `EPOLL_CTL_MOD`.
```ocaml
# Eio_posix.run @@ fun _env ->
@ -14,6 +17,8 @@ open Eio.Std
let r, w = Eio_unix.pipe sw in
Eio_unix.await_writable (Eio_unix.FD.peek w)
);
(* [r] and [w] are now closed. We'll likely allocate the same FD numbers the second time.
Check we don't get confused and try to [EPOLL_CTL_MOD] them. *)
Switch.run (fun sw ->
let r, w = Eio_unix.pipe sw in
Eio_unix.await_writable (Eio_unix.FD.peek w)