mirror of
https://github.com/VDR4Arch/vdr.git
synced 2023-10-10 13:36:52 +02:00
Improved locking
This commit is contained in:
parent
dd6c37c13d
commit
d5db0c5ba7
26
svdrp.c
26
svdrp.c
@ -10,7 +10,7 @@
|
|||||||
* and interact with the Video Disk Recorder - or write a full featured
|
* and interact with the Video Disk Recorder - or write a full featured
|
||||||
* graphical interface that sits on top of an SVDRP connection.
|
* graphical interface that sits on top of an SVDRP connection.
|
||||||
*
|
*
|
||||||
* $Id: svdrp.c 4.29 2018/02/25 13:44:54 kls Exp $
|
* $Id: svdrp.c 4.30 2018/02/26 15:42:15 kls Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "svdrp.h"
|
#include "svdrp.h"
|
||||||
@ -571,6 +571,8 @@ protected:
|
|||||||
public:
|
public:
|
||||||
cSVDRPClientHandler(int TcpPort, int UdpPort);
|
cSVDRPClientHandler(int TcpPort, int UdpPort);
|
||||||
virtual ~cSVDRPClientHandler();
|
virtual ~cSVDRPClientHandler();
|
||||||
|
void Lock(void) { mutex.Lock(); }
|
||||||
|
void Unlock(void) { mutex.Unlock(); }
|
||||||
void AddClient(cSVDRPServerParams &ServerParams, const char *IpAddress);
|
void AddClient(cSVDRPServerParams &ServerParams, const char *IpAddress);
|
||||||
bool Execute(const char *ServerName, const char *Command, cStringList *Response = NULL);
|
bool Execute(const char *ServerName, const char *Command, cStringList *Response = NULL);
|
||||||
bool GetServerNames(cStringList *ServerNames, eSvdrpFetchFlags FetchFlags = sffNone);
|
bool GetServerNames(cStringList *ServerNames, eSvdrpFetchFlags FetchFlags = sffNone);
|
||||||
@ -2725,18 +2727,26 @@ void StopSVDRPHandler(void)
|
|||||||
|
|
||||||
bool GetSVDRPServerNames(cStringList *ServerNames, eSvdrpFetchFlags FetchFlag)
|
bool GetSVDRPServerNames(cStringList *ServerNames, eSvdrpFetchFlags FetchFlag)
|
||||||
{
|
{
|
||||||
|
bool Result = false;
|
||||||
cMutexLock MutexLock(&SVDRPHandlerMutex);
|
cMutexLock MutexLock(&SVDRPHandlerMutex);
|
||||||
if (SVDRPClientHandler)
|
if (SVDRPClientHandler) {
|
||||||
return SVDRPClientHandler->GetServerNames(ServerNames, FetchFlag);
|
SVDRPClientHandler->Lock();
|
||||||
return false;
|
Result = SVDRPClientHandler->GetServerNames(ServerNames, FetchFlag);
|
||||||
|
SVDRPClientHandler->Unlock();
|
||||||
|
}
|
||||||
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ExecSVDRPCommand(const char *ServerName, const char *Command, cStringList *Response)
|
bool ExecSVDRPCommand(const char *ServerName, const char *Command, cStringList *Response)
|
||||||
{
|
{
|
||||||
|
bool Result = false;
|
||||||
cMutexLock MutexLock(&SVDRPHandlerMutex);
|
cMutexLock MutexLock(&SVDRPHandlerMutex);
|
||||||
if (SVDRPClientHandler)
|
if (SVDRPClientHandler) {
|
||||||
return SVDRPClientHandler->Execute(ServerName, Command, Response);
|
SVDRPClientHandler->Lock();
|
||||||
return false;
|
Result = SVDRPClientHandler->Execute(ServerName, Command, Response);
|
||||||
|
SVDRPClientHandler->Unlock();
|
||||||
|
}
|
||||||
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BroadcastSVDRPCommand(const char *Command)
|
void BroadcastSVDRPCommand(const char *Command)
|
||||||
@ -2744,9 +2754,11 @@ void BroadcastSVDRPCommand(const char *Command)
|
|||||||
cMutexLock MutexLock(&SVDRPHandlerMutex);
|
cMutexLock MutexLock(&SVDRPHandlerMutex);
|
||||||
cStringList ServerNames;
|
cStringList ServerNames;
|
||||||
if (SVDRPClientHandler) {
|
if (SVDRPClientHandler) {
|
||||||
|
SVDRPClientHandler->Lock();
|
||||||
if (SVDRPClientHandler->GetServerNames(&ServerNames)) {
|
if (SVDRPClientHandler->GetServerNames(&ServerNames)) {
|
||||||
for (int i = 0; i < ServerNames.Size(); i++)
|
for (int i = 0; i < ServerNames.Size(); i++)
|
||||||
ExecSVDRPCommand(ServerNames[i], Command);
|
ExecSVDRPCommand(ServerNames[i], Command);
|
||||||
}
|
}
|
||||||
|
SVDRPClientHandler->Unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user