Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
dhtnet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
dhtnet
Commits
d1e018ca
Commit
d1e018ca
authored
1 year ago
by
Sébastien Blin
Browse files
Options
Downloads
Patches
Plain Diff
natpmp: pass shared pointer to timer to avoid crash
Change-Id: I1fbf84f8fb10b14390abb951b8ed312716047936
parent
c453ca7f
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/upnp/protocol/natpmp/nat_pmp.cpp
+5
-3
5 additions, 3 deletions
src/upnp/protocol/natpmp/nat_pmp.cpp
src/upnp/protocol/natpmp/nat_pmp.h
+7
-0
7 additions, 0 deletions
src/upnp/protocol/natpmp/nat_pmp.h
with
12 additions
and
3 deletions
src/upnp/protocol/natpmp/nat_pmp.cpp
+
5
−
3
View file @
d1e018ca
...
...
@@ -186,9 +186,11 @@ NatPmp::searchForIgd()
// Cancel the current timer (if any) and re-schedule.
searchForIgdTimer_
.
expires_after
(
NATPMP_SEARCH_RETRY_UNIT
*
igdSearchCounter_
);
searchForIgdTimer_
.
async_wait
([
this
](
const
asio
::
error_code
&
ec
)
{
if
(
!
ec
)
searchForIgd
();
searchForIgdTimer_
.
async_wait
([
w
=
weak
()](
const
asio
::
error_code
&
ec
)
{
if
(
!
ec
)
{
if
(
auto
shared
=
w
.
lock
())
shared
->
searchForIgd
();
}
});
}
else
{
if
(
logger_
)
logger_
->
warn
(
"NAT-PMP: Setup failed after {} trials. NAT-PMP will be disabled!"
,
...
...
This diff is collapsed.
Click to expand it.
src/upnp/protocol/natpmp/nat_pmp.h
+
7
−
0
View file @
d1e018ca
...
...
@@ -149,6 +149,13 @@ private:
// Shutdown synchronization
bool
shutdownComplete_
{
false
};
// Asio :(
// https://stackoverflow.com/questions/35507956/is-it-safe-to-destroy-boostasio-timer-from-its-handler-or-handler-dtor
std
::
weak_ptr
<
NatPmp
>
weak
()
{
return
std
::
static_pointer_cast
<
NatPmp
>
(
shared_from_this
());
}
};
}
// namespace upnp
...
...
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