Now sending the SVDRP discover broadcast once per minute, to re-establish lost connections

This commit is contained in:
Klaus Schmidinger
2025-07-21 08:26:31 +02:00
parent 0c654ed2a7
commit 49cc3adfba
2 changed files with 10 additions and 5 deletions

View File

@@ -10138,7 +10138,7 @@ Video Disk Recorder Revision History
- Fixed an invalid lock sequence when pressing the Channel+/Channel- keys while in the
"What's on..." menu in live view.
2025-07-10:
2025-07-21:
- Fixed cPoller::Poll() to allow negative timeout values again.
- When regenerating the index of a recording, PID changes are now taken into account
@@ -10169,3 +10169,4 @@ Video Disk Recorder Revision History
- Reverted the change in cCondWait::SleepMs() because of a possible lockup (reported by Johann
Friedrichs).
- Added cTimer::VpsTime() (suggested by Markus Ehrnsperger).
- Now sending the SVDRP discover broadcast once per minute, to re-establish lost connections.

12
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.11 2025/03/02 11:03:35 kls Exp $
* $Id: svdrp.c 5.12 2025/07/21 08:26:31 kls Exp $
*/
#include "svdrp.h"
@@ -246,7 +246,6 @@ bool cSocket::SendDgram(const char *Dgram, int Port)
Addr.sin_port = htons(Port);
// Send datagram:
dbgsvdrp("> %s:%d %s\n", inet_ntoa(Addr.sin_addr), Port, Dgram);
dsyslog("SVDRP %s > %s:%d send dgram '%s'", Setup.SVDRPHostName, inet_ntoa(Addr.sin_addr), Port, Dgram);
int Length = strlen(Dgram);
int Sent = sendto(Socket, Dgram, Length, 0, (sockaddr *)&Addr, sizeof(Addr));
if (Sent < 0)
@@ -301,7 +300,6 @@ cString cSocket::Discover(void)
}
if (strcmp(strgetval(buf, "name", ':'), Setup.SVDRPHostName) != 0) { // ignore our own broadcast
dbgsvdrp("< %s discovery received (%s)\n", lastIpAddress.Connection(), buf);
isyslog("SVDRP %s < %s discovery received (%s)", Setup.SVDRPHostName, lastIpAddress.Connection(), buf);
return buf;
}
}
@@ -714,8 +712,14 @@ void cSVDRPClientHandler::Action(void)
{
if (udpSocket.Listen()) {
SVDRPClientPoller.Add(udpSocket.Socket(), false);
SendDiscover();
time_t LastDiscover = 0;
#define SVDRPDiscoverDelta 60 // seconds
while (Running()) {
time_t Now = time(NULL);
if (Now - LastDiscover >= SVDRPDiscoverDelta) {
SendDiscover();
LastDiscover = Now;
}
SVDRPClientPoller.Poll(1000);
cMutexLock MutexLock(&mutex);
HandleClientConnection();