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
201982b1
Commit
201982b1
authored
5 years ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
dhtrunner: don't count cancel as ops
parent
83f2b272
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/dhtrunner.cpp
+2
-11
2 additions, 11 deletions
src/dhtrunner.cpp
with
2 additions
and
11 deletions
src/dhtrunner.cpp
+
2
−
11
View file @
201982b1
...
...
@@ -231,7 +231,7 @@ DhtRunner::shutdown(ShutdownCallback cb) {
return
;
}
if
(
logger_
)
logger_
->
d
(
"[runner %p] state changed to Stopping
"
,
this
);
logger_
->
d
(
"[runner %p] state changed to Stopping
, %zu ongoing ops"
,
this
,
ongoing_ops
.
load
()
);
std
::
lock_guard
<
std
::
mutex
>
lck
(
storage_mtx
);
ongoing_ops
++
;
shutdownCallbacks_
.
emplace_back
(
std
::
move
(
cb
));
...
...
@@ -314,6 +314,7 @@ DhtRunner::join()
std
::
lock_guard
<
std
::
mutex
>
lck
(
storage_mtx
);
pending_ops
=
decltype
(
pending_ops
)();
pending_ops_prio
=
decltype
(
pending_ops_prio
)();
ongoing_ops
=
0
;
}
{
std
::
lock_guard
<
std
::
mutex
>
lck
(
dht_mtx
);
...
...
@@ -699,7 +700,6 @@ void
DhtRunner
::
cancelListen
(
InfoHash
h
,
size_t
token
)
{
std
::
lock_guard
<
std
::
mutex
>
lck
(
storage_mtx
);
ongoing_ops
++
;
#ifdef OPENDHT_PROXY_CLIENT
pending_ops
.
emplace
([
=
](
SecureDht
&
)
{
auto
it
=
listeners_
.
find
(
token
);
...
...
@@ -709,12 +709,10 @@ DhtRunner::cancelListen(InfoHash h, size_t token)
if
(
it
->
second
.
tokenProxyDht
and
dht_via_proxy_
)
dht_via_proxy_
->
cancelListen
(
h
,
it
->
second
.
tokenProxyDht
);
listeners_
.
erase
(
it
);
opEnded
();
});
#else
pending_ops
.
emplace
([
=
](
SecureDht
&
dht
)
{
dht
.
cancelListen
(
h
,
token
);
opEnded
();
});
#endif // OPENDHT_PROXY_CLIENT
cv
.
notify_all
();
...
...
@@ -724,7 +722,6 @@ void
DhtRunner
::
cancelListen
(
InfoHash
h
,
std
::
shared_future
<
size_t
>
ftoken
)
{
std
::
lock_guard
<
std
::
mutex
>
lck
(
storage_mtx
);
ongoing_ops
++
;
#ifdef OPENDHT_PROXY_CLIENT
pending_ops
.
emplace
([
=
](
SecureDht
&
)
{
auto
it
=
listeners_
.
find
(
ftoken
.
get
());
...
...
@@ -734,12 +731,10 @@ DhtRunner::cancelListen(InfoHash h, std::shared_future<size_t> ftoken)
if
(
it
->
second
.
tokenProxyDht
and
dht_via_proxy_
)
dht_via_proxy_
->
cancelListen
(
h
,
it
->
second
.
tokenProxyDht
);
listeners_
.
erase
(
it
);
opEnded
();
});
#else
pending_ops
.
emplace
([
=
](
SecureDht
&
dht
)
{
dht
.
cancelListen
(
h
,
ftoken
.
get
());
opEnded
();
});
#endif // OPENDHT_PROXY_CLIENT
cv
.
notify_all
();
...
...
@@ -788,10 +783,8 @@ void
DhtRunner
::
cancelPut
(
const
InfoHash
&
h
,
Value
::
Id
id
)
{
std
::
lock_guard
<
std
::
mutex
>
lck
(
storage_mtx
);
ongoing_ops
++
;
pending_ops
.
emplace
([
=
](
SecureDht
&
dht
)
{
dht
.
cancelPut
(
h
,
id
);
opEnded
();
});
cv
.
notify_all
();
}
...
...
@@ -800,10 +793,8 @@ void
DhtRunner
::
cancelPut
(
const
InfoHash
&
h
,
const
std
::
shared_ptr
<
Value
>&
value
)
{
std
::
lock_guard
<
std
::
mutex
>
lck
(
storage_mtx
);
ongoing_ops
++
;
pending_ops
.
emplace
([
=
](
SecureDht
&
dht
)
{
dht
.
cancelPut
(
h
,
value
->
id
);
opEnded
();
});
cv
.
notify_all
();
}
...
...
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