Skip to content

Commit

Permalink
Fix issue #335
Browse files Browse the repository at this point in the history
The CreateEvent function requests EVENT_ALL_ACCESS access rights
when the event object already exists. This causes problems
when the event object is created from a service.
The solution is to call OpenEvent function when the CreateEvent
failed due to access control.
The proper solution would be to use CreateEventEx function, but
this one is not available on Windows XP.
  • Loading branch information
hurtonm committed Apr 11, 2012
1 parent 899778d commit cfa6f4b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/signaler.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -238,7 +238,13 @@ int zmq::signaler_t::make_fdpair (fd_t *r_, fd_t *w_)
// two instances of the library don't accidentally create signaler // two instances of the library don't accidentally create signaler
// crossing the process boundary. // crossing the process boundary.
// We'll use named event object to implement the critical section. // We'll use named event object to implement the critical section.
HANDLE sync = CreateEvent (NULL, FALSE, TRUE, TEXT("zmq-signaler-port-sync")); // 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"));
if (sync == NULL && GetLastError () == ERROR_ACCESS_DENIED)
sync = OpenEvent (SYNCHRONIZE, FALSE, TEXT ("zmq-signaler-port-sync"));

win_assert (sync != NULL); win_assert (sync != NULL);


// Enter the critical section. // Enter the critical section.
Expand Down

0 comments on commit cfa6f4b

Please sign in to comment.