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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
opendht
Commits
405b8739
Commit
405b8739
authored
3 years ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
dhtrunner: always call `opEnded` once per op
parent
7ed11a02
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/dhtrunner.cpp
+30
-13
30 additions, 13 deletions
src/dhtrunner.cpp
with
30 additions
and
13 deletions
src/dhtrunner.cpp
+
30
−
13
View file @
405b8739
...
...
@@ -297,16 +297,24 @@ DhtRunner::shutdown(ShutdownCallback cb, bool stop) {
}
if
(
logger_
)
logger_
->
d
(
"[runner %p] state changed to Stopping, %zu ongoing ops"
,
this
,
ongoing_ops
.
load
());
#ifdef OPENDHT_PROXY_CLIENT
ongoing_ops
+=
2
;
#else
ongoing_ops
++
;
#endif
shutdownCallbacks_
.
emplace_back
(
std
::
move
(
cb
));
pending_ops
.
emplace
([
=
](
SecureDht
&
)
mutable
{
auto
onShutdown
=
[
this
]{
opEnded
();
};
#ifdef OPENDHT_PROXY_CLIENT
if
(
dht_via_proxy_
)
dht_via_proxy_
->
shutdown
(
onShutdown
,
stop
);
else
opEnded
();
#endif
if
(
dht_
)
dht_
->
shutdown
(
onShutdown
,
stop
);
else
opEnded
();
});
cv
.
notify_all
();
}
...
...
@@ -823,12 +831,16 @@ DhtRunner::cancelListen(InfoHash h, size_t token)
#ifdef OPENDHT_PROXY_CLIENT
pending_ops
.
emplace
([
=
](
SecureDht
&
)
{
auto
it
=
listeners_
.
find
(
token
);
if
(
it
==
listeners_
.
end
())
return
;
if
(
it
->
second
.
tokenClassicDht
)
dht_
->
cancelListen
(
h
,
it
->
second
.
tokenClassicDht
);
if
(
it
->
second
.
tokenProxyDht
and
dht_via_proxy_
)
dht_via_proxy_
->
cancelListen
(
h
,
it
->
second
.
tokenProxyDht
);
listeners_
.
erase
(
it
);
if
(
it
!=
listeners_
.
end
())
{
if
(
it
->
second
.
tokenClassicDht
)
dht_
->
cancelListen
(
h
,
it
->
second
.
tokenClassicDht
);
if
(
it
->
second
.
tokenProxyDht
and
dht_via_proxy_
)
dht_via_proxy_
->
cancelListen
(
h
,
it
->
second
.
tokenProxyDht
);
listeners_
.
erase
(
it
);
}
else
{
if
(
logger_
)
logger_
->
w
(
"[runner %p] cancelListen: unknown token %zu."
,
this
,
token
);
}
opEnded
();
});
#else
...
...
@@ -849,13 +861,18 @@ DhtRunner::cancelListen(InfoHash h, std::shared_future<size_t> ftoken)
ongoing_ops
++
;
#ifdef OPENDHT_PROXY_CLIENT
pending_ops
.
emplace
([
this
,
h
,
ftoken
=
std
::
move
(
ftoken
)](
SecureDht
&
)
{
auto
it
=
listeners_
.
find
(
ftoken
.
get
());
if
(
it
==
listeners_
.
end
())
return
;
if
(
it
->
second
.
tokenClassicDht
)
dht_
->
cancelListen
(
h
,
it
->
second
.
tokenClassicDht
);
if
(
it
->
second
.
tokenProxyDht
and
dht_via_proxy_
)
dht_via_proxy_
->
cancelListen
(
h
,
it
->
second
.
tokenProxyDht
);
listeners_
.
erase
(
it
);
auto
token
=
ftoken
.
get
();
auto
it
=
listeners_
.
find
(
token
);
if
(
it
!=
listeners_
.
end
())
{
if
(
it
->
second
.
tokenClassicDht
)
dht_
->
cancelListen
(
h
,
it
->
second
.
tokenClassicDht
);
if
(
it
->
second
.
tokenProxyDht
and
dht_via_proxy_
)
dht_via_proxy_
->
cancelListen
(
h
,
it
->
second
.
tokenProxyDht
);
listeners_
.
erase
(
it
);
}
else
{
if
(
logger_
)
logger_
->
w
(
"[runner %p] cancelListen: unknown token %zu."
,
this
,
token
);
}
opEnded
();
});
#else
...
...
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