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
75809b27
Commit
75809b27
authored
Mar 22, 2012
by
Pieter Hintjens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed issue LIBZMQ-345 - race condition in ctx.socket/term allows segfault
parent
3b483a8d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
7 deletions
+4
-7
ctx.cpp
src/ctx.cpp
+3
-6
ctx.hpp
src/ctx.hpp
+1
-1
No files found.
src/ctx.cpp
View file @
75809b27
...
...
@@ -84,11 +84,11 @@ zmq::ctx_t::~ctx_t ()
int
zmq
::
ctx_t
::
terminate
()
{
slot_sync
.
lock
();
if
(
!
starting
)
{
// Check whether termination was already underway, but interrupted and now
// restarted.
slot_sync
.
lock
();
bool
restarted
=
terminating
;
terminating
=
true
;
slot_sync
.
unlock
();
...
...
@@ -116,8 +116,8 @@ int zmq::ctx_t::terminate ()
zmq_assert
(
cmd
.
type
==
command_t
::
done
);
slot_sync
.
lock
();
zmq_assert
(
sockets
.
empty
());
slot_sync
.
unlock
();
}
slot_sync
.
unlock
();
// Deallocate the resources.
delete
this
;
...
...
@@ -163,10 +163,10 @@ int zmq::ctx_t::get (int option_)
zmq
::
socket_base_t
*
zmq
::
ctx_t
::
create_socket
(
int
type_
)
{
slot_sync
.
lock
();
if
(
unlikely
(
starting
))
{
starting
=
false
;
// Initialise the array of mailboxes. Additional three slots are for
// zmq_term thread and reaper thread.
opt_sync
.
lock
();
...
...
@@ -203,8 +203,6 @@ zmq::socket_base_t *zmq::ctx_t::create_socket (int type_)
}
}
slot_sync
.
lock
();
// Once zmq_term() was called, we can't create new sockets.
if
(
terminating
)
{
slot_sync
.
unlock
();
...
...
@@ -237,7 +235,6 @@ zmq::socket_base_t *zmq::ctx_t::create_socket (int type_)
slots
[
slot
]
=
s
->
get_mailbox
();
slot_sync
.
unlock
();
return
s
;
}
...
...
src/ctx.hpp
View file @
75809b27
...
...
@@ -126,7 +126,7 @@ namespace zmq
// Synchronisation of accesses to global slot-related data:
// sockets, empty_slots, terminating. It also synchronises
// access to zombie sockets as such (as oposed to slots) and provides
// access to zombie sockets as such (as op
p
osed to slots) and provides
// a memory barrier to ensure that all CPU cores see the same data.
mutex_t
slot_sync
;
...
...
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