mirror of
https://github.com/zeromq/libzmq.git
synced 2025-11-09 23:57:50 +01:00
Fix issue 335
By assigning a SECURITY_DESCRIPTOR to the event we gain the ability to share it between service and console programs. We also added EVENT_MODIFY_STATE as a requirement to OpenEvent so we can SetEvent later in the method.
This commit is contained in:
@@ -233,6 +233,14 @@ int zmq::signaler_t::make_fdpair (fd_t *r_, fd_t *w_)
|
||||
return 0;
|
||||
|
||||
#elif defined ZMQ_HAVE_WINDOWS
|
||||
SECURITY_DESCRIPTOR sd = {0};
|
||||
SECURITY_ATTRIBUTES sa = {0};
|
||||
|
||||
InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION);
|
||||
SetSecurityDescriptorDacl(&sd, TRUE, 0, FALSE);
|
||||
|
||||
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
|
||||
sa.lpSecurityDescriptor = &sd;
|
||||
|
||||
// This function has to be in a system-wide critical section so that
|
||||
// two instances of the library don't accidentally create signaler
|
||||
@@ -241,9 +249,9 @@ int zmq::signaler_t::make_fdpair (fd_t *r_, fd_t *w_)
|
||||
// Note that if the event object already exists, the CreateEvent requests
|
||||
// EVENT_ALL_ACCESS access right. If this fails, we try to open
|
||||
// the event object asking for SYNCHRONIZE access only.
|
||||
HANDLE sync = CreateEvent (NULL, FALSE, TRUE, TEXT ("zmq-signaler-port-sync"));
|
||||
HANDLE sync = CreateEvent (&sa, FALSE, TRUE, TEXT ("zmq-signaler-port-sync"));
|
||||
if (sync == NULL && GetLastError () == ERROR_ACCESS_DENIED)
|
||||
sync = OpenEvent (SYNCHRONIZE, FALSE, TEXT ("zmq-signaler-port-sync"));
|
||||
sync = OpenEvent (SYNCHRONIZE | EVENT_MODIFY_STATE, FALSE, TEXT ("zmq-signaler-port-sync"));
|
||||
|
||||
win_assert (sync != NULL);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user