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
9382941a
Commit
9382941a
authored
Dec 08, 2012
by
Min(Dongmin Yu)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
returns EHOSTUNREACH when a peer is full if ZMQ_ROUTER_MANDATORY is set
parent
95d36f42
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
3 deletions
+52
-3
router.cpp
src/router.cpp
+7
-2
test_router_mandatory.cpp
tests/test_router_mandatory.cpp
+45
-1
No files found.
src/router.cpp
View file @
9382941a
...
...
@@ -156,19 +156,24 @@ int zmq::router_t::xsend (msg_t *msg_)
// Find the pipe associated with the identity stored in the prefix.
// If there's no such pipe just silently ignore the message, unless
// r
eport_unreachable
is set.
// r
outer_mandatory
is set.
blob_t
identity
((
unsigned
char
*
)
msg_
->
data
(),
msg_
->
size
());
outpipes_t
::
iterator
it
=
outpipes
.
find
(
identity
);
bool
unreach
=
false
;
if
(
it
!=
outpipes
.
end
())
{
current_out
=
it
->
second
.
pipe
;
if
(
!
current_out
->
check_write
())
{
it
->
second
.
active
=
false
;
current_out
=
NULL
;
unreach
=
true
;
}
}
else
if
(
mandatory
)
{
if
(
mandatory
)
unreach
=
true
;
if
(
unreach
)
{
more_out
=
false
;
errno
=
EHOSTUNREACH
;
return
-
1
;
...
...
tests/test_router_mandatory.cpp
View file @
9382941a
...
...
@@ -21,6 +21,7 @@
#include <stdio.h>
#include "testutil.hpp"
#include "../include/zmq_utils.h"
int
main
(
void
)
{
...
...
@@ -33,7 +34,11 @@ int main (void)
void
*
sa
=
zmq_socket
(
ctx
,
ZMQ_ROUTER
);
assert
(
sa
);
int
rc
=
zmq_bind
(
sa
,
"tcp://127.0.0.1:15560"
);
int
hwm
=
1
;
int
rc
=
zmq_setsockopt
(
sa
,
ZMQ_SNDHWM
,
&
hwm
,
sizeof
(
hwm
));
assert
(
rc
==
0
);
rc
=
zmq_bind
(
sa
,
"tcp://127.0.0.1:15560"
);
assert
(
rc
==
0
);
// Sending a message to an unknown peer with the default setting
...
...
@@ -52,9 +57,48 @@ int main (void)
rc
=
zmq_send
(
sa
,
"UNKNOWN"
,
7
,
ZMQ_SNDMORE
|
ZMQ_DONTWAIT
);
assert
(
rc
==
-
1
&&
errno
==
EHOSTUNREACH
);
// Create a valid socket
void
*
sb
=
zmq_socket
(
ctx
,
ZMQ_DEALER
);
assert
(
sb
);
rc
=
zmq_setsockopt
(
sb
,
ZMQ_RCVHWM
,
&
hwm
,
sizeof
(
hwm
));
assert
(
rc
==
0
);
rc
=
zmq_setsockopt
(
sb
,
ZMQ_IDENTITY
,
"X"
,
1
);
assert
(
rc
==
0
);
rc
=
zmq_connect
(
sb
,
"tcp://127.0.0.1:15560"
);
assert
(
rc
==
0
);
// wait until connect
zmq_sleep
(
1
);
// make it full and check that it fails
rc
=
zmq_send
(
sa
,
"X"
,
1
,
ZMQ_SNDMORE
);
assert
(
rc
==
1
);
rc
=
zmq_send
(
sa
,
"DATA1"
,
5
,
0
);
assert
(
rc
==
5
);
rc
=
zmq_send
(
sa
,
"X"
,
1
,
ZMQ_SNDMORE
);
if
(
rc
==
1
)
{
// the first frame has been sent
rc
=
zmq_send
(
sa
,
"DATA2"
,
5
,
0
);
assert
(
rc
==
5
);
// send more
rc
=
zmq_send
(
sa
,
"X"
,
1
,
ZMQ_SNDMORE
);
}
assert
(
rc
==
-
1
&&
errno
==
EHOSTUNREACH
);
rc
=
zmq_close
(
sa
);
assert
(
rc
==
0
);
rc
=
zmq_close
(
sb
);
assert
(
rc
==
0
);
rc
=
zmq_term
(
ctx
);
assert
(
rc
==
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