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
045dab91
Commit
045dab91
authored
May 18, 2014
by
Martin Hurton
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1037 from hintjens/master
Problem: artificial restriction on binary identities
parents
bac001cc
a9a15ccf
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
21 deletions
+20
-21
zmq_setsockopt.txt
doc/zmq_setsockopt.txt
+1
-1
ctx.cpp
src/ctx.cpp
+5
-3
options.cpp
src/options.cpp
+2
-5
test_inproc_connect.cpp
tests/test_inproc_connect.cpp
+12
-12
No files found.
doc/zmq_setsockopt.txt
View file @
045dab91
...
@@ -190,7 +190,7 @@ ZMQ_IDENTITY: Set socket identity
...
@@ -190,7 +190,7 @@ ZMQ_IDENTITY: Set socket identity
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The 'ZMQ_IDENTITY' option shall set the identity of the specified 'socket'
The 'ZMQ_IDENTITY' option shall set the identity of the specified 'socket'
when connecting to a ROUTER socket. The identity should be from 1 to 255
when connecting to a ROUTER socket. The identity should be from 1 to 255
bytes long and
MAY NOT start with binary zero
.
bytes long and
may contain any values
.
If two clients use the same identity when connecting to a ROUTER, the
If two clients use the same identity when connecting to a ROUTER, the
results shall depend on the ZMQ_ROUTER_HANDOVER option setting. If that
results shall depend on the ZMQ_ROUTER_HANDOVER option setting. If that
...
...
src/ctx.cpp
View file @
045dab91
...
@@ -42,7 +42,8 @@
...
@@ -42,7 +42,8 @@
int
clipped_maxsocket
(
int
max_requested
)
int
clipped_maxsocket
(
int
max_requested
)
{
{
if
(
max_requested
>=
zmq
::
poller_t
::
max_fds
()
&&
zmq
::
poller_t
::
max_fds
()
!=
-
1
)
if
(
max_requested
>=
zmq
::
poller_t
::
max_fds
()
&&
zmq
::
poller_t
::
max_fds
()
!=
-
1
)
max_requested
=
zmq
::
poller_t
::
max_fds
()
-
1
;
// -1 because we need room for the repear mailbox.
// -1 because we need room for the reaper mailbox.
max_requested
=
zmq
::
poller_t
::
max_fds
()
-
1
;
return
max_requested
;
return
max_requested
;
}
}
...
@@ -175,7 +176,8 @@ int zmq::ctx_t::shutdown ()
...
@@ -175,7 +176,8 @@ int zmq::ctx_t::shutdown ()
int
zmq
::
ctx_t
::
set
(
int
option_
,
int
optval_
)
int
zmq
::
ctx_t
::
set
(
int
option_
,
int
optval_
)
{
{
int
rc
=
0
;
int
rc
=
0
;
if
(
option_
==
ZMQ_MAX_SOCKETS
&&
optval_
>=
1
&&
optval_
==
clipped_maxsocket
(
optval_
))
{
if
(
option_
==
ZMQ_MAX_SOCKETS
&&
optval_
>=
1
&&
optval_
==
clipped_maxsocket
(
optval_
))
{
opt_sync
.
lock
();
opt_sync
.
lock
();
max_sockets
=
optval_
;
max_sockets
=
optval_
;
opt_sync
.
unlock
();
opt_sync
.
unlock
();
...
@@ -233,7 +235,7 @@ zmq::socket_base_t *zmq::ctx_t::create_socket (int type_)
...
@@ -233,7 +235,7 @@ zmq::socket_base_t *zmq::ctx_t::create_socket (int type_)
int
ios
=
io_thread_count
;
int
ios
=
io_thread_count
;
opt_sync
.
unlock
();
opt_sync
.
unlock
();
slot_count
=
mazmq
+
ios
+
2
;
slot_count
=
mazmq
+
ios
+
2
;
slots
=
(
mailbox_t
**
)
malloc
(
sizeof
(
mailbox_t
*
)
*
slot_count
);
slots
=
(
mailbox_t
**
)
malloc
(
sizeof
(
mailbox_t
*
)
*
slot_count
);
alloc_assert
(
slots
);
alloc_assert
(
slots
);
// Initialise the infrastructure for zmq_ctx_term thread.
// Initialise the infrastructure for zmq_ctx_term thread.
...
...
src/options.cpp
View file @
045dab91
...
@@ -89,11 +89,8 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
...
@@ -89,11 +89,8 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
break
;
break
;
case
ZMQ_IDENTITY
:
case
ZMQ_IDENTITY
:
// Empty identity is invalid as well as identity longer than
// Identity is any binary string from 1 to 255 octets
// 255 bytes. Identity starting with binary zero is invalid
if
(
optvallen_
>
0
&&
optvallen_
<
256
)
{
// as these are used for auto-generated identities.
if
(
optvallen_
>
0
&&
optvallen_
<
256
&&
*
((
const
unsigned
char
*
)
optval_
)
!=
0
)
{
identity_size
=
optvallen_
;
identity_size
=
optvallen_
;
memcpy
(
identity
,
optval_
,
identity_size
);
memcpy
(
identity
,
optval_
,
identity_size
);
return
0
;
return
0
;
...
...
tests/test_inproc_connect.cpp
View file @
045dab91
...
@@ -24,7 +24,7 @@ static void pusher (void *ctx)
...
@@ -24,7 +24,7 @@ static void pusher (void *ctx)
// Connect first
// Connect first
void
*
connectSocket
=
zmq_socket
(
ctx
,
ZMQ_PAIR
);
void
*
connectSocket
=
zmq_socket
(
ctx
,
ZMQ_PAIR
);
assert
(
connectSocket
);
assert
(
connectSocket
);
int
rc
=
zmq_connect
(
connectSocket
,
"inproc://
a
"
);
int
rc
=
zmq_connect
(
connectSocket
,
"inproc://
sink
"
);
assert
(
rc
==
0
);
assert
(
rc
==
0
);
// Queue up some data
// Queue up some data
...
@@ -44,13 +44,13 @@ void test_bind_before_connect ()
...
@@ -44,13 +44,13 @@ void test_bind_before_connect ()
// Bind first
// Bind first
void
*
bindSocket
=
zmq_socket
(
ctx
,
ZMQ_PAIR
);
void
*
bindSocket
=
zmq_socket
(
ctx
,
ZMQ_PAIR
);
assert
(
bindSocket
);
assert
(
bindSocket
);
int
rc
=
zmq_bind
(
bindSocket
,
"inproc://
a
"
);
int
rc
=
zmq_bind
(
bindSocket
,
"inproc://
bbc
"
);
assert
(
rc
==
0
);
assert
(
rc
==
0
);
// Now connect
// Now connect
void
*
connectSocket
=
zmq_socket
(
ctx
,
ZMQ_PAIR
);
void
*
connectSocket
=
zmq_socket
(
ctx
,
ZMQ_PAIR
);
assert
(
connectSocket
);
assert
(
connectSocket
);
rc
=
zmq_connect
(
connectSocket
,
"inproc://
a
"
);
rc
=
zmq_connect
(
connectSocket
,
"inproc://
bbc
"
);
assert
(
rc
==
0
);
assert
(
rc
==
0
);
// Queue up some data
// Queue up some data
...
@@ -85,7 +85,7 @@ void test_connect_before_bind ()
...
@@ -85,7 +85,7 @@ void test_connect_before_bind ()
// Connect first
// Connect first
void
*
connectSocket
=
zmq_socket
(
ctx
,
ZMQ_PAIR
);
void
*
connectSocket
=
zmq_socket
(
ctx
,
ZMQ_PAIR
);
assert
(
connectSocket
);
assert
(
connectSocket
);
int
rc
=
zmq_connect
(
connectSocket
,
"inproc://
a
"
);
int
rc
=
zmq_connect
(
connectSocket
,
"inproc://
cbb
"
);
assert
(
rc
==
0
);
assert
(
rc
==
0
);
// Queue up some data
// Queue up some data
...
@@ -95,7 +95,7 @@ void test_connect_before_bind ()
...
@@ -95,7 +95,7 @@ void test_connect_before_bind ()
// Now bind
// Now bind
void
*
bindSocket
=
zmq_socket
(
ctx
,
ZMQ_PAIR
);
void
*
bindSocket
=
zmq_socket
(
ctx
,
ZMQ_PAIR
);
assert
(
bindSocket
);
assert
(
bindSocket
);
rc
=
zmq_bind
(
bindSocket
,
"inproc://
a
"
);
rc
=
zmq_bind
(
bindSocket
,
"inproc://
cbb
"
);
assert
(
rc
==
0
);
assert
(
rc
==
0
);
// Read pending message
// Read pending message
...
@@ -126,7 +126,7 @@ void test_connect_before_bind_pub_sub ()
...
@@ -126,7 +126,7 @@ void test_connect_before_bind_pub_sub ()
// Connect first
// Connect first
void
*
connectSocket
=
zmq_socket
(
ctx
,
ZMQ_PUB
);
void
*
connectSocket
=
zmq_socket
(
ctx
,
ZMQ_PUB
);
assert
(
connectSocket
);
assert
(
connectSocket
);
int
rc
=
zmq_connect
(
connectSocket
,
"inproc://
a
"
);
int
rc
=
zmq_connect
(
connectSocket
,
"inproc://
cbbps
"
);
assert
(
rc
==
0
);
assert
(
rc
==
0
);
// Queue up some data, this will be dropped
// Queue up some data, this will be dropped
...
@@ -138,7 +138,7 @@ void test_connect_before_bind_pub_sub ()
...
@@ -138,7 +138,7 @@ void test_connect_before_bind_pub_sub ()
assert
(
bindSocket
);
assert
(
bindSocket
);
rc
=
zmq_setsockopt
(
bindSocket
,
ZMQ_SUBSCRIBE
,
""
,
0
);
rc
=
zmq_setsockopt
(
bindSocket
,
ZMQ_SUBSCRIBE
,
""
,
0
);
assert
(
rc
==
0
);
assert
(
rc
==
0
);
rc
=
zmq_bind
(
bindSocket
,
"inproc://
a
"
);
rc
=
zmq_bind
(
bindSocket
,
"inproc://
cbbps
"
);
assert
(
rc
==
0
);
assert
(
rc
==
0
);
// Wait for pub-sub connection to happen
// Wait for pub-sub connection to happen
...
@@ -182,7 +182,7 @@ void test_multiple_connects ()
...
@@ -182,7 +182,7 @@ void test_multiple_connects ()
{
{
connectSocket
[
i
]
=
zmq_socket
(
ctx
,
ZMQ_PUSH
);
connectSocket
[
i
]
=
zmq_socket
(
ctx
,
ZMQ_PUSH
);
assert
(
connectSocket
[
i
]);
assert
(
connectSocket
[
i
]);
rc
=
zmq_connect
(
connectSocket
[
i
],
"inproc://
a
"
);
rc
=
zmq_connect
(
connectSocket
[
i
],
"inproc://
multiple
"
);
assert
(
rc
==
0
);
assert
(
rc
==
0
);
// Queue up some data
// Queue up some data
...
@@ -193,7 +193,7 @@ void test_multiple_connects ()
...
@@ -193,7 +193,7 @@ void test_multiple_connects ()
// Now bind
// Now bind
void
*
bindSocket
=
zmq_socket
(
ctx
,
ZMQ_PULL
);
void
*
bindSocket
=
zmq_socket
(
ctx
,
ZMQ_PULL
);
assert
(
bindSocket
);
assert
(
bindSocket
);
rc
=
zmq_bind
(
bindSocket
,
"inproc://
a
"
);
rc
=
zmq_bind
(
bindSocket
,
"inproc://
multiple
"
);
assert
(
rc
==
0
);
assert
(
rc
==
0
);
for
(
unsigned
int
i
=
0
;
i
<
no_of_connects
;
++
i
)
for
(
unsigned
int
i
=
0
;
i
<
no_of_connects
;
++
i
)
...
@@ -240,7 +240,7 @@ void test_multiple_threads ()
...
@@ -240,7 +240,7 @@ void test_multiple_threads ()
// Now bind
// Now bind
void
*
bindSocket
=
zmq_socket
(
ctx
,
ZMQ_PULL
);
void
*
bindSocket
=
zmq_socket
(
ctx
,
ZMQ_PULL
);
assert
(
bindSocket
);
assert
(
bindSocket
);
rc
=
zmq_bind
(
bindSocket
,
"inproc://
a
"
);
rc
=
zmq_bind
(
bindSocket
,
"inproc://
sink
"
);
assert
(
rc
==
0
);
assert
(
rc
==
0
);
for
(
unsigned
int
i
=
0
;
i
<
no_of_threads
;
++
i
)
for
(
unsigned
int
i
=
0
;
i
<
no_of_threads
;
++
i
)
...
@@ -277,13 +277,13 @@ void test_identity ()
...
@@ -277,13 +277,13 @@ void test_identity ()
void
*
sc
=
zmq_socket
(
ctx
,
ZMQ_DEALER
);
void
*
sc
=
zmq_socket
(
ctx
,
ZMQ_DEALER
);
assert
(
sc
);
assert
(
sc
);
int
rc
=
zmq_connect
(
sc
,
"inproc://
a
"
);
int
rc
=
zmq_connect
(
sc
,
"inproc://
identity
"
);
assert
(
rc
==
0
);
assert
(
rc
==
0
);
void
*
sb
=
zmq_socket
(
ctx
,
ZMQ_ROUTER
);
void
*
sb
=
zmq_socket
(
ctx
,
ZMQ_ROUTER
);
assert
(
sb
);
assert
(
sb
);
rc
=
zmq_bind
(
sb
,
"inproc://
a
"
);
rc
=
zmq_bind
(
sb
,
"inproc://
identity
"
);
assert
(
rc
==
0
);
assert
(
rc
==
0
);
// Send 2-part message.
// Send 2-part message.
...
...
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