boringssl/ssl/test
David Benjamin 87c8a643e1 Use TCP sockets rather than socketpairs in the SSL tests.
This involves more synchronization with child exits as the kernel no longer
closes the pre-created pipes for free, but it works on Windows. As long as
TCP_NODELAY is set, the performance seems comparable. Though it does involve
dealing with graceful socket shutdown. I couldn't get that to work on Windows
without draining the socket; not even SO_LINGER worked. Current (untested)
theory is that Windows refuses to gracefully shutdown a socket if the peer
sends data after we've stopped reading.

cmd.ExtraFiles doesn't work on Windows; it doesn't use fds natively, so you
can't pass fds 4 and 5. (stdin/stdout/stderr are special slots in
CreateProcess.) We can instead use the syscall module directly and mark handles
as inheritable (and then pass the numerical values out-of-band), but that
requires synchronizing all of our shim.Start() calls and assuming no other
thread is spawning a process.

PROC_THREAD_ATTRIBUTE_HANDLE_LIST fixes threading problems, but requires
wrapping more syscalls.  exec.Cmd also doesn't let us launch the process
ourselves. Plus it still requires every handle in the list be marked
inheritable, so it doesn't help if some other thread is launching a process
with bInheritHandles TRUE but NOT using PROC_THREAD_ATTRIBUTE_HANDLE_LIST.
(Like Go, though we can take syscall.ForkLock there.)

http://blogs.msdn.com/b/oldnewthing/archive/2011/12/16/10248328.aspx

The more natively Windows option seems to be named pipes, but that too requires
wrapping more system calls. (To be fair, that isn't too painful.) They also
involve a listening server, so we'd still have to synchronize with shim.Wait()
a la net.TCPListener.

Then there's DuplicateHandle, but then we need an out-of-band signal.

All in all, one cross-platform implementation with a TCP sockets seems
simplest.

Change-Id: I38233e309a0fa6814baf61e806732138902347c0
Reviewed-on: https://boringssl-review.googlesource.com/3563
Reviewed-by: Adam Langley <agl@google.com>
2015-02-23 19:59:06 +00:00
..
runner Use TCP sockets rather than socketpairs in the SSL tests. 2015-02-23 19:59:06 +00:00
async_bio.cc Use just one style for the shim. 2015-02-10 01:18:24 +00:00
async_bio.h Use just one style for the shim. 2015-02-10 01:18:24 +00:00
bssl_shim.cc Use TCP sockets rather than socketpairs in the SSL tests. 2015-02-23 19:59:06 +00:00
CMakeLists.txt Change CMakeLists.txt to two-space indent. 2015-01-28 16:37:10 -08:00
malloc.cc aarch64 support. 2015-01-14 23:38:11 +00:00
packeted_bio.cc Use TCP sockets rather than socketpairs in the SSL tests. 2015-02-23 19:59:06 +00:00
packeted_bio.h Use just one style for the shim. 2015-02-10 01:18:24 +00:00
scoped_types.h RAII bssl_shim. 2015-02-09 20:04:05 +00:00
test_config.cc Use TCP sockets rather than socketpairs in the SSL tests. 2015-02-23 19:59:06 +00:00
test_config.h Use TCP sockets rather than socketpairs in the SSL tests. 2015-02-23 19:59:06 +00:00