lib/upnp/ClientInit: use class ScopeLock
This commit is contained in:
parent
8610eb84c6
commit
6e2ad6860f
@ -65,9 +65,11 @@ UpnpClientGlobalInit(UpnpClient_Handle &handle, Error &error)
|
|||||||
if (!UpnpGlobalInit(error))
|
if (!UpnpGlobalInit(error))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
upnp_client_init_mutex.lock();
|
bool success;
|
||||||
bool success = upnp_client_ref > 0 || DoInit(error);
|
{
|
||||||
upnp_client_init_mutex.unlock();
|
const ScopeLock protect(upnp_client_init_mutex);
|
||||||
|
success = upnp_client_ref > 0 || DoInit(error);
|
||||||
|
}
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
++upnp_client_ref;
|
++upnp_client_ref;
|
||||||
@ -81,13 +83,13 @@ UpnpClientGlobalInit(UpnpClient_Handle &handle, Error &error)
|
|||||||
void
|
void
|
||||||
UpnpClientGlobalFinish()
|
UpnpClientGlobalFinish()
|
||||||
{
|
{
|
||||||
upnp_client_init_mutex.lock();
|
{
|
||||||
|
const ScopeLock protect(upnp_client_init_mutex);
|
||||||
|
|
||||||
assert(upnp_client_ref > 0);
|
assert(upnp_client_ref > 0);
|
||||||
if (--upnp_client_ref == 0)
|
if (--upnp_client_ref == 0)
|
||||||
UpnpUnRegisterClient(upnp_client_handle);
|
UpnpUnRegisterClient(upnp_client_handle);
|
||||||
|
}
|
||||||
upnp_client_init_mutex.unlock();
|
|
||||||
|
|
||||||
UpnpGlobalFinish();
|
UpnpGlobalFinish();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user