mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-06-20 01:58:29 +02:00
_dbus_win_startup_winsock: be thread-safe
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68610 Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
This commit is contained in:
parent
53966707ae
commit
b7a91bfd46
1 changed files with 28 additions and 7 deletions
|
|
@ -672,21 +672,26 @@ _dbus_connect_named_pipe (const char *path,
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns #FALSE if no memory
|
||||||
void
|
*/
|
||||||
|
dbus_bool_t
|
||||||
_dbus_win_startup_winsock (void)
|
_dbus_win_startup_winsock (void)
|
||||||
{
|
{
|
||||||
/* Straight from MSDN, deuglified */
|
/* Straight from MSDN, deuglified */
|
||||||
|
|
||||||
|
/* Protected by _DBUS_LOCK_sysdeps */
|
||||||
static dbus_bool_t beenhere = FALSE;
|
static dbus_bool_t beenhere = FALSE;
|
||||||
|
|
||||||
WORD wVersionRequested;
|
WORD wVersionRequested;
|
||||||
WSADATA wsaData;
|
WSADATA wsaData;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
if (!_DBUS_LOCK (sysdeps))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
if (beenhere)
|
if (beenhere)
|
||||||
return;
|
goto out;
|
||||||
|
|
||||||
wVersionRequested = MAKEWORD (2, 0);
|
wVersionRequested = MAKEWORD (2, 0);
|
||||||
|
|
||||||
|
|
@ -710,6 +715,10 @@ _dbus_win_startup_winsock (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
beenhere = TRUE;
|
beenhere = TRUE;
|
||||||
|
|
||||||
|
out:
|
||||||
|
_DBUS_UNLOCK (sysdeps);
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1054,7 +1063,11 @@ _dbus_full_duplex_pipe (int *fd1,
|
||||||
int len;
|
int len;
|
||||||
u_long arg;
|
u_long arg;
|
||||||
|
|
||||||
_dbus_win_startup_winsock ();
|
if (!_dbus_win_startup_winsock ())
|
||||||
|
{
|
||||||
|
_DBUS_SET_OOM (error);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
temp = socket (AF_INET, SOCK_STREAM, 0);
|
temp = socket (AF_INET, SOCK_STREAM, 0);
|
||||||
if (temp == INVALID_SOCKET)
|
if (temp == INVALID_SOCKET)
|
||||||
|
|
@ -1498,7 +1511,11 @@ _dbus_connect_tcp_socket_with_nonce (const char *host,
|
||||||
|
|
||||||
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
|
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
|
||||||
|
|
||||||
_dbus_win_startup_winsock ();
|
if (!_dbus_win_startup_winsock ())
|
||||||
|
{
|
||||||
|
_DBUS_SET_OOM (error);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
_DBUS_ZERO (hints);
|
_DBUS_ZERO (hints);
|
||||||
|
|
||||||
|
|
@ -1643,7 +1660,11 @@ _dbus_listen_tcp_socket (const char *host,
|
||||||
*fds_p = NULL;
|
*fds_p = NULL;
|
||||||
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
|
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
|
||||||
|
|
||||||
_dbus_win_startup_winsock ();
|
if (!_dbus_win_startup_winsock ())
|
||||||
|
{
|
||||||
|
_DBUS_SET_OOM (error);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
_DBUS_ZERO (hints);
|
_DBUS_ZERO (hints);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue