Riccardo Schirone af337b1439
Prevent multiple threads from opening new files at the same time ##r2r (#17736)
This should fix a nasty issue with r2r, where tests never terminated.
That was caused by the jq process waiting indefinitely for input from
fd0, because the other end of the pipe was never closed.

Indeed r2r_subprocess_start forks and closes known unnecessary opened fd
in the child process, however it does not consider also all the other
file descriptors that could have been created by other threads
simultaneously. As fd are per-process and not per-thread, file
descriptors created by other threads while doing e.g. pipe to spawn a
separate jq process will clutter other threads (and following jq
processes) as well. If two jq processes happen to keep a fd to the other
end of the pipe for the fd0 of the other jq process, none of them
terminates, thus they never close those spurious file descriptors,
causing tests to hang.

This tries to fix the issue by making sure only one thread at a time can
start a subprocess. In this way no other FDs can be created while a
thread is in the middle of r2r_subprocess_start.
2020-09-30 10:40:23 +02:00
..
2017-01-13 12:49:42 +01:00