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
328abb98
Commit
328abb98
authored
Jun 08, 2018
by
Joseph Noir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve simultaneous handshakes via UDP
parent
9616bd0c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
3 deletions
+35
-3
libcaf_io/caf/io/basp/instance.hpp
libcaf_io/caf/io/basp/instance.hpp
+8
-0
libcaf_io/caf/io/basp/routing_table.hpp
libcaf_io/caf/io/basp/routing_table.hpp
+9
-0
libcaf_io/src/routing_table.cpp
libcaf_io/src/routing_table.cpp
+18
-3
No files found.
libcaf_io/caf/io/basp/instance.hpp
View file @
328abb98
...
...
@@ -348,6 +348,12 @@ public:
"connection: "
<<
CAF_ARG
(
hdr
.
source_node
));
callee_
.
finalize_handshake
(
hdr
.
source_node
,
aid
,
sigs
);
return
false
;
}
else
if
(
!
tcp_based
&&
(
tbl_
.
received_client_handshake
(
hdr
.
source_node
)
&&
this_node
()
<
hdr
.
source_node
))
{
CAF_LOG_INFO
(
"simultaneous handshake, let the other node proceed: "
<<
CAF_ARG
(
hdr
.
source_node
));
callee_
.
finalize_handshake
(
hdr
.
source_node
,
aid
,
sigs
);
return
false
;
}
// Add this node to our contacts.
CAF_LOG_INFO
(
"new endpoint:"
<<
CAF_ARG
(
hdr
.
source_node
));
...
...
@@ -411,6 +417,7 @@ public:
}
else
{
if
(
!
lr
.
known
)
tbl_
.
add
(
hdr
.
source_node
);
tbl_
.
received_client_handshake
(
hdr
.
source_node
,
true
);
uint16_t
seq
=
ep
->
requires_ordering
?
ep
->
seq_outgoing
++
:
0
;
write_server_handshake
(
ctx
,
callee_
.
get_buffer
(
hdl
),
port
,
seq
);
callee_
.
flush
(
hdl
);
...
...
@@ -437,6 +444,7 @@ public:
}
CAF_LOG_INFO
(
"new endpoint:"
<<
CAF_ARG
(
hdr
.
source_node
));
tbl_
.
handle
(
hdr
.
source_node
,
hdl
);
tbl_
.
received_client_handshake
(
hdr
.
source_node
,
false
);
callee_
.
learned_new_node
(
hdr
.
source_node
);
callee_
.
send_buffered_messages
(
ctx
,
hdr
.
source_node
,
hdl
);
break
;
...
...
libcaf_io/caf/io/basp/routing_table.hpp
View file @
328abb98
...
...
@@ -133,6 +133,12 @@ public:
/// Get a reference to an address map for the local node.
const
address_map
&
local_addresses
();
// Set the received client handshake flag for `nid`.
bool
received_client_handshake
(
const
node_id
&
nid
,
bool
flag
);
// Get the received client handshake flag for `nid`.
bool
received_client_handshake
(
const
node_id
&
nid
);
public:
/// Entry to bundle information for a remote endpoint.
struct
node_info
{
...
...
@@ -140,6 +146,9 @@ public:
optional
<
endpoint_handle
>
hdl
;
/// The endpoint who told us about the node.
optional
<
node_id
>
origin
;
/// Track if we received a client handshake to solve simultaneous
/// handshake with UDP.
bool
received_client_handshake
;
};
template
<
class
Map
,
class
Fallback
>
...
...
libcaf_io/src/routing_table.cpp
View file @
328abb98
...
...
@@ -59,13 +59,13 @@ void routing_table::add(const node_id& nid, const endpoint_handle& hdl) {
CAF_ASSERT
(
nid_by_hdl_
.
count
(
hdl
)
==
0
);
CAF_ASSERT
(
node_information_base_
.
count
(
nid
)
==
0
);
nid_by_hdl_
.
emplace
(
hdl
,
nid
);
node_information_base_
[
nid
]
=
node_info
{
hdl
,
none
};
node_information_base_
[
nid
]
=
node_info
{
hdl
,
none
,
false
};
parent_
->
parent
().
notify
<
hook
::
new_connection_established
>
(
nid
);
}
void
routing_table
::
add
(
const
node_id
&
nid
,
const
node_id
&
origin
)
{
CAF_ASSERT
(
node_information_base_
.
count
(
nid
)
==
0
);
node_information_base_
[
nid
]
=
node_info
{
none
,
origin
};
node_information_base_
[
nid
]
=
node_info
{
none
,
origin
,
false
};
// TODO: Some new related hook?
//parent_->parent().notify<hook::new_connection_established>(nid);
}
...
...
@@ -73,7 +73,7 @@ void routing_table::add(const node_id& nid, const node_id& origin) {
void
routing_table
::
add
(
const
node_id
&
nid
)
{
//CAF_ASSERT(hdl_by_nid_.count(nid) == 0);
CAF_ASSERT
(
node_information_base_
.
count
(
nid
)
==
0
);
node_information_base_
[
nid
]
=
node_info
{
none
,
none
};
node_information_base_
[
nid
]
=
node_info
{
none
,
none
,
false
};
// TODO: Some new related hook?
//parent_->parent().notify<hook::new_connection_established>(nid);
}
...
...
@@ -129,6 +129,21 @@ const routing_table::address_map& routing_table::local_addresses() {
return
local_addrs_
;
}
bool
routing_table
::
received_client_handshake
(
const
node_id
&
nid
,
bool
flag
)
{
auto
i
=
node_information_base_
.
find
(
nid
);
if
(
i
==
node_information_base_
.
end
())
return
false
;
i
->
second
.
received_client_handshake
=
flag
;
return
true
;
}
bool
routing_table
::
received_client_handshake
(
const
node_id
&
nid
)
{
auto
i
=
node_information_base_
.
find
(
nid
);
if
(
i
==
node_information_base_
.
end
())
return
false
;
return
i
->
second
.
received_client_handshake
;
}
}
// namespace basp
}
// namespace io
}
// namespace caf
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