Skip to content

Document how to hook/attach handler to "ready to receive connections" #3714

@ssokolow

Description

@ssokolow

I'm currently planning out a PR to fix some race conditions in 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 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions