mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-03-20 13:40:13 +00:00
Platform_pipe: call WSAStartup/WSACleanup explicitly
Not all pipes are destroyed upon common_cleanup call (which calls WSACleanup).
This commit is contained in:
@@ -116,6 +116,35 @@ static void * worker(void *args)
|
||||
|
||||
int platform_pipe_init(fd_t p[2])
|
||||
{
|
||||
#ifdef WIN32
|
||||
// This needs to be called twice, indeed, since WSACleanup will be run
|
||||
// on both ends. This call is also required because not all pipes are
|
||||
// destroyed before common_cleanup which calls WSACleanup
|
||||
WSADATA wsaData;
|
||||
int err = WSAStartup(MAKEWORD(2, 2), &wsaData);
|
||||
if (err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error %d.", err);
|
||||
return -1;
|
||||
}
|
||||
if (LOBYTE(wsaData.wVersion) != 2 || HIBYTE(wsaData.wVersion) != 2) {
|
||||
fprintf(stderr, "Counld not found usable version of Winsock.\n");
|
||||
WSACleanup();
|
||||
return -1;
|
||||
}
|
||||
err = WSAStartup(MAKEWORD(2, 2), &wsaData);
|
||||
if (err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error %d.", err);
|
||||
WSACleanup();
|
||||
return -1;
|
||||
}
|
||||
if (LOBYTE(wsaData.wVersion) != 2 || HIBYTE(wsaData.wVersion) != 2) {
|
||||
fprintf(stderr, "Counld not found usable version of Winsock.\n");
|
||||
WSACleanup();
|
||||
WSACleanup();
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
struct params par;
|
||||
fd_t sock = open_socket(&par.port);
|
||||
if (sock == INVALID_SOCKET) {
|
||||
@@ -146,5 +175,8 @@ int platform_pipe_init(fd_t p[2])
|
||||
void platform_pipe_close(fd_t pipe)
|
||||
{
|
||||
CLOSESOCKET(pipe);
|
||||
#ifdef WIN32
|
||||
WSACleanup();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user