mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-28 16:15:23 +08:00
Problem: race condition in making socket non-inheritable
Solution: create sockets with WSA_FLAG_NO_HANDLE_INHERIT
This commit is contained in:
parent
44da0e7e42
commit
2d9a8955f5
@ -76,7 +76,14 @@ zmq::fd_t zmq::open_socket (int domain_, int type_, int protocol_)
|
|||||||
type_ |= SOCK_CLOEXEC;
|
type_ |= SOCK_CLOEXEC;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined ZMQ_HAVE_WINDOWS && defined WSA_FLAG_NO_HANDLE_INHERIT
|
||||||
|
// if supported, create socket with WSA_FLAG_NO_HANDLE_INHERIT, such that
|
||||||
|
// the race condition in making it non-inheritable later is avoided
|
||||||
|
const fd_t s = WSASocket (domain_, type_, protocol_, NULL, 0,
|
||||||
|
WSA_FLAG_NO_HANDLE_INHERIT);
|
||||||
|
#else
|
||||||
const fd_t s = socket (domain_, type_, protocol_);
|
const fd_t s = socket (domain_, type_, protocol_);
|
||||||
|
#endif
|
||||||
if (s == retired_fd) {
|
if (s == retired_fd) {
|
||||||
#ifdef ZMQ_HAVE_WINDOWS
|
#ifdef ZMQ_HAVE_WINDOWS
|
||||||
errno = wsa_error_to_errno (WSAGetLastError ());
|
errno = wsa_error_to_errno (WSAGetLastError ());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user