Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
e5ee3579
Commit
e5ee3579
authored
Aug 25, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib/upnp/Discovery: use DeferredMonitor instead of BlockingCall()
parent
8aef518c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
13 deletions
+15
-13
Discovery.cxx
src/lib/upnp/Discovery.cxx
+6
-11
Discovery.hxx
src/lib/upnp/Discovery.hxx
+9
-2
No files found.
src/lib/upnp/Discovery.cxx
View file @
e5ee3579
...
@@ -22,7 +22,6 @@
...
@@ -22,7 +22,6 @@
#include "ContentDirectoryService.hxx"
#include "ContentDirectoryService.hxx"
#include "Log.hxx"
#include "Log.hxx"
#include "lib/curl/Global.hxx"
#include "lib/curl/Global.hxx"
#include "event/Call.hxx"
#include "util/DeleteDisposer.hxx"
#include "util/DeleteDisposer.hxx"
#include "util/ScopeExit.hxx"
#include "util/ScopeExit.hxx"
#include "util/RuntimeError.hxx"
#include "util/RuntimeError.hxx"
...
@@ -34,7 +33,7 @@
...
@@ -34,7 +33,7 @@
UPnPDeviceDirectory
::
Downloader
::
Downloader
(
UPnPDeviceDirectory
&
_parent
,
UPnPDeviceDirectory
::
Downloader
::
Downloader
(
UPnPDeviceDirectory
&
_parent
,
const
Upnp_Discovery
&
disco
)
const
Upnp_Discovery
&
disco
)
:
parent
(
_parent
),
:
DeferredMonitor
(
_parent
.
GetEventLoop
()),
parent
(
_parent
),
id
(
disco
.
DeviceId
),
url
(
disco
.
Location
),
id
(
disco
.
DeviceId
),
url
(
disco
.
Location
),
expires
(
std
::
chrono
::
seconds
(
disco
.
Expires
)),
expires
(
std
::
chrono
::
seconds
(
disco
.
Expires
)),
request
(
*
parent
.
curl
,
url
.
c_str
(),
*
this
)
request
(
*
parent
.
curl
,
url
.
c_str
(),
*
this
)
...
@@ -43,20 +42,16 @@ UPnPDeviceDirectory::Downloader::Downloader(UPnPDeviceDirectory &_parent,
...
@@ -43,20 +42,16 @@ UPnPDeviceDirectory::Downloader::Downloader(UPnPDeviceDirectory &_parent,
}
}
void
void
UPnPDeviceDirectory
::
Downloader
::
Start
()
UPnPDeviceDirectory
::
Downloader
::
Destroy
()
{
{
auto
&
event_loop
=
parent
.
GetEventLoop
();
parent
.
downloaders
.
erase_and_dispose
(
parent
.
downloaders
.
iterator_to
(
*
this
),
DeleteDisposer
());
BlockingCall
(
event_loop
,
[
this
](){
request
.
Start
();
});
}
}
void
void
UPnPDeviceDirectory
::
Downloader
::
Destroy
()
UPnPDeviceDirectory
::
Downloader
::
RunDeferred
()
{
{
parent
.
downloaders
.
erase_and_dispose
(
parent
.
downloaders
.
iterator_to
(
*
this
),
request
.
Start
();
DeleteDisposer
());
}
}
void
void
...
...
src/lib/upnp/Discovery.hxx
View file @
e5ee3579
...
@@ -26,6 +26,7 @@
...
@@ -26,6 +26,7 @@
#include "lib/curl/Handler.hxx"
#include "lib/curl/Handler.hxx"
#include "lib/curl/Request.hxx"
#include "lib/curl/Request.hxx"
#include "thread/Mutex.hxx"
#include "thread/Mutex.hxx"
#include "event/DeferredMonitor.hxx"
#include "Compiler.h"
#include "Compiler.h"
#include <upnp/upnp.h>
#include <upnp/upnp.h>
...
@@ -83,7 +84,7 @@ class UPnPDeviceDirectory final : UpnpCallback {
...
@@ -83,7 +84,7 @@ class UPnPDeviceDirectory final : UpnpCallback {
class
Downloader
final
class
Downloader
final
:
public
boost
::
intrusive
::
list_base_hook
<
boost
::
intrusive
::
link_mode
<
boost
::
intrusive
::
normal_link
>>
,
:
public
boost
::
intrusive
::
list_base_hook
<
boost
::
intrusive
::
link_mode
<
boost
::
intrusive
::
normal_link
>>
,
CurlResponseHandler
{
DeferredMonitor
,
CurlResponseHandler
{
UPnPDeviceDirectory
&
parent
;
UPnPDeviceDirectory
&
parent
;
...
@@ -99,10 +100,16 @@ class UPnPDeviceDirectory final : UpnpCallback {
...
@@ -99,10 +100,16 @@ class UPnPDeviceDirectory final : UpnpCallback {
Downloader
(
UPnPDeviceDirectory
&
_parent
,
Downloader
(
UPnPDeviceDirectory
&
_parent
,
const
Upnp_Discovery
&
disco
);
const
Upnp_Discovery
&
disco
);
void
Start
();
void
Start
()
{
DeferredMonitor
::
Schedule
();
}
void
Destroy
();
void
Destroy
();
private
:
private
:
/* virtual methods from DeferredMonitor */
void
RunDeferred
()
override
;
/* virtual methods from CurlResponseHandler */
/* virtual methods from CurlResponseHandler */
void
OnHeaders
(
unsigned
status
,
void
OnHeaders
(
unsigned
status
,
std
::
multimap
<
std
::
string
,
std
::
string
>
&&
headers
)
override
;
std
::
multimap
<
std
::
string
,
std
::
string
>
&&
headers
)
override
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment