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
cda3c96a
Commit
cda3c96a
authored
Sep 19, 2010
by
Martin Sustrik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor code reorganisation in ctx_t::terminate
parent
938689a4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
16 deletions
+15
-16
ctx.cpp
src/ctx.cpp
+15
-16
No files found.
src/ctx.cpp
View file @
cda3c96a
...
...
@@ -106,13 +106,6 @@ zmq::ctx_t::~ctx_t ()
int
zmq
::
ctx_t
::
terminate
()
{
// First send stop command to sockets so that any
// blocking calls are interrupted.
slot_sync
.
lock
();
for
(
sockets_t
::
size_type
i
=
0
;
i
!=
sockets
.
size
();
i
++
)
sockets
[
i
]
->
stop
();
slot_sync
.
unlock
();
// Close the logging infrastructure.
log_sync
.
lock
();
int
rc
=
log_socket
->
close
();
...
...
@@ -120,26 +113,32 @@ int zmq::ctx_t::terminate ()
log_socket
=
NULL
;
log_sync
.
unlock
();
// Find out whether there are any open sockets to care about.
// If so, sleep till they are closed. Note that we can use
// no_sockets_notify safely out of the critical section as once set
// its value is never changed again.
// First send stop command to sockets so that any
// blocking calls are interrupted.
slot_sync
.
lock
();
for
(
sockets_t
::
size_type
i
=
0
;
i
!=
sockets
.
size
();
i
++
)
sockets
[
i
]
->
stop
();
if
(
!
sockets
.
empty
())
no_sockets_notify
=
true
;
slot_sync
.
unlock
();
// Find out whether there are any open sockets to care about.
// If there are open sockets, sleep till they are closed. Note that we can
// use no_sockets_notify safely out of the critical section as once set
// its value is never changed again.
if
(
no_sockets_notify
)
no_sockets_sync
.
wait
();
// Note that the lock won't block anyone here. There's noone else having
// open sockets anyway. The only purpose of the lock is to double-check all
// the CPU caches have been synchronised.
slot_sync
.
lock
();
// At this point there should be no active sockets. What we have is a set
// of zombies waiting to be dezombified.
zmq_assert
(
sockets
.
empty
());
// Get rid of remaining zombie sockets. Note that the lock won't block
// anyone here. There's noone else having open sockets anyway. The only
// purpose of the lock is to double-check all the CPU caches have been
// synchronised.
slot_sync
.
lock
();
// Get rid of remaining zombie sockets.
while
(
!
zombies
.
empty
())
{
dezombify
();
...
...
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