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
fa976f87
Commit
fa976f87
authored
Aug 07, 2018
by
Simon Giesecke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplified uses of erase
parent
6357890f
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
39 additions
and
49 deletions
+39
-49
ctx.cpp
src/ctx.cpp
+10
-12
dish.cpp
src/dish.cpp
+1
-6
mailbox_safe.cpp
src/mailbox_safe.cpp
+4
-6
own.cpp
src/own.cpp
+2
-5
poller_base.cpp
src/poller_base.cpp
+17
-14
radio.cpp
src/radio.cpp
+4
-2
router.cpp
src/router.cpp
+1
-4
No files found.
src/ctx.cpp
View file @
fa976f87
...
...
@@ -448,10 +448,7 @@ int zmq::thread_ctx_t::set (int option_, int optval_)
_thread_affinity_cpus
.
insert
(
optval_
);
}
else
if
(
option_
==
ZMQ_THREAD_AFFINITY_CPU_REMOVE
&&
optval_
>=
0
)
{
scoped_lock_t
locker
(
_opt_sync
);
std
::
set
<
int
>::
iterator
it
=
_thread_affinity_cpus
.
find
(
optval_
);
if
(
it
!=
_thread_affinity_cpus
.
end
())
{
_thread_affinity_cpus
.
erase
(
it
);
}
else
{
if
(
0
==
_thread_affinity_cpus
.
erase
(
optval_
))
{
errno
=
EINVAL
;
rc
=
-
1
;
}
...
...
@@ -531,15 +528,16 @@ void zmq::ctx_t::unregister_endpoints (socket_base_t *socket_)
{
scoped_lock_t
locker
(
_endpoints_sync
);
endpoints_t
::
iterator
it
=
_endpoints
.
begin
();
while
(
it
!=
_endpoints
.
end
())
{
if
(
it
->
second
.
socket
==
socket_
)
{
endpoints_t
::
iterator
to_erase
=
it
;
for
(
endpoints_t
::
iterator
it
=
_endpoints
.
begin
();
it
!=
_endpoints
.
end
();)
{
if
(
it
->
second
.
socket
==
socket_
)
#if __cplusplus >= 201103L
it
=
_endpoints
.
erase
(
it
);
#else
_endpoints
.
erase
(
it
++
);
#endif
else
++
it
;
_endpoints
.
erase
(
to_erase
);
continue
;
}
++
it
;
}
}
...
...
src/dish.cpp
View file @
fa976f87
...
...
@@ -137,16 +137,11 @@ int zmq::dish_t::xleave (const char *group_)
return
-
1
;
}
subscriptions_t
::
iterator
it
=
std
::
find
(
_subscriptions
.
begin
(),
_subscriptions
.
end
(),
group
);
if
(
it
==
_subscriptions
.
end
())
{
if
(
0
==
_subscriptions
.
erase
(
group
))
{
errno
=
EINVAL
;
return
-
1
;
}
_subscriptions
.
erase
(
it
);
msg_t
msg
;
int
rc
=
msg
.
init_leave
();
errno_assert
(
rc
==
0
);
...
...
src/mailbox_safe.cpp
View file @
fa976f87
...
...
@@ -32,6 +32,8 @@
#include "clock.hpp"
#include "err.hpp"
#include <algorithm>
zmq
::
mailbox_safe_t
::
mailbox_safe_t
(
mutex_t
*
sync_
)
:
_sync
(
sync_
)
{
// Get the pipe into passive state. That way, if the users starts by
...
...
@@ -58,13 +60,9 @@ void zmq::mailbox_safe_t::add_signaler (signaler_t *signaler_)
void
zmq
::
mailbox_safe_t
::
remove_signaler
(
signaler_t
*
signaler_
)
{
std
::
vector
<
signaler_t
*>::
iterator
it
=
_signalers
.
begin
();
// TODO: make a copy of array and signal outside the lock
for
(;
it
!=
_signalers
.
end
();
++
it
)
{
if
(
*
it
==
signaler_
)
break
;
}
std
::
vector
<
signaler_t
*>::
iterator
it
=
std
::
find
(
_signalers
.
begin
(),
_signalers
.
end
(),
signaler_
);
if
(
it
!=
_signalers
.
end
())
_signalers
.
erase
(
it
);
...
...
src/own.cpp
View file @
fa976f87
...
...
@@ -102,15 +102,12 @@ void zmq::own_t::process_term_req (own_t *object_)
if
(
_terminating
)
return
;
// If I/O object is well and alive let's ask it to terminate.
owned_t
::
iterator
it
=
std
::
find
(
_owned
.
begin
(),
_owned
.
end
(),
object_
);
// If not found, we assume that termination request was already sent to
// the object so we can safely ignore the request.
if
(
it
==
_owned
.
end
(
))
if
(
0
==
_owned
.
erase
(
object_
))
return
;
_owned
.
erase
(
it
);
// If I/O object is well and alive let's ask it to terminate.
register_term_acks
(
1
);
// Note that this object is the root of the (partial shutdown) thus, its
...
...
src/poller_base.cpp
View file @
fa976f87
...
...
@@ -82,29 +82,32 @@ uint64_t zmq::poller_base_t::execute_timers ()
return
0
;
// Get the current time.
uint64_t
current
=
_clock
.
now_ms
();
const
uint64_t
current
=
_clock
.
now_ms
();
// Execute the timers that are already due.
timers_t
::
iterator
it
=
_timers
.
begin
();
while
(
it
!=
_timers
.
end
())
{
const
timers_t
::
iterator
begin
=
_timers
.
begin
();
const
timers_t
::
iterator
end
=
_timers
.
end
();
uint64_t
res
=
0
;
timers_t
::
iterator
it
=
begin
;
for
(;
it
!=
end
;
++
it
)
{
// If we have to wait to execute the item, same will be true about
// all the following items (multimap is sorted). Thus we can stop
// checking the subsequent timers and return the time to wait for
// the next timer (at least 1ms).
if
(
it
->
first
>
current
)
return
it
->
first
-
current
;
// checking the subsequent timers.
if
(
it
->
first
>
current
)
{
res
=
it
->
first
-
current
;
break
;
}
// Trigger the timer.
it
->
second
.
sink
->
timer_event
(
it
->
second
.
id
);
// Remove it from the list of active timers.
timers_t
::
iterator
o
=
it
;
++
it
;
_timers
.
erase
(
o
);
}
// There are no more timers.
return
0
;
// Remove them from the list of active timers.
_timers
.
erase
(
begin
,
it
);
// Return the time to wait for the next timer (at least 1ms), or 0, if
// there are no more timers.
return
res
;
}
zmq
::
worker_poller_base_t
::
worker_poller_base_t
(
const
thread_ctx_t
&
ctx_
)
:
...
...
src/radio.cpp
View file @
fa976f87
...
...
@@ -122,12 +122,14 @@ int zmq::radio_t::xsetsockopt (int option_,
void
zmq
::
radio_t
::
xpipe_terminated
(
pipe_t
*
pipe_
)
{
// NOTE: erase invalidates an iterator, and that's why it's not incrementing in post-loop
// read-after-free caught by Valgrind, see https://github.com/zeromq/libzmq/pull/1771
for
(
subscriptions_t
::
iterator
it
=
_subscriptions
.
begin
();
it
!=
_subscriptions
.
end
();)
{
if
(
it
->
second
==
pipe_
)
{
#if __cplusplus >= 201103L
it
=
_subscriptions
.
erase
(
it
);
#else
_subscriptions
.
erase
(
it
++
);
#endif
}
else
{
++
it
;
}
...
...
src/router.cpp
View file @
fa976f87
...
...
@@ -150,10 +150,7 @@ int zmq::router_t::xsetsockopt (int option_,
void
zmq
::
router_t
::
xpipe_terminated
(
pipe_t
*
pipe_
)
{
std
::
set
<
pipe_t
*>::
iterator
it
=
_anonymous_pipes
.
find
(
pipe_
);
if
(
it
!=
_anonymous_pipes
.
end
())
_anonymous_pipes
.
erase
(
it
);
else
{
if
(
0
==
_anonymous_pipes
.
erase
(
pipe_
))
{
erase_out_pipe
(
pipe_
);
_fq
.
pipe_terminated
(
pipe_
);
pipe_
->
rollback
();
...
...
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