-
Notifications
You must be signed in to change notification settings - Fork 390
Closed
Labels
A-filesArea: related to files, paths, sockets, file descriptors, or handlesArea: related to files, paths, sockets, file descriptors, or handlesA-shimsArea: This affects the external function shimsArea: This affects the external function shimsC-enhancementCategory: a PR with an enhancement or an issue tracking an accepted enhancementCategory: a PR with an enhancement or an issue tracking an accepted enhancement
Description
In #3712, any epoll_wait
call with non-zero timeout value is currently rejected using throw_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:
- Refactor the main logic of
epoll_wait
into a function, as demonstrated in a1fc187. This can also be done together with the step below. - Use
this.block_thread
inepoll_wait
, andthis.unblock_thread
incheck_and_update_readiness
.
2.1 To getthis.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:
thread 1 | thread 2
epoll_wait on epoll file descriptor 5 blocks |
| close(5)
|
> What should happen here? Reject the close or terminate the blocking operation?
It seems like closing a file descriptor while blocking on it is UB, related SO discussion:
Metadata
Metadata
Assignees
Labels
A-filesArea: related to files, paths, sockets, file descriptors, or handlesArea: related to files, paths, sockets, file descriptors, or handlesA-shimsArea: This affects the external function shimsArea: This affects the external function shimsC-enhancementCategory: a PR with an enhancement or an issue tracking an accepted enhancementCategory: a PR with an enhancement or an issue tracking an accepted enhancement