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
c9af358e
Commit
c9af358e
authored
Jan 23, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/upnp/Discovery: move code to LockAdd(), LockRemove()
parent
3afcfe33
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
9 deletions
+21
-9
Discovery.cxx
src/db/upnp/Discovery.cxx
+18
-9
Discovery.hxx
src/db/upnp/Discovery.hxx
+3
-0
No files found.
src/db/upnp/Discovery.cxx
View file @
c9af358e
...
...
@@ -54,6 +54,22 @@ isMSDevice(const char *st)
}
inline
void
UPnPDeviceDirectory
::
LockAdd
(
std
::
string
&&
id
,
ContentDirectoryDescriptor
&&
d
)
{
const
ScopeLock
protect
(
mutex
);
directories
[
std
::
move
(
id
)]
=
std
::
move
(
d
);
}
inline
void
UPnPDeviceDirectory
::
LockRemove
(
const
std
::
string
&
id
)
{
const
ScopeLock
protect
(
mutex
);
auto
i
=
directories
.
find
(
id
);
if
(
i
!=
directories
.
end
())
directories
.
erase
(
i
);
}
inline
void
UPnPDeviceDirectory
::
discoExplorer
()
{
for
(;;)
{
...
...
@@ -88,10 +104,7 @@ UPnPDeviceDirectory::discoExplorer()
}
}
mutex
.
lock
();
directories
[
std
::
move
(
tsk
->
deviceId
)]
=
std
::
move
(
d
);
mutex
.
unlock
();
LockAdd
(
std
::
move
(
tsk
->
deviceId
),
std
::
move
(
d
));
delete
tsk
;
}
}
...
...
@@ -120,14 +133,10 @@ UPnPDeviceDirectory::OnAlive(Upnp_Discovery *disco)
inline
int
UPnPDeviceDirectory
::
OnByeBye
(
Upnp_Discovery
*
disco
)
{
if
(
isMSDevice
(
disco
->
DeviceType
)
||
isCDService
(
disco
->
ServiceType
))
{
// Device signals it is going off.
const
ScopeLock
protect
(
mutex
);
auto
it
=
directories
.
find
(
disco
->
DeviceId
);
if
(
it
!=
directories
.
end
())
directories
.
erase
(
it
);
LockRemove
(
disco
->
DeviceId
);
}
return
UPNP_E_SUCCESS
;
...
...
src/db/upnp/Discovery.hxx
View file @
c9af358e
...
...
@@ -129,6 +129,9 @@ private:
*/
bool
expireDevices
(
Error
&
error
);
void
LockAdd
(
std
::
string
&&
id
,
ContentDirectoryDescriptor
&&
d
);
void
LockRemove
(
const
std
::
string
&
id
);
/**
* Worker routine for the discovery queue. Get messages about
* devices appearing and disappearing, and update the
...
...
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