From b14ed38a48fea93a618436a667154c2c9fb6bfbf Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sat, 19 Nov 2022 15:47:03 +0100 Subject: [PATCH] Removed some unnecessary locks from SVDRPClientHandler --- HISTORY | 3 ++- svdrp.c | 24 +++++++----------------- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/HISTORY b/HISTORY index 15859d9f..9789e2f3 100644 --- a/HISTORY +++ b/HISTORY @@ -9780,7 +9780,7 @@ Video Disk Recorder Revision History out by Onur Sentürk). - Official release. -2022-11-14: +2022-11-19: - 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 @@ -9796,3 +9796,4 @@ Video Disk Recorder Revision History recording is being replayed. - 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). +- Removed some unnecessary locks from SVDRPClientHandler. diff --git a/svdrp.c b/svdrp.c index b993577f..10e44389 100644 --- a/svdrp.c +++ b/svdrp.c @@ -10,7 +10,7 @@ * and interact with the Video Disk Recorder - or write a full featured * 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" @@ -605,8 +605,6 @@ protected: public: cSVDRPClientHandler(int TcpPort, int UdpPort); virtual ~cSVDRPClientHandler(); - void Lock(void) { mutex.Lock(); } - void Unlock(void) { mutex.Unlock(); } void AddClient(cSVDRPServerParams &ServerParams, const char *IpAddress); bool Execute(const char *ServerName, const char *Command, cStringList *Response = NULL); bool GetServerNames(cStringList *ServerNames); @@ -2382,10 +2380,10 @@ void cSVDRPServer::CmdPOLL(const char *Option) if (SVDRPClientHandler) { if (ListName) { if (strcasecmp(ListName, "timers") == 0) { - if (SVDRPClientHandler->TriggerFetchingTimers(RemoteName)) - Reply(250, "OK"); - else - Reply(501, "No connection to \"%s\"", RemoteName); + if (SVDRPClientHandler->TriggerFetchingTimers(RemoteName)) + Reply(250, "OK"); + else + Reply(501, "No connection to \"%s\"", RemoteName); } else Reply(501, "Unknown list name: \"%s\"", ListName); @@ -2796,11 +2794,8 @@ bool GetSVDRPServerNames(cStringList *ServerNames) { bool Result = false; cMutexLock MutexLock(&SVDRPHandlerMutex); - if (SVDRPClientHandler) { - SVDRPClientHandler->Lock(); + if (SVDRPClientHandler) Result = SVDRPClientHandler->GetServerNames(ServerNames); - SVDRPClientHandler->Unlock(); - } return Result; } @@ -2808,11 +2803,8 @@ bool ExecSVDRPCommand(const char *ServerName, const char *Command, cStringList * { bool Result = false; cMutexLock MutexLock(&SVDRPHandlerMutex); - if (SVDRPClientHandler) { - SVDRPClientHandler->Lock(); + if (SVDRPClientHandler) Result = SVDRPClientHandler->Execute(ServerName, Command, Response); - SVDRPClientHandler->Unlock(); - } return Result; } @@ -2821,11 +2813,9 @@ void BroadcastSVDRPCommand(const char *Command) cMutexLock MutexLock(&SVDRPHandlerMutex); cStringList ServerNames; if (SVDRPClientHandler) { - SVDRPClientHandler->Lock(); if (SVDRPClientHandler->GetServerNames(&ServerNames)) { for (int i = 0; i < ServerNames.Size(); i++) ExecSVDRPCommand(ServerNames[i], Command); } - SVDRPClientHandler->Unlock(); } }