If an SVDRP peer connection is lost, the connection in the opposite direction is now also closed

This commit is contained in:
Klaus Schmidinger
2025-07-21 08:39:20 +02:00
parent 49cc3adfba
commit 02951d4136
3 changed files with 21 additions and 2 deletions

View File

@@ -2605,6 +2605,8 @@ Markus Ehrnsperger <markus.ehrnsperger@googlemail.com>
parameters of a previous call to cTimer::Matches() parameters of a previous call to cTimer::Matches()
for fixing the stop time of repeating timers in case of DST change for fixing the stop time of repeating timers in case of DST change
for suggesting to add cTimer::VpsTime() for suggesting to add cTimer::VpsTime()
for reporting that if an SVDRP peer connection is lost, the connection in the opposite
direction needs to be closed
Werner Färber <w.faerber@gmx.de> Werner Färber <w.faerber@gmx.de>
for reporting a bug in handling the cPluginManager::Active() result when pressing for reporting a bug in handling the cPluginManager::Active() result when pressing

View File

@@ -10170,3 +10170,5 @@ Video Disk Recorder Revision History
Friedrichs). Friedrichs).
- Added cTimer::VpsTime() (suggested by Markus Ehrnsperger). - Added cTimer::VpsTime() (suggested by Markus Ehrnsperger).
- Now sending the SVDRP discover broadcast once per minute, to re-establish lost connections. - Now sending the SVDRP discover broadcast once per minute, to re-establish lost connections.
- If an SVDRP peer connection is lost, the connection in the opposite direction is now also
closed (reported by Markus Ehrnsperger).

19
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.12 2025/07/21 08:26:31 kls Exp $ * $Id: svdrp.c 5.13 2025/07/21 08:39:20 kls Exp $
*/ */
#include "svdrp.h" #include "svdrp.h"
@@ -324,10 +324,10 @@ private:
int fetchFlags; int fetchFlags;
bool connected; bool connected;
bool Send(const char *Command); bool Send(const char *Command);
void Close(void);
public: public:
cSVDRPClient(const char *Address, int Port, const char *ServerName, int Timeout); cSVDRPClient(const char *Address, int Port, const char *ServerName, int Timeout);
~cSVDRPClient(); ~cSVDRPClient();
void Close(void);
const char *ServerName(void) const { return serverName; } const char *ServerName(void) const { return serverName; }
const char *Connection(void) const { return serverIpAddress.Connection(); } const char *Connection(void) const { return serverIpAddress.Connection(); }
bool HasAddress(const char *Address, int Port) const; bool HasAddress(const char *Address, int Port) const;
@@ -465,6 +465,7 @@ bool cSVDRPClient::Process(cStringList *Response)
} }
else if (Timeout.TimedOut()) { else if (Timeout.TimedOut()) {
esyslog("SVDRP %s < %s timeout while waiting for response from '%s'", Setup.SVDRPHostName, serverIpAddress.Connection(), *serverName); esyslog("SVDRP %s < %s timeout while waiting for response from '%s'", Setup.SVDRPHostName, serverIpAddress.Connection(), *serverName);
Close();
return false; return false;
} }
else if (!Response && numChars == 0) else if (!Response && numChars == 0)
@@ -603,6 +604,7 @@ public:
cSVDRPClientHandler(int TcpPort, int UdpPort); cSVDRPClientHandler(int TcpPort, int UdpPort);
virtual ~cSVDRPClientHandler() override; virtual ~cSVDRPClientHandler() override;
void AddClient(cSVDRPServerParams &ServerParams, const char *IpAddress); void AddClient(cSVDRPServerParams &ServerParams, const char *IpAddress);
void CloseClient(const char *ServerName);
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);
bool TriggerFetchingTimers(const char *ServerName); bool TriggerFetchingTimers(const char *ServerName);
@@ -696,6 +698,17 @@ void cSVDRPClientHandler::AddClient(cSVDRPServerParams &ServerParams, const char
clientConnections.Append(new cSVDRPClient(IpAddress, ServerParams.Port(), ServerParams.Name(), ServerParams.Timeout())); clientConnections.Append(new cSVDRPClient(IpAddress, ServerParams.Port(), ServerParams.Name(), ServerParams.Timeout()));
} }
void cSVDRPClientHandler::CloseClient(const char *ServerName)
{
cMutexLock MutexLock(&mutex);
for (int i = 0; i < clientConnections.Size(); i++) {
if (strcmp(clientConnections[i]->ServerName(), ServerName) == 0) {
clientConnections[i]->Close();
break;
}
}
}
void cSVDRPClientHandler::HandleClientConnection(void) void cSVDRPClientHandler::HandleClientConnection(void)
{ {
cString NewDiscover = udpSocket.Discover(); cString NewDiscover = udpSocket.Discover();
@@ -2784,6 +2797,8 @@ void cSVDRPServerHandler::ProcessConnections(void)
{ {
for (int i = 0; i < serverConnections.Size(); i++) { for (int i = 0; i < serverConnections.Size(); i++) {
if (!serverConnections[i]->Process()) { if (!serverConnections[i]->Process()) {
if (SVDRPClientHandler)
SVDRPClientHandler->CloseClient(serverConnections[i]->ClientName());
delete serverConnections[i]; delete serverConnections[i];
serverConnections.Remove(i); serverConnections.Remove(i);
i--; i--;