diff options
author | David Benjamin <davidben@chromium.org> | 2015-02-21 09:54:29 +0300 |
---|---|---|
committer | Adam Langley <agl@google.com> | 2015-02-23 22:59:06 +0300 |
commit | 87c8a643e1dd290780a20a11c5c98b043da387f6 (patch) | |
tree | 577fe75b66e2c077c16c0012009de7bb687c110d /crypto/bio | |
parent | 6204eba91ed9d1d5b99879592bfdbef0f3d0660b (diff) |
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>
Diffstat (limited to 'crypto/bio')
-rw-r--r-- | crypto/bio/socket.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/crypto/bio/socket.c b/crypto/bio/socket.c index 3f3884ce..75412cf2 100644 --- a/crypto/bio/socket.c +++ b/crypto/bio/socket.c @@ -66,6 +66,8 @@ #pragma warning(push, 3) #include <WinSock2.h> #pragma warning(pop) + +#pragma comment(lib, "Ws2_32.lib") #endif #include "internal.h" |