Implement blocking support for epoll #3805
Labels
A-files
Area: related to files, paths, sockets, file descriptors, or handles
A-shims
Area: This affects the external function shims
C-enhancement
Category: a PR with an enhancement or an issue tracking an accepted enhancement
In #3712, any
epoll_wait
call with non-zero timeout value is currently rejected usingthrow_unsup_format
because blocking for file descriptions is not supported yet. This is part of the work for tokio support in #602 .Below are some very high-level and rough steps that would be needed to support blocking epoll:
epoll_wait
into a function, as demonstrated in a1fc187. This can also be done together with the step below.this.block_thread
inepoll_wait
, andthis.unblock_thread
incheck_and_update_readiness
.2.1 To get
this.unblock_thread
to work, we might need to introduce some data structures to know which thread should we wake up when there is an epoll notification for a file description.@oli-obk mentioned an interesting test case that might be a data race on file description level: one thread
close
epoll file descriptor while another thread is blocking on that epoll file descriptor.Visualisation:
It seems like closing a file descriptor while blocking on it is UB, related SO discussion:
The text was updated successfully, but these errors were encountered: