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
096007c5
Commit
096007c5
authored
Aug 21, 2015
by
Richard Newton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix zmq crash when calling shutdown with a pending inproc socket connect
parent
4e5843b8
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
1 deletion
+28
-1
ctx.cpp
src/ctx.cpp
+6
-1
test_inproc_connect.cpp
tests/test_inproc_connect.cpp
+22
-0
No files found.
src/ctx.cpp
View file @
096007c5
...
@@ -126,6 +126,11 @@ zmq::ctx_t::~ctx_t ()
...
@@ -126,6 +126,11 @@ zmq::ctx_t::~ctx_t ()
int
zmq
::
ctx_t
::
terminate
()
int
zmq
::
ctx_t
::
terminate
()
{
{
slot_sync
.
lock
();
bool
saveTerminating
=
terminating
;
terminating
=
false
;
// Connect up any pending inproc connections, otherwise we will hang
// Connect up any pending inproc connections, otherwise we will hang
pending_connections_t
copy
=
pending_connections
;
pending_connections_t
copy
=
pending_connections
;
for
(
pending_connections_t
::
iterator
p
=
copy
.
begin
();
p
!=
copy
.
end
();
++
p
)
{
for
(
pending_connections_t
::
iterator
p
=
copy
.
begin
();
p
!=
copy
.
end
();
++
p
)
{
...
@@ -133,8 +138,8 @@ int zmq::ctx_t::terminate ()
...
@@ -133,8 +138,8 @@ int zmq::ctx_t::terminate ()
s
->
bind
(
p
->
first
.
c_str
());
s
->
bind
(
p
->
first
.
c_str
());
s
->
close
();
s
->
close
();
}
}
terminating
=
saveTerminating
;
slot_sync
.
lock
();
if
(
!
starting
)
{
if
(
!
starting
)
{
#ifdef HAVE_FORK
#ifdef HAVE_FORK
...
...
tests/test_inproc_connect.cpp
View file @
096007c5
...
@@ -471,6 +471,27 @@ void test_unbind ()
...
@@ -471,6 +471,27 @@ void test_unbind ()
assert
(
rc
==
0
);
assert
(
rc
==
0
);
}
}
void
test_shutdown_during_pend
()
{
void
*
ctx
=
zmq_ctx_new
();
assert
(
ctx
);
// Connect first
void
*
connectSocket
=
zmq_socket
(
ctx
,
ZMQ_PAIR
);
assert
(
connectSocket
);
int
rc
=
zmq_connect
(
connectSocket
,
"inproc://cbb"
);
assert
(
rc
==
0
);
zmq_ctx_shutdown
(
ctx
);
// Cleanup
rc
=
zmq_close
(
connectSocket
);
assert
(
rc
==
0
);
rc
=
zmq_ctx_term
(
ctx
);
assert
(
rc
==
0
);
}
int
main
(
void
)
int
main
(
void
)
{
{
setup_test_environment
();
setup_test_environment
();
...
@@ -484,6 +505,7 @@ int main (void)
...
@@ -484,6 +505,7 @@ int main (void)
test_identity
();
test_identity
();
test_connect_only
();
test_connect_only
();
test_unbind
();
test_unbind
();
test_shutdown_during_pend
();
return
0
;
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