clue / reactphp-ssh-proxy

Async SSH proxy connector and forwarder, tunnel any TCP/IP-based protocol through an SSH server, built on top of ReactPHP.
https://clue.engineering/2018/introducing-reactphp-ssh-proxy
MIT License
21 stars 7 forks source link

Avoid race condition for forked process in test suite #14

Closed clue closed 5 years ago

clue commented 5 years ago

There's a very short race condition where the forked php process first has to dup() the file descriptor specs before invoking exec() to switch to the actual ssh child process. We don't need to wait for the child process to be ready, but only for the forked process to close the file descriptors. This happens ~80% of times on single core machines and almost never on multi core systems, so simply wait 5ms (plenty of time!) and retry again.

Builds on top of https://github.com/clue/reactphp-sqlite/pull/15 and #10