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
75cc2015
Commit
75cc2015
authored
May 16, 2017
by
BJovke
Committed by
GitHub
May 16, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2572 from bluca/rep_leak
Problem: REP leaves label msgs for dead REQ in pipe
parents
d1758192
0999fdd8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
2 deletions
+53
-2
router.cpp
src/router.cpp
+3
-0
test_reqrep_ipc.cpp
tests/test_reqrep_ipc.cpp
+50
-2
No files found.
src/router.cpp
View file @
75cc2015
...
...
@@ -273,6 +273,9 @@ int zmq::router_t::xsend (msg_t *msg_)
// Message failed to send - we must close it ourselves.
int
rc
=
msg_
->
close
();
errno_assert
(
rc
==
0
);
// HWM was checked before, so the pipe must be gone. Roll back
// messages that were piped, for example REP labels.
current_out
->
rollback
();
current_out
=
NULL
;
}
else
{
if
(
!
more_out
)
{
...
...
tests/test_reqrep_ipc.cpp
View file @
75cc2015
...
...
@@ -29,9 +29,48 @@
#include "testutil.hpp"
int
main
(
void
)
void
test_leak
(
void
)
{
char
my_endpoint
[
256
];
void
*
ctx
=
zmq_ctx_new
();
assert
(
ctx
);
void
*
sb
=
zmq_socket
(
ctx
,
ZMQ_REP
);
assert
(
sb
);
int
rc
=
zmq_bind
(
sb
,
"ipc://*"
);
assert
(
rc
==
0
);
size_t
len
=
sizeof
(
my_endpoint
);
rc
=
zmq_getsockopt
(
sb
,
ZMQ_LAST_ENDPOINT
,
my_endpoint
,
&
len
);
assert
(
rc
==
0
);
void
*
sc
=
zmq_socket
(
ctx
,
ZMQ_REQ
);
assert
(
sc
);
rc
=
zmq_connect
(
sc
,
my_endpoint
);
assert
(
rc
==
0
);
rc
=
s_send
(
sc
,
"leakymsg"
);
assert
(
rc
==
strlen
(
"leakymsg"
));
char
*
buf
=
s_recv
(
sb
);
free
(
buf
);
rc
=
zmq_close
(
sc
);
assert
(
rc
==
0
);
msleep
(
SETTLE_TIME
);
rc
=
s_send
(
sb
,
"leakymsg"
);
assert
(
rc
==
strlen
(
"leakymsg"
));
rc
=
zmq_close
(
sb
);
assert
(
rc
==
0
);
rc
=
zmq_ctx_term
(
ctx
);
assert
(
rc
==
0
);
}
void
test_simple
(
void
)
{
setup_test_environment
();
char
my_endpoint
[
256
];
void
*
ctx
=
zmq_ctx_new
();
assert
(
ctx
);
...
...
@@ -59,6 +98,15 @@ int main (void)
rc
=
zmq_ctx_term
(
ctx
);
assert
(
rc
==
0
);
}
int
main
(
void
)
{
setup_test_environment
();
test_simple
();
test_leak
();
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