Added WSAStartup() and WSACleanup() calls to zts_start() and zts_stop()

This commit is contained in:
Joseph Henry
2017-10-10 12:23:42 -07:00
parent f9754d8216
commit 27dddb2f45

View File

@@ -55,6 +55,10 @@ namespace ZeroTier {
ZeroTier::Mutex _multiplexer_lock; ZeroTier::Mutex _multiplexer_lock;
} }
#if defined(__MINGW32__) || defined(__MINGW64__)
WSADATA wsaData;
#endif
/****************************************************************************/ /****************************************************************************/
/* ZeroTier Core helper functions for libzt - DON'T CALL THESE DIRECTLY */ /* ZeroTier Core helper functions for libzt - DON'T CALL THESE DIRECTLY */
/****************************************************************************/ /****************************************************************************/
@@ -395,6 +399,9 @@ void zts_start(const char *path)
if (path) { if (path) {
ZeroTier::homeDir = path; ZeroTier::homeDir = path;
} }
#if defined(__MINGW32__) || defined(__MINGW64__)
WSAStartup(MAKEWORD(2, 2), &wsaData) // initialize WinSock. Used in Phy for loopback pipe
#endif
pthread_t service_thread; pthread_t service_thread;
pthread_create(&service_thread, NULL, zts_start_service, NULL); pthread_create(&service_thread, NULL, zts_start_service, NULL);
} }
@@ -426,6 +433,9 @@ void zts_stop() {
ZeroTier::zt1Service->terminate(); ZeroTier::zt1Service->terminate();
disableTaps(); disableTaps();
} }
#if defined(__MINGW32__) || defined(__MINGW64__)
WSACleanup(); // clean up WinSock
#endif
} }
void zts_get_homepath(char *homePath, int len) { void zts_get_homepath(char *homePath, int len) {