File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -85,7 +85,20 @@ public function testOpenMemoryDatabaseShouldNotInheritActiveFileDescriptors()
8585 // close server and ensure we can start a new server on the previous address
8686 // the pending SQLite process should not inherit the existing server socket
8787 fclose ($ server );
88- $ server = stream_socket_server ('tcp:// ' . $ address );
88+
89+ $ server = @stream_socket_server ('tcp:// ' . $ address );
90+ if ($ server === false ) {
91+ // There's a very short race condition where the forked php process
92+ // first has to `dup()` the file descriptor specs before invoking
93+ // `exec()` to switch to the actual `ssh` child process. We don't
94+ // need to wait for the child process to be ready, but only for the
95+ // forked process to close the file descriptors. This happens ~80%
96+ // of times on single core machines and almost never on multi core
97+ // systems, so simply wait 5ms (plenty of time!) and retry again.
98+ usleep (5000 );
99+ $ server = stream_socket_server ('tcp:// ' . $ address );
100+ }
101+
89102 $ this ->assertTrue (is_resource ($ server ));
90103 fclose ($ server );
91104
You can’t perform that action at this time.
0 commit comments