sapling/eden/fs/win
Xavier Deguillard 16bbe5baa2 win: only inherit the pipe handles
Summary:
The CreateProcess API allows inheritable handles to be available in the spawned
process by passing a flag to it. What the documentation for this API leave to
the imagination is what happens when processes are spawned concurrently in
multiple threads and handles are opened and made inheritable while doing this.
The answer is obvious but the consequences aren't: they are inherited.

When anonymous Pipes are used, one end needs to be inheritable for the spawned
process to being able use it, but if one is created concurrently with spawning
a process, that other process may have an open handle to that unrelated pipe.
And since to detect that a pipe is closed, all handles to the other end needs
to be closed, this can lead to never being able to detect that it is closed...

This scenario is exactly what is happening in eden when spawning the Mercurial
process, and when one of these processes would die, eden would just hang trying
to write to the pipe, not knowing that the process was already gone. To unblock
eden, all the hg.real processes had to be killed, as this would close all the
pipe handles, and then eden would detect that the pipe was closed and re-spawn
Mercurial (only for the exact same thing to happen).

In order to fix this, we need to tell CreateProcess to only inherit the pipes
handles, and nothing else.

Reviewed By: wez

Differential Revision: D21895537

fbshipit-source-id: 3c84a1d0316b50b5750f554fa20f72f59a718882
2020-06-10 19:29:18 -07:00
..
mount win: change the argument order for writeFile 2020-05-05 18:14:54 -07:00
service unify the EdenMain code on Windows 2020-05-28 09:01:03 -07:00
store Switch to new EdenMount 2020-04-24 08:33:27 -07:00
testharness Add APIs to remove cached files and tombstones from ProjectedFS cache 2020-04-24 12:46:18 -07:00
utils win: only inherit the pipe handles 2020-06-10 19:29:18 -07:00
CMakeLists.txt Remove old version of Windows TestMounts 2020-04-24 08:33:27 -07:00
Edenwin.h Tidy up license headers 2019-10-11 05:28:23 -07:00