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
cf34aeb2
Commit
cf34aeb2
authored
Sep 04, 2016
by
Constantin Rack
Committed by
GitHub
Sep 04, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2100 from a4z/master
Problem: scoped optional mutex lock caused unit tests to fail
parents
3068f476
a43f6ce0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
16 deletions
+18
-16
mutex.hpp
src/mutex.hpp
+2
-2
socket_base.cpp
src/socket_base.cpp
+16
-14
No files found.
src/mutex.hpp
View file @
cf34aeb2
...
...
@@ -188,13 +188,13 @@ namespace zmq
scoped_optional_lock_t
(
mutex_t
*
mutex_
)
:
mutex
(
mutex_
)
{
if
(
mutex
!=
0
)
if
(
mutex
!=
NULL
)
mutex
->
lock
();
}
~
scoped_optional_lock_t
()
{
if
(
mutex
!=
0
)
if
(
mutex
!=
NULL
)
mutex
->
unlock
();
}
...
...
src/socket_base.cpp
View file @
cf34aeb2
...
...
@@ -332,7 +332,7 @@ void zmq::socket_base_t::attach_pipe (pipe_t *pipe_, bool subscribe_to_all_)
int
zmq
::
socket_base_t
::
setsockopt
(
int
option_
,
const
void
*
optval_
,
size_t
optvallen_
)
{
scoped_optional_lock_t
sync_lock
(
thread_safe
?
&
sync
:
0
);
scoped_optional_lock_t
sync_lock
(
thread_safe
?
&
sync
:
NULL
);
if
(
!
options
.
is_valid
(
option_
))
{
errno
=
EINVAL
;
...
...
@@ -361,7 +361,7 @@ int zmq::socket_base_t::setsockopt (int option_, const void *optval_,
int
zmq
::
socket_base_t
::
getsockopt
(
int
option_
,
void
*
optval_
,
size_t
*
optvallen_
)
{
scoped_optional_lock_t
sync_lock
(
thread_safe
?
&
sync
:
0
);
scoped_optional_lock_t
sync_lock
(
thread_safe
?
&
sync
:
NULL
);
if
(
unlikely
(
ctx_terminated
))
{
errno
=
ETERM
;
...
...
@@ -443,7 +443,7 @@ int zmq::socket_base_t::getsockopt (int option_, void *optval_,
int
zmq
::
socket_base_t
::
join
(
const
char
*
group_
)
{
scoped_optional_lock_t
sync_lock
(
thread_safe
?
&
sync
:
0
);
scoped_optional_lock_t
sync_lock
(
thread_safe
?
&
sync
:
NULL
);
int
rc
=
xjoin
(
group_
);
...
...
@@ -453,7 +453,7 @@ int zmq::socket_base_t::join (const char* group_)
int
zmq
::
socket_base_t
::
leave
(
const
char
*
group_
)
{
scoped_optional_lock_t
sync_lock
(
thread_safe
?
&
sync
:
0
);
scoped_optional_lock_t
sync_lock
(
thread_safe
?
&
sync
:
NULL
);
int
rc
=
xleave
(
group_
);
...
...
@@ -463,7 +463,7 @@ int zmq::socket_base_t::leave (const char* group_)
int
zmq
::
socket_base_t
::
add_signaler
(
signaler_t
*
s_
)
{
scoped_optional_lock_t
sync_lock
(
thread_safe
?
&
sync
:
0
);
scoped_optional_lock_t
sync_lock
(
thread_safe
?
&
sync
:
NULL
);
if
(
!
thread_safe
)
{
errno
=
EINVAL
;
...
...
@@ -477,7 +477,7 @@ int zmq::socket_base_t::add_signaler(signaler_t *s_)
int
zmq
::
socket_base_t
::
remove_signaler
(
signaler_t
*
s_
)
{
scoped_optional_lock_t
sync_lock
(
thread_safe
?
&
sync
:
0
);
scoped_optional_lock_t
sync_lock
(
thread_safe
?
&
sync
:
NULL
);
if
(
!
thread_safe
)
{
errno
=
EINVAL
;
...
...
@@ -491,7 +491,7 @@ int zmq::socket_base_t::remove_signaler(signaler_t *s_)
int
zmq
::
socket_base_t
::
bind
(
const
char
*
addr_
)
{
scoped_optional_lock_t
sync_lock
(
thread_safe
?
&
sync
:
0
);
scoped_optional_lock_t
sync_lock
(
thread_safe
?
&
sync
:
NULL
);
if
(
unlikely
(
ctx_terminated
))
{
errno
=
ETERM
;
...
...
@@ -678,7 +678,7 @@ int zmq::socket_base_t::bind (const char *addr_)
int
zmq
::
socket_base_t
::
connect
(
const
char
*
addr_
)
{
scoped_optional_lock_t
sync_lock
(
thread_safe
?
&
sync
:
0
);
scoped_optional_lock_t
sync_lock
(
thread_safe
?
&
sync
:
NULL
);
if
(
unlikely
(
ctx_terminated
))
{
errno
=
ETERM
;
...
...
@@ -988,7 +988,7 @@ void zmq::socket_base_t::add_endpoint (const char *addr_, own_t *endpoint_, pipe
int
zmq
::
socket_base_t
::
term_endpoint
(
const
char
*
addr_
)
{
scoped_optional_lock_t
sync_lock
(
thread_safe
?
&
sync
:
0
);
scoped_optional_lock_t
sync_lock
(
thread_safe
?
&
sync
:
NULL
);
// Check whether the library haven't been shut down yet.
if
(
unlikely
(
ctx_terminated
))
{
...
...
@@ -1082,7 +1082,7 @@ int zmq::socket_base_t::term_endpoint (const char *addr_)
int
zmq
::
socket_base_t
::
send
(
msg_t
*
msg_
,
int
flags_
)
{
scoped_optional_lock_t
sync_lock
(
thread_safe
?
&
sync
:
0
);
scoped_optional_lock_t
sync_lock
(
thread_safe
?
&
sync
:
NULL
);
// Check whether the library haven't been shut down yet.
if
(
unlikely
(
ctx_terminated
))
{
...
...
@@ -1158,7 +1158,7 @@ int zmq::socket_base_t::send (msg_t *msg_, int flags_)
int
zmq
::
socket_base_t
::
recv
(
msg_t
*
msg_
,
int
flags_
)
{
scoped_optional_lock_t
sync_lock
(
thread_safe
?
&
sync
:
0
);
scoped_optional_lock_t
sync_lock
(
thread_safe
?
&
sync
:
NULL
);
// Check whether the library haven't been shut down yet.
if
(
unlikely
(
ctx_terminated
))
{
...
...
@@ -1254,7 +1254,7 @@ int zmq::socket_base_t::recv (msg_t *msg_, int flags_)
int
zmq
::
socket_base_t
::
close
()
{
scoped_optional_lock_t
sync_lock
(
thread_safe
?
&
sync
:
0
);
scoped_optional_lock_t
sync_lock
(
thread_safe
?
&
sync
:
NULL
);
// Remove all existing signalers for thread safe sockets
if
(
thread_safe
)
...
...
@@ -1292,7 +1292,7 @@ void zmq::socket_base_t::start_reaping (poller_t *poller_)
if
(
!
thread_safe
)
fd
=
((
mailbox_t
*
)
mailbox
)
->
get_fd
();
else
{
scoped_optional_lock_t
sync_lock
(
thread_safe
?
&
sync
:
0
);
scoped_optional_lock_t
sync_lock
(
thread_safe
?
&
sync
:
NULL
);
reaper_signaler
=
new
signaler_t
();
...
...
@@ -1485,13 +1485,15 @@ void zmq::socket_base_t::in_event ()
// of the reaper thread. Process any commands from other threads/sockets
// that may be available at the moment. Ultimately, the socket will
// be destroyed.
scoped_optional_lock_t
sync_lock
(
thread_safe
?
&
sync
:
0
);
{
scoped_optional_lock_t
sync_lock
(
thread_safe
?
&
sync
:
NULL
);
// If the socket is thread safe we need to unsignal the reaper signaler
if
(
thread_safe
)
reaper_signaler
->
recv
();
process_commands
(
0
,
false
);
}
check_destroy
();
}
...
...
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