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()
85
85
// close server and ensure we can start a new server on the previous address
86
86
// the pending SQLite process should not inherit the existing server socket
87
87
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
+
89
102
$ this ->assertTrue (is_resource ($ server ));
90
103
fclose ($ server );
91
104
You can’t perform that action at this time.
0 commit comments