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
b9f02f22
Commit
b9f02f22
authored
Jan 18, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/upnp: don't use WorkQueue for _ADVERTISEMENT_BYEBYE
Remove the ContentDirectoryDescriptor right away. Reduces bloat.
parent
b6356104
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
36 deletions
+30
-36
Discovery.cxx
src/db/upnp/Discovery.cxx
+28
-33
Discovery.hxx
src/db/upnp/Discovery.hxx
+2
-3
No files found.
src/db/upnp/Discovery.cxx
View file @
b9f02f22
...
@@ -62,40 +62,33 @@ UPnPDeviceDirectory::discoExplorer()
...
@@ -62,40 +62,33 @@ UPnPDeviceDirectory::discoExplorer()
}
}
const
ScopeLock
protect
(
mutex
);
const
ScopeLock
protect
(
mutex
);
if
(
!
tsk
->
alive
)
{
// Device signals its existence and well-being. Perform the
// Device signals it is going off.
// UPnP "description" phase by downloading and decoding the
auto
it
=
directories
.
find
(
tsk
->
deviceId
);
// description document.
if
(
it
!=
directories
.
end
())
{
char
*
buf
;
directories
.
erase
(
it
);
// LINE_SIZE is defined by libupnp's upnp.h...
}
char
contentType
[
LINE_SIZE
];
}
else
{
int
code
=
UpnpDownloadUrlItem
(
tsk
->
url
.
c_str
(),
&
buf
,
contentType
);
// Device signals its existence and well-being. Perform the
if
(
code
!=
UPNP_E_SUCCESS
)
{
// UPnP "description" phase by downloading and decoding the
continue
;
// description document.
}
char
*
buf
;
std
::
string
sdesc
(
buf
);
// LINE_SIZE is defined by libupnp's upnp.h...
char
contentType
[
LINE_SIZE
];
int
code
=
UpnpDownloadUrlItem
(
tsk
->
url
.
c_str
(),
&
buf
,
contentType
);
if
(
code
!=
UPNP_E_SUCCESS
)
{
continue
;
}
std
::
string
sdesc
(
buf
);
// Update or insert the device
// Update or insert the device
ContentDirectoryDescriptor
d
(
tsk
->
url
,
sdesc
,
ContentDirectoryDescriptor
d
(
tsk
->
url
,
sdesc
,
time
(
0
),
tsk
->
expires
);
time
(
0
),
tsk
->
expires
);
if
(
!
d
.
device
.
ok
)
{
if
(
!
d
.
device
.
ok
)
{
continue
;
continue
;
}
}
#if defined(__clang__) || GCC_CHECK_VERSION(4,8)
#if defined(__clang__) || GCC_CHECK_VERSION(4,8)
auto
e
=
directories
.
emplace
(
tsk
->
deviceId
,
d
);
auto
e
=
directories
.
emplace
(
tsk
->
deviceId
,
d
);
#else
#else
auto
e
=
directories
.
insert
(
std
::
make_pair
(
tsk
->
deviceId
,
d
));
auto
e
=
directories
.
insert
(
std
::
make_pair
(
tsk
->
deviceId
,
d
));
#endif
#endif
if
(
!
e
.
second
)
if
(
!
e
.
second
)
e
.
first
->
second
=
d
;
e
.
first
->
second
=
d
;
}
delete
tsk
;
delete
tsk
;
}
}
}
}
...
@@ -113,7 +106,7 @@ UPnPDeviceDirectory::OnAlive(Upnp_Discovery *disco)
...
@@ -113,7 +106,7 @@ UPnPDeviceDirectory::OnAlive(Upnp_Discovery *disco)
{
{
if
(
isMSDevice
(
disco
->
DeviceType
)
||
if
(
isMSDevice
(
disco
->
DeviceType
)
||
isCDService
(
disco
->
ServiceType
))
{
isCDService
(
disco
->
ServiceType
))
{
DiscoveredTask
*
tp
=
new
DiscoveredTask
(
1
,
disco
);
DiscoveredTask
*
tp
=
new
DiscoveredTask
(
disco
);
if
(
discoveredQueue
.
put
(
tp
))
if
(
discoveredQueue
.
put
(
tp
))
return
UPNP_E_FINISH
;
return
UPNP_E_FINISH
;
}
}
...
@@ -127,9 +120,11 @@ UPnPDeviceDirectory::OnByeBye(Upnp_Discovery *disco)
...
@@ -127,9 +120,11 @@ UPnPDeviceDirectory::OnByeBye(Upnp_Discovery *disco)
if
(
isMSDevice
(
disco
->
DeviceType
)
||
if
(
isMSDevice
(
disco
->
DeviceType
)
||
isCDService
(
disco
->
ServiceType
))
{
isCDService
(
disco
->
ServiceType
))
{
DiscoveredTask
*
tp
=
new
DiscoveredTask
(
0
,
disco
);
// Device signals it is going off.
if
(
discoveredQueue
.
put
(
tp
))
const
ScopeLock
protect
(
mutex
);
return
UPNP_E_FINISH
;
auto
it
=
directories
.
find
(
disco
->
DeviceId
);
if
(
it
!=
directories
.
end
())
directories
.
erase
(
it
);
}
}
return
UPNP_E_SUCCESS
;
return
UPNP_E_SUCCESS
;
...
...
src/db/upnp/Discovery.hxx
View file @
b9f02f22
...
@@ -49,13 +49,12 @@ class UPnPDeviceDirectory {
...
@@ -49,13 +49,12 @@ class UPnPDeviceDirectory {
* discovery thread.
* discovery thread.
*/
*/
struct
DiscoveredTask
{
struct
DiscoveredTask
{
bool
alive
;
std
::
string
url
;
std
::
string
url
;
std
::
string
deviceId
;
std
::
string
deviceId
;
int
expires
;
// Seconds valid
int
expires
;
// Seconds valid
DiscoveredTask
(
bool
_alive
,
const
Upnp_Discovery
*
disco
)
DiscoveredTask
(
const
Upnp_Discovery
*
disco
)
:
alive
(
_alive
),
url
(
disco
->
Location
),
:
url
(
disco
->
Location
),
deviceId
(
disco
->
DeviceId
),
deviceId
(
disco
->
DeviceId
),
expires
(
disco
->
Expires
)
{}
expires
(
disco
->
Expires
)
{}
};
};
...
...
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