util: move socket_init() to osdep.c
vscclient needs to call socket_init() for portability. Moving to osdep.c since it has no internal dependency. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Alon Levy <alevy@redhat.com>
This commit is contained in:
parent
e2d9c5e769
commit
d3bf825e59
23
util/osdep.c
23
util/osdep.c
@ -406,3 +406,26 @@ bool fips_get_state(void)
|
|||||||
return fips_enabled;
|
return fips_enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
static void socket_cleanup(void)
|
||||||
|
{
|
||||||
|
WSACleanup();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int socket_init(void)
|
||||||
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
WSADATA Data;
|
||||||
|
int ret, err;
|
||||||
|
|
||||||
|
ret = WSAStartup(MAKEWORD(2, 2), &Data);
|
||||||
|
if (ret != 0) {
|
||||||
|
err = WSAGetLastError();
|
||||||
|
fprintf(stderr, "WSAStartup: %d\n", err);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
atexit(socket_cleanup);
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@ -974,27 +974,3 @@ int socket_dgram(SocketAddress *remote, SocketAddress *local, Error **errp)
|
|||||||
qemu_opts_del(opts);
|
qemu_opts_del(opts);
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
static void socket_cleanup(void)
|
|
||||||
{
|
|
||||||
WSACleanup();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int socket_init(void)
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
WSADATA Data;
|
|
||||||
int ret, err;
|
|
||||||
|
|
||||||
ret = WSAStartup(MAKEWORD(2,2), &Data);
|
|
||||||
if (ret != 0) {
|
|
||||||
err = WSAGetLastError();
|
|
||||||
fprintf(stderr, "WSAStartup: %d\n", err);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
atexit(socket_cleanup);
|
|
||||||
#endif
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user