Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
opendht
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
opendht
Commits
97fccc44
Commit
97fccc44
authored
Apr 8, 2016
by
Simon Désaulniers
Committed by
Adrien Béraud
May 2, 2016
Browse files
Options
Downloads
Patches
Plain Diff
dht: fix drop due to ratelimit bug
parent
ee318818
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
include/opendht/network_engine.h
+0
-1
0 additions, 1 deletion
include/opendht/network_engine.h
src/network_engine.cpp
+4
-4
4 additions, 4 deletions
src/network_engine.cpp
with
4 additions
and
5 deletions
include/opendht/network_engine.h
+
0
−
1
View file @
97fccc44
...
@@ -539,7 +539,6 @@ private:
...
@@ -539,7 +539,6 @@ private:
std
::
queue
<
time_point
>
rate_limit_time
{};
std
::
queue
<
time_point
>
rate_limit_time
{};
static
std
::
mt19937
rd_device
;
static
std
::
mt19937
rd_device
;
time_point
now
;
// requests handling
// requests handling
uint16_t
transaction_id
{
1
};
uint16_t
transaction_id
{
1
};
...
...
This diff is collapsed.
Click to expand it.
src/network_engine.cpp
+
4
−
4
View file @
97fccc44
...
@@ -78,13 +78,13 @@ bool
...
@@ -78,13 +78,13 @@ bool
NetworkEngine
::
rateLimit
()
NetworkEngine
::
rateLimit
()
{
{
using
namespace
std
::
chrono
;
using
namespace
std
::
chrono
;
while
(
not
rate_limit_time
.
empty
()
and
duration_cast
<
seconds
>
(
now
-
rate_limit_time
.
front
())
>
seconds
(
1
))
while
(
not
rate_limit_time
.
empty
()
and
duration_cast
<
seconds
>
(
scheduler
.
time
()
-
rate_limit_time
.
front
())
>
seconds
(
1
))
rate_limit_time
.
pop
();
rate_limit_time
.
pop
();
if
(
rate_limit_time
.
size
()
>=
MAX_REQUESTS_PER_SEC
)
if
(
rate_limit_time
.
size
()
>=
MAX_REQUESTS_PER_SEC
)
return
false
;
return
false
;
rate_limit_time
.
emplace
(
now
);
rate_limit_time
.
emplace
(
scheduler
.
time
()
);
return
true
;
return
true
;
}
}
...
@@ -631,11 +631,11 @@ NetworkEngine::sendAnnounceValue(std::shared_ptr<Node> n, const InfoHash& infoha
...
@@ -631,11 +631,11 @@ NetworkEngine::sendAnnounceValue(std::shared_ptr<Node> n, const InfoHash& infoha
msgpack
::
packer
<
msgpack
::
sbuffer
>
pk
(
&
buffer
);
msgpack
::
packer
<
msgpack
::
sbuffer
>
pk
(
&
buffer
);
pk
.
pack_map
(
5
);
pk
.
pack_map
(
5
);
pk
.
pack
(
std
::
string
(
"a"
));
pk
.
pack_map
((
created
<
now
?
5
:
4
));
pk
.
pack
(
std
::
string
(
"a"
));
pk
.
pack_map
((
created
<
scheduler
.
time
()
?
5
:
4
));
pk
.
pack
(
std
::
string
(
"id"
));
pk
.
pack
(
myid
);
pk
.
pack
(
std
::
string
(
"id"
));
pk
.
pack
(
myid
);
pk
.
pack
(
std
::
string
(
"h"
));
pk
.
pack
(
infohash
);
pk
.
pack
(
std
::
string
(
"h"
));
pk
.
pack
(
infohash
);
pk
.
pack
(
std
::
string
(
"values"
));
pk
.
pack_array
(
1
);
pk
.
pack
(
value
);
pk
.
pack
(
std
::
string
(
"values"
));
pk
.
pack_array
(
1
);
pk
.
pack
(
value
);
if
(
created
<
now
)
{
if
(
created
<
scheduler
.
time
()
)
{
pk
.
pack
(
std
::
string
(
"c"
));
pk
.
pack
(
std
::
string
(
"c"
));
pk
.
pack
(
to_time_t
(
created
));
pk
.
pack
(
to_time_t
(
created
));
}
}
...
...
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
sign in
to comment