Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
77134fe2
Commit
77134fe2
authored
May 03, 2020
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'issue/1065' into topic/novaquark
parents
762a926a
9bfcfec1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
25 deletions
+23
-25
libcaf_io/src/io/basp/routing_table.cpp
libcaf_io/src/io/basp/routing_table.cpp
+23
-25
No files found.
libcaf_io/src/io/basp/routing_table.cpp
View file @
77134fe2
...
...
@@ -85,36 +85,34 @@ node_id routing_table::lookup_indirect(const node_id& nid) const {
node_id
routing_table
::
erase_direct
(
const
connection_handle
&
hdl
)
{
std
::
unique_lock
<
std
::
mutex
>
guard
{
mtx_
};
// Sanity check: do nothing if the handle is not mapped to a node.
auto
i
=
direct_by_hdl_
.
find
(
hdl
);
if
(
i
==
direct_by_hdl_
.
end
())
return
{};
// Check whether this handle was the primary mapping for the node.
auto
&
node
=
i
->
second
;
// We always remove i from direct_by_hdl_.
auto
node
=
std
::
move
(
i
->
second
);
direct_by_hdl_
.
erase
(
i
);
// Sanity check: direct_by_nid_ should contain a reverse mapping.
auto
j
=
direct_by_nid_
.
find
(
node
);
if
(
j
!=
direct_by_nid_
.
end
())
{
if
(
j
->
second
==
hdl
)
{
// Try to find an alternative for falling back to a differnt connection.
auto
predicate
=
[
&
](
handle_to_node_map
::
value_type
&
kvp
)
{
return
kvp
.
second
==
node
;
};
auto
e
=
direct_by_hdl_
.
end
();
auto
alternative
=
std
::
find_if
(
direct_by_hdl_
.
begin
(),
e
,
predicate
);
if
(
alternative
!=
e
)
{
// Update node <-> handle mapping and only drop the handle.
j
->
second
=
alternative
->
first
;
}
else
{
// This was the only connection to the node. Drop it.
auto
result
=
std
::
move
(
node
);
direct_by_nid_
.
erase
(
j
);
direct_by_hdl_
.
erase
(
i
);
return
result
;
}
}
if
(
j
==
direct_by_nid_
.
end
())
{
CAF_LOG_WARNING
(
"no reverse mapping exists for the connection handle"
);
return
node
;
}
// Try to find an alternative connection for communicating with the node.
auto
predicate
=
[
&
](
const
handle_to_node_map
::
value_type
&
kvp
)
{
return
kvp
.
second
==
node
;
};
auto
e
=
direct_by_hdl_
.
end
();
auto
alternative
=
std
::
find_if
(
direct_by_hdl_
.
begin
(),
e
,
predicate
);
if
(
alternative
!=
e
)
{
// Update node <-> handle mapping.
j
->
second
=
alternative
->
first
;
return
{};
}
else
{
// Drop the node after losing the last connection to it.
direct_by_nid_
.
erase
(
j
);
return
node
;
}
// Unless this was the only connection to the node, we only drop the
// connection handle.
direct_by_hdl_
.
erase
(
i
);
return
{};
}
bool
routing_table
::
erase_indirect
(
const
node_id
&
dest
)
{
...
...
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