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
Admin message
Maintenance moved to Monday 17.3. at 13:00. ETA 60 - 90 minutes.
Show more breadcrumbs
Beyond AKA
Beyond Protocol
Commits
e9d069bb
Commit
e9d069bb
authored
2 years ago
by
Nicolas Pope
Browse files
Options
Downloads
Patches
Plain Diff
#18
Increase msgpack buffer if needed
parent
9da2399c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/peer.cpp
+9
-6
9 additions, 6 deletions
src/peer.cpp
src/peer.hpp
+3
-1
3 additions, 1 deletion
src/peer.hpp
with
12 additions
and
7 deletions
src/peer.cpp
+
9
−
6
View file @
e9d069bb
...
...
@@ -288,21 +288,24 @@ void Peer::data() {
int
rc
=
0
;
// Only need to lock and reserve buffer if there isn't enough
if
(
recv_buf_
.
buffer_capacity
()
<
kMaxMessage
)
{
if
(
recv_buf_
.
buffer_capacity
()
<
recv_buf_max_
)
{
UNIQUE_LOCK
(
recv_mtx_
,
lk
);
recv_buf_
.
reserve_buffer
(
kMaxMessage
);
recv_buf_
.
reserve_buffer
(
recv_buf_max_
);
}
in
t
cap
=
static_cast
<
int
>
(
recv_buf_
.
buffer_capacity
()
)
;
size_
t
cap
=
recv_buf_
.
buffer_capacity
();
try
{
rc
=
sock_
->
recv
(
recv_buf_
.
buffer
(),
recv_buf_
.
buffer_capacity
());
if
(
rc
>=
cap
-
1
)
{
if
(
rc
>=
static_cast
<
int
>
(
cap
-
1
)
)
{
net_
->
_notifyError
(
this
,
Error
::
kBufferSize
,
"Too much data received"
);
// TODO(Nick): Increase the buffer size next time
// Increase buffer size
if
(
recv_buf_max_
<
kMaxMessage
)
{
recv_buf_max_
+=
512
*
1024
;
}
}
if
(
cap
<
(
kMaxMessage
/
10
))
{
if
(
cap
<
(
recv_buf_max_
/
10
))
{
net_
->
_notifyError
(
this
,
Error
::
kBufferSize
,
"Buffer is at capacity"
);
}
}
catch
(
std
::
exception
&
ex
)
{
...
...
This diff is collapsed.
Click to expand it.
src/peer.hpp
+
3
−
1
View file @
e9d069bb
...
...
@@ -213,7 +213,8 @@ class Peer {
void
data
();
public
:
static
const
int
kMaxMessage
=
2
*
1024
*
1024
;
// 10Mb currently
static
const
int
kMaxMessage
=
4
*
1024
*
1024
;
// 4Mb currently
static
const
int
kDefaultMessage
=
512
*
1024
;
// 0.5Mb currently
private
:
// Functions
bool
socketError
();
// Process one error from socket
...
...
@@ -266,6 +267,7 @@ class Peer {
std
::
atomic_flag
recv_checked_
=
ATOMIC_FLAG_INIT
;
msgpack
::
unpacker
recv_buf_
;
size_t
recv_buf_max_
=
kDefaultMessage
;
MUTEX
recv_mtx_
;
// Send buffers
...
...
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