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()
for fixing the stop time of repeating timers in case of DST change
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>
for reporting a bug in handling the cPluginManager::Active() result when pressing

View File

@@ -10170,3 +10170,5 @@ Video Disk Recorder Revision History
Friedrichs).
- Added cTimer::VpsTime() (suggested by Markus Ehrnsperger).
- 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
* 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"
@@ -324,10 +324,10 @@ private:
int fetchFlags;
bool connected;
bool Send(const char *Command);
void Close(void);
public:
cSVDRPClient(const char *Address, int Port, const char *ServerName, int Timeout);
~cSVDRPClient();
void Close(void);
const char *ServerName(void) const { return serverName; }
const char *Connection(void) const { return serverIpAddress.Connection(); }
bool HasAddress(const char *Address, int Port) const;
@@ -465,6 +465,7 @@ bool cSVDRPClient::Process(cStringList *Response)
}
else if (Timeout.TimedOut()) {
esyslog("SVDRP %s < %s timeout while waiting for response from '%s'", Setup.SVDRPHostName, serverIpAddress.Connection(), *serverName);
Close();
return false;
}
else if (!Response && numChars == 0)
@@ -603,6 +604,7 @@ public:
cSVDRPClientHandler(int TcpPort, int UdpPort);
virtual ~cSVDRPClientHandler() override;
void AddClient(cSVDRPServerParams &ServerParams, const char *IpAddress);
void CloseClient(const char *ServerName);
bool Execute(const char *ServerName, const char *Command, cStringList *Response = NULL);
bool GetServerNames(cStringList *ServerNames);
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()));
}
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)
{
cString NewDiscover = udpSocket.Discover();
@@ -2784,6 +2797,8 @@ void cSVDRPServerHandler::ProcessConnections(void)
{
for (int i = 0; i < serverConnections.Size(); i++) {
if (!serverConnections[i]->Process()) {
if (SVDRPClientHandler)
SVDRPClientHandler->CloseClient(serverConnections[i]->ClientName());
delete serverConnections[i];
serverConnections.Remove(i);
i--;