Document how to hook/attach handler to "ready to receive connections"
- Dominant language
- Rust
- Stars
- 24.8k
- Forks
- 1.9k
- Avg merge
- 23h 10m
- Merged PRs (30d)
- 26
Description
I'm currently planning out a PR to fix some race conditions in [miniserve](https://github.com/svenstaro/miniserve)'s test suite, and one of the problem tests is a functional test which has been assuming that, if it waits on a `println!` of bound sockets that happens after `HttpServer::run`, then the sockets will be ready to receive connections.
Given the bug, it's clear that "The [Server](https://docs.rs/actix-web/latest/actix_web/dev/struct.Server.html) must be awaited or polled in order to start running" is more important here, but I'm having trouble finding anything in the actix-web docs about how to hang a handler off "listening threads are ready to receive connections".
Specifically, I need it so I can implement something in the vein of Xephyr's `-displayfd` to more generally solve race conditions in `miniserve`'s test suite:
```
ssokolow@monolith-tng miniserve [test-race-fix] % Xephyr -help
[...]
-displayfd fd file descriptor to write display number to when ready to connect
[...]
```
**NOTE:** I don't even have commit access to miniserve, so "re-architect the entire test suite to use existing testing affordances" probably isn't an answer that I have the authority to bring back and, if given it, I'll probably just incorporate some kind of "sleep-and-retry" loop into the test harness in my PR, given that I sympathize with the desire for integration testing that extends all the way to the CLI arguments and stdout/stderr output.
**EDIT:** I'm assuming the "or polled" may be key, given that I've done similar "Spin the GTK/Qt event loop once to dispatch the queued X11 calls and then exit" stuff in some of my projects with "do one thing, then quit" CLI interfaces, but I don't want to gamble on that.
Contributor guide
Assessment
This issue has not been assessed yet.