Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
Beyond Protocol
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Beyond AKA
Beyond Protocol
Commits
a10ec3d2
Commit
a10ec3d2
authored
3 years ago
by
Nicolas Pope
Browse files
Options
Downloads
Patches
Plain Diff
Improve handshake reliability
parent
1288564d
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/peer.cpp
+17
-2
17 additions, 2 deletions
src/peer.cpp
test/stream_unit.cpp
+15
-9
15 additions, 9 deletions
test/stream_unit.cpp
with
32 additions
and
11 deletions
src/peer.cpp
+
17
−
2
View file @
a10ec3d2
...
...
@@ -405,8 +405,23 @@ bool Peer::_data() {
// Must handle immediately with no other thread able
// to read next message before completion.
// The handshake handler must not block.
//disp_->dispatch(*this, obj);
//return true;
try
{
disp_
->
dispatch
(
*
this
,
obj
);
}
catch
(
const
std
::
exception
&
e
)
{
net_
->
_notifyError
(
this
,
ftl
::
protocol
::
Error
::
kDispatchFailed
,
e
.
what
());
}
++
job_count_
;
ftl
::
pool
.
push
([
this
](
int
id
)
{
try
{
_data
();
}
catch
(
const
std
::
exception
&
e
)
{
net_
->
_notifyError
(
this
,
ftl
::
protocol
::
Error
::
kUnknown
,
e
.
what
());
}
--
job_count_
;
});
return
true
;
}
}
catch
(...)
{
DLOG
(
WARNING
)
<<
"Bad first message format... waiting"
;
...
...
This diff is collapsed.
Click to expand it.
test/stream_unit.cpp
+
15
−
9
View file @
a10ec3d2
...
...
@@ -38,12 +38,12 @@ class TestStream : public ftl::protocol::Stream {
//std::function<void(const StreamPacket &, const Packet &)> cb_;
};
TEST_CASE
(
"ftl::stream::Muxer()::
write
"
,
"[stream]"
)
{
TEST_CASE
(
"ftl::stream::Muxer()::
post, distinct framesets
"
,
"[stream]"
)
{
std
::
unique_ptr
<
Muxer
>
mux
=
std
::
make_unique
<
Muxer
>
();
REQUIRE
(
mux
);
SECTION
(
"write with one stream"
)
{
SECTION
(
"write with one stream
fails
"
)
{
std
::
shared_ptr
<
Stream
>
s
=
std
::
make_shared
<
TestStream
>
();
REQUIRE
(
s
);
...
...
@@ -104,7 +104,7 @@ TEST_CASE("ftl::stream::Muxer()::write", "[stream]") {
}
}
TEST_CASE
(
"ftl::stream::Muxer()::post
multi-
frameset"
,
"[stream]"
)
{
TEST_CASE
(
"ftl::stream::Muxer()::post
, single
frameset"
,
"[stream]"
)
{
std
::
unique_ptr
<
Muxer
>
mux
=
std
::
make_unique
<
Muxer
>
();
REQUIRE
(
mux
);
...
...
@@ -115,7 +115,7 @@ TEST_CASE("ftl::stream::Muxer()::post multi-frameset", "[stream]") {
std
::
shared_ptr
<
Stream
>
s2
=
std
::
make_shared
<
TestStream
>
();
REQUIRE
(
s2
);
mux
->
add
(
s1
);
mux
->
add
(
s1
,
1
);
mux
->
add
(
s2
,
1
);
StreamPacket
tspkt
=
{
4
,
0
,
0
,
1
,
Channel
::
kColour
};
...
...
@@ -125,15 +125,15 @@ TEST_CASE("ftl::stream::Muxer()::post multi-frameset", "[stream]") {
});
REQUIRE
(
s1
->
post
({
4
,
100
,
0
,
0
,
Channel
::
kColour
},{})
);
REQUIRE
(
tspkt
.
streamID
==
0
);
REQUIRE
(
tspkt
.
streamID
==
1
);
REQUIRE
(
tspkt
.
frame_number
==
0
);
REQUIRE
(
s2
->
post
({
4
,
101
,
0
,
0
,
Channel
::
kColour
},{})
);
REQUIRE
(
tspkt
.
streamID
==
1
);
REQUIRE
(
tspkt
.
frame_number
==
0
);
REQUIRE
(
tspkt
.
frame_number
==
1
);
StreamPacket
tspkt2
=
{
4
,
0
,
0
,
1
,
Channel
::
kColour
};
StreamPacket
tspkt3
=
{
4
,
0
,
0
,
1
,
Channel
::
kColour
};
StreamPacket
tspkt2
=
{
4
,
0
,
4
,
4
,
Channel
::
kColour
};
StreamPacket
tspkt3
=
{
4
,
0
,
4
,
4
,
Channel
::
kColour
};
auto
h2
=
s1
->
onPacket
([
&
tspkt2
](
const
StreamPacket
&
spkt
,
const
Packet
&
pkt
)
{
tspkt2
=
spkt
;
return
true
;
...
...
@@ -143,9 +143,15 @@ TEST_CASE("ftl::stream::Muxer()::post multi-frameset", "[stream]") {
return
true
;
});
REQUIRE
(
mux
->
post
({
4
,
200
,
1
,
0
,
Channel
::
kColour
},{})
);
REQUIRE
(
mux
->
post
({
4
,
200
,
1
,
1
,
Channel
::
kColour
},{})
);
REQUIRE
(
tspkt2
.
streamID
==
4
);
REQUIRE
(
tspkt2
.
frame_number
==
4
);
REQUIRE
(
tspkt3
.
streamID
==
0
);
REQUIRE
(
tspkt3
.
frame_number
==
0
);
REQUIRE
(
mux
->
post
({
4
,
200
,
1
,
0
,
Channel
::
kColour
},{})
);
REQUIRE
(
tspkt2
.
streamID
==
0
);
REQUIRE
(
tspkt2
.
frame_number
==
0
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment