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
81da391e
Commit
81da391e
authored
Sep 29, 2011
by
Martin Sustrik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use single port for creating signalers on Windows
Signed-off-by:
Martin Sustrik
<
sustrik@250bpm.com
>
parent
7a10bbe7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
7 deletions
+22
-7
config.hpp
src/config.hpp
+5
-1
signaler.cpp
src/signaler.cpp
+17
-6
No files found.
src/config.hpp
View file @
81da391e
...
...
@@ -79,7 +79,11 @@ namespace zmq
clock_precision
=
1000000
,
// Maximum transport data unit size for PGM (TPDU).
pgm_max_tpdu
=
1500
pgm_max_tpdu
=
1500
,
// On some OSes the signaler has to be emulated using a TCP
// connection. In such cases following port is used.
signaler_port
=
5905
};
}
...
...
src/signaler.cpp
View file @
81da391e
...
...
@@ -59,6 +59,7 @@
#include "signaler.hpp"
#include "likely.hpp"
#include "stdint.hpp"
#include "config.hpp"
#include "err.hpp"
#include "fd.hpp"
#include "ip.hpp"
...
...
@@ -233,6 +234,17 @@ int zmq::signaler_t::make_fdpair (fd_t *r_, fd_t *w_)
#elif defined ZMQ_HAVE_WINDOWS
// This function has to be in a system-wide critical section so that
// two instances of the library don't accidentally create signaler
// crossing the process boundary.
// We'll use named event object to implement the critical section.
HANDLE
sync
=
CreateEvent
(
NULL
,
FALSE
,
FALSE
,
"zmq-signaler-port-sync"
);
win_assert
(
sync
!=
NULL
);
// Enter the critical section.
DWORD
dwrc
=
WaitForSingleObject
(
sync
,
INFINITE
);
zmq_assert
(
dwrc
==
WAIT_OBJECT_0
);
// Windows has no 'socketpair' function. CreatePipe is no good as pipe
// handles cannot be polled on. Here we create the socketpair by hand.
*
w_
=
INVALID_SOCKET
;
...
...
@@ -258,15 +270,10 @@ int zmq::signaler_t::make_fdpair (fd_t *r_, fd_t *w_)
memset
(
&
addr
,
0
,
sizeof
(
addr
));
addr
.
sin_family
=
AF_INET
;
addr
.
sin_addr
.
s_addr
=
htonl
(
INADDR_LOOPBACK
);
addr
.
sin_port
=
0
;
addr
.
sin_port
=
htons
(
signaler_port
)
;
rc
=
bind
(
listener
,
(
const
struct
sockaddr
*
)
&
addr
,
sizeof
(
addr
));
wsa_assert
(
rc
!=
SOCKET_ERROR
);
// Retrieve local port listener is bound to (into addr).
int
addrlen
=
sizeof
(
addr
);
rc
=
getsockname
(
listener
,
(
struct
sockaddr
*
)
&
addr
,
&
addrlen
);
wsa_assert
(
rc
!=
SOCKET_ERROR
);
// Listen for incomming connections.
rc
=
listen
(
listener
,
1
);
wsa_assert
(
rc
!=
SOCKET_ERROR
);
...
...
@@ -292,6 +299,10 @@ int zmq::signaler_t::make_fdpair (fd_t *r_, fd_t *w_)
rc
=
closesocket
(
listener
);
wsa_assert
(
rc
!=
SOCKET_ERROR
);
// Exit the critical section.
BOOL
brc
=
SetEvent
(
sync
);
win_assert
(
brc
!=
0
);
return
0
;
#elif defined ZMQ_HAVE_OPENVMS
...
...
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