Commit 57f84d68 authored by Sébastien Rombauts's avatar Sébastien Rombauts

Windows CE support : some more #if !defined _WIN32_WCE

- Windows CE does not manage security attributes (no SetSecurityDescriptorDacl(), SetEvent (NULL, xxx) ...)
- Windows CE does not inheritance of sockets for child process (SetHandleInformation ((HANDLE) *w_, HANDLE_FLAG_INHERIT...)
- see comments about story "Porting ZeroMQ to Windows Mobile" on webpage http://www.zeromq.org/story:5
parent 05bb0ead
...@@ -238,6 +238,8 @@ int zmq::signaler_t::make_fdpair (fd_t *r_, fd_t *w_) ...@@ -238,6 +238,8 @@ int zmq::signaler_t::make_fdpair (fd_t *r_, fd_t *w_)
return 0; return 0;
#elif defined ZMQ_HAVE_WINDOWS #elif defined ZMQ_HAVE_WINDOWS
#if !defined _WIN32_WCE
// Windows CE does not manage security attributes
SECURITY_DESCRIPTOR sd; SECURITY_DESCRIPTOR sd;
SECURITY_ATTRIBUTES sa; SECURITY_ATTRIBUTES sa;
memset (&sd, 0, sizeof (sd)); memset (&sd, 0, sizeof (sd));
...@@ -248,6 +250,7 @@ int zmq::signaler_t::make_fdpair (fd_t *r_, fd_t *w_) ...@@ -248,6 +250,7 @@ int zmq::signaler_t::make_fdpair (fd_t *r_, fd_t *w_)
sa.nLength = sizeof(SECURITY_ATTRIBUTES); sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.lpSecurityDescriptor = &sd; sa.lpSecurityDescriptor = &sd;
#endif
// This function has to be in a system-wide critical section so that // This function has to be in a system-wide critical section so that
// two instances of the library don't accidentally create signaler // two instances of the library don't accidentally create signaler
...@@ -256,7 +259,11 @@ int zmq::signaler_t::make_fdpair (fd_t *r_, fd_t *w_) ...@@ -256,7 +259,11 @@ int zmq::signaler_t::make_fdpair (fd_t *r_, fd_t *w_)
// Note that if the event object already exists, the CreateEvent requests // Note that if the event object already exists, the CreateEvent requests
// EVENT_ALL_ACCESS access right. If this fails, we try to open // EVENT_ALL_ACCESS access right. If this fails, we try to open
// the event object asking for SYNCHRONIZE access only. // the event object asking for SYNCHRONIZE access only.
#if !defined _WIN32_WCE
HANDLE sync = CreateEvent (&sa, FALSE, TRUE, TEXT ("Global\\zmq-signaler-port-sync")); HANDLE sync = CreateEvent (&sa, FALSE, TRUE, TEXT ("Global\\zmq-signaler-port-sync"));
#else
HANDLE sync = CreateEvent (NULL, FALSE, TRUE, TEXT ("Global\\zmq-signaler-port-sync"));
#endif
if (sync == NULL && GetLastError () == ERROR_ACCESS_DENIED) if (sync == NULL && GetLastError () == ERROR_ACCESS_DENIED)
sync = OpenEvent (SYNCHRONIZE | EVENT_MODIFY_STATE, FALSE, TEXT ("Global\\zmq-signaler-port-sync")); sync = OpenEvent (SYNCHRONIZE | EVENT_MODIFY_STATE, FALSE, TEXT ("Global\\zmq-signaler-port-sync"));
...@@ -303,9 +310,13 @@ int zmq::signaler_t::make_fdpair (fd_t *r_, fd_t *w_) ...@@ -303,9 +310,13 @@ int zmq::signaler_t::make_fdpair (fd_t *r_, fd_t *w_)
*w_ = WSASocket (AF_INET, SOCK_STREAM, 0, NULL, 0, 0); *w_ = WSASocket (AF_INET, SOCK_STREAM, 0, NULL, 0, 0);
wsa_assert (*w_ != INVALID_SOCKET); wsa_assert (*w_ != INVALID_SOCKET);
#if !defined _WIN32_WCE
// On Windows, preventing sockets to be inherited by child processes. // On Windows, preventing sockets to be inherited by child processes.
BOOL brc = SetHandleInformation ((HANDLE) *w_, HANDLE_FLAG_INHERIT, 0); BOOL brc = SetHandleInformation ((HANDLE) *w_, HANDLE_FLAG_INHERIT, 0);
win_assert (brc); win_assert (brc);
#else
BOOL brc;
#endif
// Set TCP_NODELAY on writer socket. // Set TCP_NODELAY on writer socket.
rc = setsockopt (*w_, IPPROTO_TCP, TCP_NODELAY, rc = setsockopt (*w_, IPPROTO_TCP, TCP_NODELAY,
...@@ -341,10 +352,11 @@ int zmq::signaler_t::make_fdpair (fd_t *r_, fd_t *w_) ...@@ -341,10 +352,11 @@ int zmq::signaler_t::make_fdpair (fd_t *r_, fd_t *w_)
win_assert (brc != 0); win_assert (brc != 0);
if (*r_ != INVALID_SOCKET) { if (*r_ != INVALID_SOCKET) {
#if !defined _WIN32_WCE
// On Windows, preventing sockets to be inherited by child processes. // On Windows, preventing sockets to be inherited by child processes.
brc = SetHandleInformation ((HANDLE) *r_, HANDLE_FLAG_INHERIT, 0); brc = SetHandleInformation ((HANDLE) *r_, HANDLE_FLAG_INHERIT, 0);
win_assert (brc); win_assert (brc);
#endif
return 0; return 0;
} else { } else {
// Cleanup writer if connection failed // Cleanup writer if connection failed
......
...@@ -174,9 +174,11 @@ int zmq::tcp_listener_t::set_address (const char *addr_) ...@@ -174,9 +174,11 @@ int zmq::tcp_listener_t::set_address (const char *addr_)
errno = wsa_error_to_errno (WSAGetLastError ()); errno = wsa_error_to_errno (WSAGetLastError ());
return -1; return -1;
} }
#if !defined _WIN32_WCE
// On Windows, preventing sockets to be inherited by child processes. // On Windows, preventing sockets to be inherited by child processes.
BOOL brc = SetHandleInformation ((HANDLE) s, HANDLE_FLAG_INHERIT, 0); BOOL brc = SetHandleInformation ((HANDLE) s, HANDLE_FLAG_INHERIT, 0);
win_assert (brc); win_assert (brc);
#endif
#else #else
if (s == -1) if (s == -1)
return -1; return -1;
...@@ -258,9 +260,11 @@ zmq::fd_t zmq::tcp_listener_t::accept () ...@@ -258,9 +260,11 @@ zmq::fd_t zmq::tcp_listener_t::accept ()
WSAGetLastError () == WSAENOBUFS); WSAGetLastError () == WSAENOBUFS);
return retired_fd; return retired_fd;
} }
#if !defined _WIN32_WCE
// On Windows, preventing sockets to be inherited by child processes. // On Windows, preventing sockets to be inherited by child processes.
BOOL brc = SetHandleInformation ((HANDLE) sock, HANDLE_FLAG_INHERIT, 0); BOOL brc = SetHandleInformation ((HANDLE) sock, HANDLE_FLAG_INHERIT, 0);
win_assert (brc); win_assert (brc);
#endif
#else #else
if (sock == -1) { if (sock == -1) {
errno_assert (errno == EAGAIN || errno == EWOULDBLOCK || errno_assert (errno == EAGAIN || errno == EWOULDBLOCK ||
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment