From f4ce5a285167e7656037096f77f04ab80a010453 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sat, 14 Jan 2017 13:00:55 -0800 Subject: Windows TCP now working. There are lots of changes here, mostly stuff we did in support of Windows TCP. However, there are some bugs that were fixed, and we added some new error codes, and generalized the handling of some failures during accept. Windows IPC (NamedPipes) is still missing. --- src/platform/windows/win_thread.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src/platform/windows/win_thread.c') diff --git a/src/platform/windows/win_thread.c b/src/platform/windows/win_thread.c index 4f323616..631883fc 100644 --- a/src/platform/windows/win_thread.c +++ b/src/platform/windows/win_thread.c @@ -125,8 +125,11 @@ nni_plat_thr_init(nni_plat_thr *thr, void (*fn)(void *), void *arg) thr->func = fn; thr->arg = arg; - thr->handle = (HANDLE) _beginthreadex(NULL, 0, - nni_plat_thr_main, thr, 0, NULL); + // We could probably even go down to 8k... but crypto for some + // protocols might get bigger than this. 1MB is waaay too big. + thr->handle = (HANDLE) _beginthreadex(NULL, 16384, + nni_plat_thr_main, thr, STACK_SIZE_PARAM_IS_A_RESERVATION, + NULL); if (thr->handle == NULL) { return (NNG_ENOMEM); // Best guess... } @@ -166,6 +169,17 @@ nni_plat_init(int (*helper)(void)) Sleep(1); } if (!inited) { + WSADATA data; + WORD ver; + ver = MAKEWORD(2, 2); + if (WSAStartup(MAKEWORD(2, 2), &data) != 0) { + InterlockedExchange(&initing, 0); + if ((LOBYTE(data.wVersion) != 2) || + (HIBYTE(data.wVersion) != 2)) { + nni_panic("got back wrong winsock ver"); + } + return (NNG_ENOMEM); + } helper(); inited = 1; } @@ -178,6 +192,7 @@ nni_plat_init(int (*helper)(void)) void nni_plat_fini(void) { + WSACleanup(); } -- cgit v1.2.3-70-g09d2