summaryrefslogtreecommitdiff
path: root/svdrp.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2018-03-01 14:45:57 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2018-03-01 14:45:57 +0100
commit4d7455e783e0fd4f37651e2bd6570d0468ca1cd0 (patch)
tree894ba0bf9914f1e9fa6c1c3864a783b642cd919e /svdrp.c
parent66d66b31dc696a8ac76a23b819eae96cc7b68f65 (diff)
downloadvdr-4d7455e783e0fd4f37651e2bd6570d0468ca1cd0.tar.gz
vdr-4d7455e783e0fd4f37651e2bd6570d0468ca1cd0.tar.bz2
Added timeouts for SVDRP peer communication about timers
Diffstat (limited to 'svdrp.c')
-rw-r--r--svdrp.c49
1 files changed, 27 insertions, 22 deletions
diff --git a/svdrp.c b/svdrp.c
index 93ead5eb..b85e13ba 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 4.31 2018/02/28 10:04:00 kls Exp $
+ * $Id: svdrp.c 4.32 2018/03/01 14:45:57 kls Exp $
*/
#include "svdrp.h"
@@ -483,22 +483,20 @@ bool cSVDRPClient::HasFetchFlag(eSvdrpFetchFlags Flag)
bool cSVDRPClient::GetRemoteTimers(cStringList &Response)
{
- if (HasFetchFlag(sffTimers)) {
- if (Execute("LSTT ID", &Response)) {
- for (int i = 0; i < Response.Size(); i++) {
- char *s = Response[i];
- int Code = SVDRPCode(s);
- if (Code == 250)
- strshift(s, 4);
- else {
- if (Code != 550)
- esyslog("ERROR: %s: %s", ServerName(), s);
- return false;
- }
+ if (Execute("LSTT ID", &Response)) {
+ for (int i = 0; i < Response.Size(); i++) {
+ char *s = Response[i];
+ int Code = SVDRPCode(s);
+ if (Code == 250)
+ strshift(s, 4);
+ else {
+ if (Code != 550)
+ esyslog("ERROR: %s: %s", ServerName(), s);
+ return false;
}
- Response.SortNumerically();
- return true;
- }
+ }
+ Response.SortNumerically();
+ return true;
}
return false;
}
@@ -629,18 +627,25 @@ void cSVDRPClientHandler::SendDiscover(void)
void cSVDRPClientHandler::ProcessConnections(void)
{
cString PollTimersCmd;
- if (cTimers::GetTimersRead(timersStateKey)) {
+ if (cTimers::GetTimersRead(timersStateKey, 100)) {
PollTimersCmd = cString::sprintf("POLL %s TIMERS", Setup.SVDRPHostName);
timersStateKey.Remove();
}
+ else if (timersStateKey.TimedOut())
+ return; // try again next time
for (int i = 0; i < clientConnections.Size(); i++) {
cSVDRPClient *Client = clientConnections[i];
if (Client->Process()) {
- cStringList RemoteTimers;
- if (Client->GetRemoteTimers(RemoteTimers)) {
- cTimers *Timers = cTimers::GetTimersWrite(timersStateKey);
- bool TimersModified = Timers->StoreRemoteTimers(Client->ServerName(), &RemoteTimers);
- timersStateKey.Remove(TimersModified);
+ if (Client->HasFetchFlag(sffTimers)) {
+ cStringList RemoteTimers;
+ if (Client->GetRemoteTimers(RemoteTimers)) {
+ if (cTimers *Timers = cTimers::GetTimersWrite(timersStateKey, 100)) {
+ bool TimersModified = Timers->StoreRemoteTimers(Client->ServerName(), &RemoteTimers);
+ timersStateKey.Remove(TimersModified);
+ }
+ else
+ Client->SetFetchFlag(sffTimers); // try again next time
+ }
}
if (*PollTimersCmd) {
if (!Client->Execute(PollTimersCmd))