1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

Removed some unnecessary locks from SVDRPClientHandler

This commit is contained in:
Klaus Schmidinger 2022-11-19 15:47:03 +01:00
parent 2bf0967a47
commit b14ed38a48
2 changed files with 9 additions and 18 deletions

View File

@ -9780,7 +9780,7 @@ Video Disk Recorder Revision History
out by Onur Sentürk). out by Onur Sentürk).
- Official release. - Official release.
2022-11-14: 2022-11-19:
- Added UPDATE-2.6.0, which was missing in the official 2.6.0 release. - Added UPDATE-2.6.0, which was missing in the official 2.6.0 release.
- Fixed unexpected calls of the '-r' script when a recording is interrupted and - Fixed unexpected calls of the '-r' script when a recording is interrupted and
@ -9796,3 +9796,4 @@ Video Disk Recorder Revision History
recording is being replayed. recording is being replayed.
- Added a warning if an attempt is made to obtain a write lock twice from the same thread. - Added a warning if an attempt is made to obtain a write lock twice from the same thread.
- Fixed default values for DVB-T (thanks to Winfried Köhler and Jose Angel). - Fixed default values for DVB-T (thanks to Winfried Köhler and Jose Angel).
- Removed some unnecessary locks from SVDRPClientHandler.

24
svdrp.c
View File

@ -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 5.3 2021/01/14 10:29:05 kls Exp $ * $Id: svdrp.c 5.4 2022/11/19 15:47:03 kls Exp $
*/ */
#include "svdrp.h" #include "svdrp.h"
@ -605,8 +605,6 @@ 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); bool GetServerNames(cStringList *ServerNames);
@ -2382,10 +2380,10 @@ void cSVDRPServer::CmdPOLL(const char *Option)
if (SVDRPClientHandler) { if (SVDRPClientHandler) {
if (ListName) { if (ListName) {
if (strcasecmp(ListName, "timers") == 0) { if (strcasecmp(ListName, "timers") == 0) {
if (SVDRPClientHandler->TriggerFetchingTimers(RemoteName)) if (SVDRPClientHandler->TriggerFetchingTimers(RemoteName))
Reply(250, "OK"); Reply(250, "OK");
else else
Reply(501, "No connection to \"%s\"", RemoteName); Reply(501, "No connection to \"%s\"", RemoteName);
} }
else else
Reply(501, "Unknown list name: \"%s\"", ListName); Reply(501, "Unknown list name: \"%s\"", ListName);
@ -2796,11 +2794,8 @@ bool GetSVDRPServerNames(cStringList *ServerNames)
{ {
bool Result = false; bool Result = false;
cMutexLock MutexLock(&SVDRPHandlerMutex); cMutexLock MutexLock(&SVDRPHandlerMutex);
if (SVDRPClientHandler) { if (SVDRPClientHandler)
SVDRPClientHandler->Lock();
Result = SVDRPClientHandler->GetServerNames(ServerNames); Result = SVDRPClientHandler->GetServerNames(ServerNames);
SVDRPClientHandler->Unlock();
}
return Result; return Result;
} }
@ -2808,11 +2803,8 @@ bool ExecSVDRPCommand(const char *ServerName, const char *Command, cStringList *
{ {
bool Result = false; bool Result = false;
cMutexLock MutexLock(&SVDRPHandlerMutex); cMutexLock MutexLock(&SVDRPHandlerMutex);
if (SVDRPClientHandler) { if (SVDRPClientHandler)
SVDRPClientHandler->Lock();
Result = SVDRPClientHandler->Execute(ServerName, Command, Response); Result = SVDRPClientHandler->Execute(ServerName, Command, Response);
SVDRPClientHandler->Unlock();
}
return Result; return Result;
} }
@ -2821,11 +2813,9 @@ 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();
} }
} }