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
38306eae
Commit
38306eae
authored
Dec 15, 2015
by
Simon Désaulniers
Browse files
Options
Downloads
Patches
Plain Diff
only one refill allowed before expiring search
parent
04632a82
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/opendht/dht.h
+1
-0
1 addition, 0 deletions
include/opendht/dht.h
python/tools/benchmark.py
+4
-4
4 additions, 4 deletions
python/tools/benchmark.py
src/dht.cpp
+9
-4
9 additions, 4 deletions
src/dht.cpp
with
14 additions
and
8 deletions
include/opendht/dht.h
+
1
−
0
View file @
38306eae
...
@@ -609,6 +609,7 @@ private:
...
@@ -609,6 +609,7 @@ private:
bool
expired
{
false
};
/* no node, or all nodes expired */
bool
expired
{
false
};
/* no node, or all nodes expired */
bool
done
{
false
};
/* search is over, cached for later */
bool
done
{
false
};
/* search is over, cached for later */
bool
refilled
{
false
};
std
::
vector
<
SearchNode
>
nodes
{};
std
::
vector
<
SearchNode
>
nodes
{};
std
::
vector
<
Announce
>
announce
{};
std
::
vector
<
Announce
>
announce
{};
std
::
vector
<
Get
>
callbacks
{};
std
::
vector
<
Get
>
callbacks
{};
...
...
This diff is collapsed.
Click to expand it.
python/tools/benchmark.py
+
4
−
4
View file @
38306eae
This diff is collapsed.
Click to expand it.
src/dht.cpp
+
9
−
4
View file @
38306eae
...
@@ -1048,13 +1048,19 @@ Dht::searchStep(Search& sr)
...
@@ -1048,13 +1048,19 @@ Dht::searchStep(Search& sr)
return
sn
.
candidate
or
sn
.
node
->
isExpired
(
now
);
return
sn
.
candidate
or
sn
.
node
->
isExpired
(
now
);
})
==
sr
.
nodes
.
size
())
})
==
sr
.
nodes
.
size
())
{
{
unsigned
added
=
sr
.
refill
(
sr
.
af
==
AF_INET
?
buckets
:
buckets6
,
now
);
unsigned
added
=
0
;
if
(
not
sr
.
refilled
)
{
added
=
sr
.
refill
(
sr
.
af
==
AF_INET
?
buckets
:
buckets6
,
now
);
sr
.
refilled
=
true
;
}
if
(
added
)
{
if
(
added
)
{
DHT_WARN
(
"[search %s IPv%c] refilled with %u nodes"
,
sr
.
id
.
toString
().
c_str
(),
(
sr
.
af
==
AF_INET
)
?
'4'
:
'6'
,
added
);
DHT_WARN
(
"[search %s IPv%c] refilled with %u nodes"
,
sr
.
id
.
toString
().
c_str
(),
(
sr
.
af
==
AF_INET
)
?
'4'
:
'6'
,
added
);
}
else
{
}
else
{
DHT_ERROR
(
"[search %s IPv%c] expired"
,
sr
.
id
.
toString
().
c_str
(),
sr
.
af
==
AF_INET
?
'4'
:
'6'
);
DHT_ERROR
(
"[search %s IPv%c] expired"
,
sr
.
id
.
toString
().
c_str
(),
sr
.
af
==
AF_INET
?
'4'
:
'6'
);
// no nodes or all expired nodes
// no nodes or all expired nodes
sr
.
expired
=
true
;
sr
.
expired
=
true
;
// reset refilled since the search is now expired.
sr
.
refilled
=
false
;
if
(
sr
.
announce
.
empty
()
&&
sr
.
listeners
.
empty
())
{
if
(
sr
.
announce
.
empty
()
&&
sr
.
listeners
.
empty
())
{
// Listening or announcing requires keeping the cluster up to date.
// Listening or announcing requires keeping the cluster up to date.
sr
.
done
=
true
;
sr
.
done
=
true
;
...
@@ -2622,10 +2628,9 @@ Dht::processMessage(const uint8_t *buf, size_t buflen, const sockaddr *from, soc
...
@@ -2622,10 +2628,9 @@ Dht::processMessage(const uint8_t *buf, size_t buflen, const sockaddr *from, soc
}
}
{
{
// We store a value only if we think we're part of the
// We store a value only if we think we're part of the
//
2*TARGET
_NODES nodes around the target id.
//
SEARCH
_NODES nodes around the target id.
auto
closest_nodes
=
(
from
->
sa_family
==
AF_INET
?
buckets
:
buckets6
).
findClosestNodes
(
msg
.
info_hash
,
2
*
TARGET
_NODES
);
auto
closest_nodes
=
(
from
->
sa_family
==
AF_INET
?
buckets
:
buckets6
).
findClosestNodes
(
msg
.
info_hash
,
SEARCH
_NODES
);
if
(
msg
.
info_hash
.
xorCmp
(
closest_nodes
.
back
()
->
id
,
myid
)
<
0
)
{
if
(
msg
.
info_hash
.
xorCmp
(
closest_nodes
.
back
()
->
id
,
myid
)
<
0
)
{
std
::
cerr
<<
"my id ["
<<
myid
<<
"] is too far from "
<<
msg
.
info_hash
<<
". Dropping value."
<<
std
::
endl
;
DHT_WARN
(
"[node %s %s] announce too far from the target id. Dropping value."
,
DHT_WARN
(
"[node %s %s] announce too far from the target id. Dropping value."
,
msg
.
id
.
toString
().
c_str
(),
print_addr
(
from
,
fromlen
).
c_str
());
msg
.
id
.
toString
().
c_str
(),
print_addr
(
from
,
fromlen
).
c_str
());
for
(
auto
&
v
:
msg
.
values
)
{
for
(
auto
&
v
:
msg
.
values
)
{
...
...
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