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
1881735f
Commit
1881735f
authored
Aug 21, 2017
by
Luca Boccassi
Committed by
GitHub
Aug 21, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2710 from sigiesec/remove-select-rm_fd-code-duplication
Problem: code duplication within zmq::select_t::rm_fd
parents
ee7f5b9b
c3c25155
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
22 deletions
+22
-22
select.cpp
src/select.cpp
+19
-22
select.hpp
src/select.hpp
+3
-0
No files found.
src/select.cpp
View file @
1881735f
...
...
@@ -90,6 +90,20 @@ zmq::select_t::handle_t zmq::select_t::add_fd (fd_t fd_, i_poll_events *events_)
return
fd_
;
}
zmq
::
select_t
::
fd_entries_t
::
iterator
zmq
::
select_t
::
find_fd_entry_by_handle
(
fd_entries_t
&
fd_entries
,
handle_t
handle_
)
{
fd_entries_t
::
iterator
fd_entry_it
;
for
(
fd_entry_it
=
fd_entries
.
begin
();
fd_entry_it
!=
fd_entries
.
end
();
++
fd_entry_it
)
if
(
fd_entry_it
->
fd
==
handle_
)
break
;
zmq_assert
(
fd_entry_it
!=
fd_entries
.
end
());
return
fd_entry_it
;
}
void
zmq
::
select_t
::
rm_fd
(
handle_t
handle_
)
{
#if defined ZMQ_HAVE_WINDOWS
...
...
@@ -99,40 +113,23 @@ void zmq::select_t::rm_fd (handle_t handle_)
family_entries_t
::
iterator
family_entry_it
=
family_entries
.
find
(
family
);
family_entry_t
&
family_entry
=
family_entry_it
->
second
;
fd_entries_t
::
iterator
fd_entry_it
=
find_fd_entry_by_handle
(
family_entry
.
fd_entries
,
handle_
);
if
(
family_entry_it
!=
current_family_entry_it
)
{
// Family is not currently being iterated and can be safely
// modified in-place. So later it can be skipped without
// re-verifying its content.
fd_entries_t
::
iterator
fd_entry_it
;
for
(
fd_entry_it
=
family_entry
.
fd_entries
.
begin
();
fd_entry_it
!=
family_entry
.
fd_entries
.
end
();
++
fd_entry_it
)
if
(
fd_entry_it
->
fd
==
handle_
)
break
;
zmq_assert
(
fd_entry_it
!=
family_entry
.
fd_entries
.
end
());
family_entry
.
fd_entries
.
erase
(
fd_entry_it
);
family_entry
.
fds_set
.
remove_fd
(
handle_
);
}
else
{
// Otherwise mark removed entries as retired. It will be cleaned up
// at the end of the iteration. See zmq::select_t::loop
fd_entries_t
::
iterator
fd_entry_it
;
for
(
fd_entry_it
=
family_entry
.
fd_entries
.
begin
();
fd_entry_it
!=
family_entry
.
fd_entries
.
end
();
++
fd_entry_it
)
if
(
fd_entry_it
->
fd
==
handle_
)
break
;
zmq_assert
(
fd_entry_it
!=
family_entry
.
fd_entries
.
end
());
fd_entry_it
->
fd
=
retired_fd
;
family_entry
.
fds_set
.
remove_fd
(
handle_
);
family_entry
.
retired
=
true
;
}
family_entry
.
fds_set
.
remove_fd
(
handle_
);
#else
fd_entries_t
::
iterator
fd_entry_it
;
for
(
fd_entry_it
=
fd_entries
.
begin
();
fd_entry_it
!=
fd_entries
.
end
();
++
fd_entry_it
)
if
(
fd_entry_it
->
fd
==
handle_
)
break
;
zmq_assert
(
fd_entry_it
!=
fd_entries
.
end
());
fd_entries_t
::
iterator
fd_entry_it
=
find_fd_entry_by_handle
(
fd_entries
,
handle_
);
fd_entry_it
->
fd
=
retired_fd
;
fds_set
.
remove_fd
(
handle_
);
...
...
src/select.hpp
View file @
1881735f
...
...
@@ -151,6 +151,9 @@ namespace zmq
// Checks if an fd_entry_t is retired.
static
bool
is_retired_fd
(
const
fd_entry_t
&
entry
);
static
fd_entries_t
::
iterator
find_fd_entry_by_handle
(
fd_entries_t
&
fd_entries
,
handle_t
handle_
);
// If true, thread is shutting down.
bool
stopping
;
...
...
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