Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
bd41087a
Commit
bd41087a
authored
Nov 28, 2013
by
KIU Shueng Chuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make win32 signaler support ephemeral ports
parent
a9eb6f79
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
20 deletions
+35
-20
signaler.cpp
src/signaler.cpp
+35
-20
No files found.
src/signaler.cpp
View file @
bd41087a
...
...
@@ -306,16 +306,21 @@ 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.
# if !defined _WIN32_WCE
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
)
sync
=
OpenEvent
(
SYNCHRONIZE
|
EVENT_MODIFY_STATE
,
FALSE
,
TEXT
(
"Global
\\
zmq-signaler-port-sync"
));
win_assert
(
sync
!=
NULL
);
HANDLE
sync
=
NULL
;
// Create critical section only if using fixed signaler port
if
(
signaler_port
!=
0
)
{
# if !defined _WIN32_WCE
sync
=
CreateEvent
(
&
sa
,
FALSE
,
TRUE
,
TEXT
(
"Global
\\
zmq-signaler-port-sync"
));
# else
sync
=
CreateEvent
(
NULL
,
FALSE
,
TRUE
,
TEXT
(
"Global
\\
zmq-signaler-port-sync"
));
# endif
if
(
sync
==
NULL
&&
GetLastError
()
==
ERROR_ACCESS_DENIED
)
sync
=
OpenEvent
(
SYNCHRONIZE
|
EVENT_MODIFY_STATE
,
FALSE
,
TEXT
(
"Global
\\
zmq-signaler-port-sync"
));
win_assert
(
sync
!=
NULL
);
}
// Windows has no 'socketpair' function. CreatePipe is no good as pipe
// handles cannot be polled on. Here we create the socketpair by hand.
...
...
@@ -353,13 +358,21 @@ int zmq::signaler_t::make_fdpair (fd_t *r_, fd_t *w_)
(
char
*
)
&
tcp_nodelay
,
sizeof
(
tcp_nodelay
));
wsa_assert
(
rc
!=
SOCKET_ERROR
);
// Enter the critical section.
DWORD
dwrc
=
WaitForSingleObject
(
sync
,
INFINITE
);
zmq_assert
(
dwrc
==
WAIT_OBJECT_0
);
if
(
sync
!=
NULL
)
{
// Enter the critical section.
DWORD
dwrc
=
WaitForSingleObject
(
sync
,
INFINITE
);
zmq_assert
(
dwrc
==
WAIT_OBJECT_0
);
}
// Bind listening socket to signaler port.
rc
=
bind
(
listener
,
(
const
struct
sockaddr
*
)
&
addr
,
sizeof
(
addr
));
if
(
rc
!=
SOCKET_ERROR
&&
signaler_port
==
0
)
{
// Retrieve ephemeral port number
int
addrlen
=
sizeof
(
addr
);
rc
=
getsockname
(
listener
,
(
struct
sockaddr
*
)
&
addr
,
&
addrlen
);
}
// Listen for incoming connections.
if
(
rc
!=
SOCKET_ERROR
)
rc
=
listen
(
listener
,
1
);
...
...
@@ -380,18 +393,20 @@ int zmq::signaler_t::make_fdpair (fd_t *r_, fd_t *w_)
// We don't need the listening socket anymore. Close it.
closesocket
(
listener
);
// Exit the critical section.
BOOL
brc
=
SetEvent
(
sync
);
win_assert
(
brc
!=
0
);
if
(
sync
!=
NULL
)
{
// Exit the critical section.
BOOL
brc
=
SetEvent
(
sync
);
win_assert
(
brc
!=
0
);
// Release the kernel object
brc
=
CloseHandle
(
sync
);
win_assert
(
brc
!=
0
);
// Release the kernel object
brc
=
CloseHandle
(
sync
);
win_assert
(
brc
!=
0
);
}
if
(
*
r_
!=
INVALID_SOCKET
)
{
# if !defined _WIN32_WCE
// On Windows, preventing sockets to be inherited by child processes.
brc
=
SetHandleInformation
((
HANDLE
)
*
r_
,
HANDLE_FLAG_INHERIT
,
0
);
BOOL
brc
=
SetHandleInformation
((
HANDLE
)
*
r_
,
HANDLE_FLAG_INHERIT
,
0
);
win_assert
(
brc
);
# endif
return
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment