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
5dadded0
Commit
5dadded0
authored
May 05, 2016
by
Constantin Rack
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1961 from somdoron/Signaler
problem: closed poller still associated with socket
parents
fb75b201
a747f724
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
17 deletions
+25
-17
mailbox_safe.cpp
src/mailbox_safe.cpp
+7
-2
mailbox_safe.hpp
src/mailbox_safe.hpp
+3
-2
socket_base.cpp
src/socket_base.cpp
+7
-0
socket_poller.cpp
src/socket_poller.cpp
+5
-10
test_poller.cpp
tests/test_poller.cpp
+3
-3
No files found.
src/mailbox_safe.cpp
View file @
5dadded0
...
...
@@ -52,12 +52,12 @@ zmq::mailbox_safe_t::~mailbox_safe_t ()
sync
->
unlock
();
}
void
zmq
::
mailbox_safe_t
::
add_signaler
(
signaler_t
*
signaler
)
void
zmq
::
mailbox_safe_t
::
add_signaler
(
signaler_t
*
signaler
)
{
signalers
.
push_back
(
signaler
);
}
void
zmq
::
mailbox_safe_t
::
remove_signaler
(
signaler_t
*
signaler
)
void
zmq
::
mailbox_safe_t
::
remove_signaler
(
signaler_t
*
signaler
)
{
std
::
vector
<
signaler_t
*>::
iterator
it
=
signalers
.
begin
();
...
...
@@ -71,6 +71,11 @@ void zmq::mailbox_safe_t::remove_signaler(signaler_t* signaler)
signalers
.
erase
(
it
);
}
void
zmq
::
mailbox_safe_t
::
clear_signalers
()
{
signalers
.
clear
();
}
void
zmq
::
mailbox_safe_t
::
send
(
const
command_t
&
cmd_
)
{
sync
->
lock
();
...
...
src/mailbox_safe.hpp
View file @
5dadded0
...
...
@@ -57,8 +57,9 @@ namespace zmq
int
recv
(
command_t
*
cmd_
,
int
timeout_
);
// Add signaler to mailbox which will be called when a message is ready
void
add_signaler
(
signaler_t
*
signaler
);
void
remove_signaler
(
signaler_t
*
signaler
);
void
add_signaler
(
signaler_t
*
signaler
);
void
remove_signaler
(
signaler_t
*
signaler
);
void
clear_signalers
();
#ifdef HAVE_FORK
// close the file descriptors in the signaller. This is used in a forked
...
...
src/socket_base.cpp
View file @
5dadded0
...
...
@@ -1281,6 +1281,12 @@ int zmq::socket_base_t::recv (msg_t *msg_, int flags_)
int
zmq
::
socket_base_t
::
close
()
{
ENTER_MUTEX
();
// Remove all existing signalers for thread safe sockets
if
(
thread_safe
)
((
mailbox_safe_t
*
)
mailbox
)
->
clear_signalers
();
// Mark the socket as dead
tag
=
0xdeadbeef
;
...
...
@@ -1289,6 +1295,7 @@ int zmq::socket_base_t::close ()
// process.
send_reap
(
this
);
EXIT_MUTEX
();
return
0
;
}
...
...
src/socket_poller.cpp
View file @
5dadded0
...
...
@@ -186,19 +186,14 @@ int zmq::socket_poller_t::remove (socket_base_t *socket_)
return
-
1
;
}
items
.
erase
(
it
);
need_rebuild
=
true
;
int
thread_safe
;
size_t
thread_safe_size
=
sizeof
(
int
);
if
(
socket_
->
getsockopt
(
ZMQ_THREAD_SAFE
,
&
thread_safe
,
&
thread_safe_size
)
==
-
1
)
return
-
1
;
if
(
thread_safe
)
{
if
(
socket_
->
remove_signaler
(
&
signaler
)
==
-
1
)
return
-
1
;
}
items
.
erase
(
it
);
need_rebuild
=
true
;
if
(
socket_
->
getsockopt
(
ZMQ_THREAD_SAFE
,
&
thread_safe
,
&
thread_safe_size
)
==
0
&&
thread_safe
)
socket_
->
remove_signaler
(
&
signaler
);
return
0
;
}
...
...
tests/test_poller.cpp
View file @
5dadded0
...
...
@@ -143,9 +143,7 @@ int main (void)
assert
(
event
.
events
==
ZMQ_POLLOUT
);
#endif
// Destory poller, sockets and ctx
rc
=
zmq_poller_destroy
(
&
poller
);
assert
(
rc
==
0
);
// Destory sockets, poller and ctx
rc
=
zmq_close
(
sink
);
assert
(
rc
==
0
);
rc
=
zmq_close
(
vent
);
...
...
@@ -158,6 +156,8 @@ int main (void)
rc
=
zmq_close
(
client
);
assert
(
rc
==
0
);
#endif
rc
=
zmq_poller_destroy
(
&
poller
);
assert
(
rc
==
0
);
rc
=
zmq_ctx_term
(
ctx
);
assert
(
rc
==
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