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
91fd4b65
Commit
91fd4b65
authored
1 year ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
upnp: stop asio context out of the loop
Change-Id: Iaee6527de1a599d6c79ef494637fb968a3035bbb
parent
027af2a3
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/upnp/upnp_context.cpp
+15
-17
15 additions, 17 deletions
src/upnp/upnp_context.cpp
with
15 additions
and
17 deletions
src/upnp/upnp_context.cpp
+
15
−
17
View file @
91fd4b65
...
...
@@ -45,9 +45,9 @@ constexpr static uint16_t UPNP_UDP_PORT_MAX {UPNP_UDP_PORT_MIN + 5000};
UPnPContext
::
UPnPContext
(
const
std
::
shared_ptr
<
asio
::
io_context
>&
ioContext
,
const
std
::
shared_ptr
<
dht
::
log
::
Logger
>&
logger
)
:
ctx
(
createIoContext
(
ioContext
,
logger
))
,
logger_
(
logger
)
,
mappingListUpdateTimer_
(
*
ctx
)
,
connectivityChangedTimer_
(
*
ctx
)
,
logger_
(
logger
)
{
if
(
logger_
)
logger_
->
debug
(
"Creating UPnPContext instance [{}]"
,
fmt
::
ptr
(
this
));
...
...
@@ -88,22 +88,13 @@ UPnPContext::shutdown(std::condition_variable& cv)
proto
->
terminate
();
}
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
mappingMutex_
);
mappingList_
->
clear
();
mappingListUpdateTimer_
.
cancel
();
controllerList_
.
clear
();
protocolList_
.
clear
();
shutdownComplete_
=
true
;
cv
.
notify_one
();
}
if
(
ioContextRunner_
)
{
if
(
logger_
)
logger_
->
debug
(
"UPnPContext: stopping io_context thread"
);
ctx
->
stop
();
ioContextRunner_
->
join
();
ioContextRunner_
.
reset
();
}
std
::
lock_guard
<
std
::
mutex
>
lock
(
mappingMutex_
);
mappingList_
->
clear
();
mappingListUpdateTimer_
.
cancel
();
controllerList_
.
clear
();
protocolList_
.
clear
();
shutdownComplete_
=
true
;
cv
.
notify_one
();
}
void
...
...
@@ -121,6 +112,13 @@ UPnPContext::shutdown()
}
else
{
if
(
logger_
)
logger_
->
error
(
"Shutdown timed-out"
);
}
if
(
ioContextRunner_
)
{
if
(
logger_
)
logger_
->
debug
(
"UPnPContext: stopping io_context thread"
);
ctx
->
stop
();
ioContextRunner_
->
join
();
ioContextRunner_
.
reset
();
}
}
UPnPContext
::~
UPnPContext
()
...
...
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