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
d568e7f5
Commit
d568e7f5
authored
Sep 26, 2013
by
Martin Hurton
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #686 from hintjens/master
Added test case for issue 566
parents
5271bc9d
e42a0a40
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
90 additions
and
2 deletions
+90
-2
.gitignore
.gitignore
+1
-0
stream_engine.cpp
src/stream_engine.cpp
+1
-1
Makefile.am
tests/Makefile.am
+3
-1
test_issue_566.cpp
tests/test_issue_566.cpp
+85
-0
No files found.
.gitignore
View file @
d568e7f5
...
...
@@ -22,6 +22,7 @@ autom4te.cache
.*~
tools/curve_keygen.o
tools/curve_keygen
tests/test_issue_566
tests/test_ctx_destroy
tests/test_term_endpoint
tests/test_system
...
...
src/stream_engine.cpp
View file @
d568e7f5
...
...
@@ -739,7 +739,7 @@ int zmq::stream_engine_t::write (const void *data_, size_t size_)
// we'll get an error (this may happen during the speculative write).
if
(
nbytes
==
SOCKET_ERROR
&&
WSAGetLastError
()
==
WSAEWOULDBLOCK
)
return
0
;
// Signalise peer failure.
if
(
nbytes
==
SOCKET_ERROR
&&
(
WSAGetLastError
()
==
WSAENETDOWN
||
...
...
tests/Makefile.am
View file @
d568e7f5
...
...
@@ -37,7 +37,8 @@ noinst_PROGRAMS = test_system \
test_req_correlate
\
test_req_relaxed
\
test_conflate
\
test_inproc_connect
test_inproc_connect
\
test_issue_566
if
!ON_MINGW
noinst_PROGRAMS
+=
test_shutdown_stress
\
...
...
@@ -82,6 +83,7 @@ test_req_correlate_SOURCES = test_req_correlate.cpp
test_req_relaxed_SOURCES
=
test_req_relaxed.cpp
test_conflate_SOURCES
=
test_conflate.cpp
test_inproc_connect_SOURCES
=
test_inproc_connect.cpp
test_issue_566_SOURCES
=
test_issue_566.cpp
if
!ON_MINGW
test_shutdown_stress_SOURCES
=
test_shutdown_stress.cpp
test_pair_ipc_SOURCES
=
test_pair_ipc.cpp testutil.hpp
...
...
tests/test_issue_566.cpp
0 → 100644
View file @
d568e7f5
/*
Copyright (c) 2007-2013 Contributors as noted in the AUTHORS file
This file is part of 0MQ.
0MQ is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
0MQ is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "testutil.hpp"
// Issue 566 describes a problem in libzmq v4.0.0 where a dealer to router
// connection would fail randomly. The test works when the two sockets are
// on the same context, and failed when they were on separate contexts.
// Fixed by https://github.com/zeromq/libzmq/commit/be25cf.
int
main
(
void
)
{
setup_test_environment
();
void
*
ctx1
=
zmq_ctx_new
();
assert
(
ctx1
);
void
*
ctx2
=
zmq_ctx_new
();
assert
(
ctx2
);
void
*
router
=
zmq_socket
(
ctx1
,
ZMQ_ROUTER
);
int
on
=
1
;
int
rc
=
zmq_setsockopt
(
router
,
ZMQ_ROUTER_MANDATORY
,
&
on
,
sizeof
(
on
));
assert
(
rc
==
0
);
rc
=
zmq_bind
(
router
,
"tcp://127.0.0.1:5555"
);
assert
(
rc
!=
-
1
);
// Repeat often enough to be sure this works as it should
for
(
int
cycle
=
0
;
cycle
<
100
;
cycle
++
)
{
// Create dealer with unique explicit identity
// We assume the router learns this out-of-band
void
*
dealer
=
zmq_socket
(
ctx2
,
ZMQ_DEALER
);
char
identity
[
10
];
sprintf
(
identity
,
"%09d"
,
cycle
);
rc
=
zmq_setsockopt
(
dealer
,
ZMQ_IDENTITY
,
identity
,
10
);
assert
(
rc
==
0
);
int
rcvtimeo
=
1000
;
rc
=
zmq_setsockopt
(
dealer
,
ZMQ_RCVTIMEO
,
&
rcvtimeo
,
sizeof
(
int
));
assert
(
rc
==
0
);
rc
=
zmq_connect
(
dealer
,
"tcp://127.0.0.1:5555"
);
assert
(
rc
==
0
);
// Router will try to send to dealer, at short intervals.
// It typically takes 2-5 msec for the connection to establish
// on a loopback interface, but we'll allow up to one second
// before failing the test (e.g. for running on a debugger or
// a very slow system).
for
(
int
attempt
=
0
;
attempt
<
500
;
attempt
++
)
{
zmq_poll
(
0
,
0
,
2
);
rc
=
zmq_send
(
router
,
identity
,
10
,
ZMQ_SNDMORE
);
if
(
rc
==
-
1
&&
errno
==
EHOSTUNREACH
)
continue
;
assert
(
rc
==
10
);
rc
=
zmq_send
(
router
,
"HELLO"
,
5
,
0
);
assert
(
rc
==
5
);
break
;
}
uint8_t
buffer
[
5
];
rc
=
zmq_recv
(
dealer
,
buffer
,
5
,
0
);
assert
(
rc
==
5
);
assert
(
memcmp
(
buffer
,
"HELLO"
,
5
)
==
0
);
close_zero_linger
(
dealer
);
}
zmq_close
(
router
);
zmq_ctx_destroy
(
ctx1
);
zmq_ctx_destroy
(
ctx2
);
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