[SCM] kodi-pvr-vdr-vnsi/master: improve connection handling

tiber-guest at users.alioth.debian.org tiber-guest at users.alioth.debian.org
Fri Nov 4 00:20:21 UTC 2016


The following commit has been merged in the master branch:
commit 5481451e0043d9a362b76942b59740fc44c527f1
Author: Rainer Hochecker <fernetmenta at online.de>
Date:   Wed Mar 30 08:46:58 2016 +0200

    improve connection handling

diff --git a/src/VNSIData.cpp b/src/VNSIData.cpp
index 7e4de7a..e65672e 100644
--- a/src/VNSIData.cpp
+++ b/src/VNSIData.cpp
@@ -86,7 +86,7 @@ bool cVNSIData::Start(const std::string& hostname, int port, const char* name, c
     }
   }
 
-  PVR->ConnectionStateChange("VNSI stated", PVR_CONNECTION_STATE_CONNECTING, "VNSI started");
+  PVR->ConnectionStateChange("VNSI started", PVR_CONNECTION_STATE_CONNECTING, "VNSI started");
 
   m_abort = false;
   CreateThread();
@@ -1016,10 +1016,20 @@ void *cVNSIData::Process()
   while (!IsStopped())
   {
     // try to reconnect
-    if (m_connectionLost && !TryReconnect())
+    if (m_connectionLost)
     {
-      Sleep(1000);
-      continue;
+      cVNSISession::eCONNECTIONSTATE state = TryReconnect();
+      if (state != cVNSISession::CONN_ESABLISHED)
+      {
+	if (state == cVNSISession::CONN_HOST_NOT_REACHABLE)
+	{
+	  PVR->ConnectionStateChange("vnsi server not reacheable",
+				     PVR_CONNECTION_STATE_SERVER_UNREACHABLE, nullptr);
+	}
+
+	Sleep(1000);
+	continue;
+      }
     }
 
     // if there's anything in the buffer, read it
diff --git a/src/VNSIData.h b/src/VNSIData.h
index 93ef8e1..2258186 100644
--- a/src/VNSIData.h
+++ b/src/VNSIData.h
@@ -74,7 +74,7 @@ public:
 
 protected:
 
-  virtual void *Process(void);
+  virtual void *Process(void) override;
   virtual bool OnResponsePacket(cResponsePacket *pkt);
 
   void OnDisconnect() override;
diff --git a/src/VNSIRecording.cpp b/src/VNSIRecording.cpp
index d487d95..ce9bfa6 100644
--- a/src/VNSIRecording.cpp
+++ b/src/VNSIRecording.cpp
@@ -82,7 +82,7 @@ void cVNSIRecording::Close()
 
 int cVNSIRecording::Read(unsigned char* buf, uint32_t buf_size)
 {
-  if (m_connectionLost && !TryReconnect())
+  if (m_connectionLost && TryReconnect() != cVNSISession::CONN_ESABLISHED)
   {
     *buf = 0;
     SleepMs(100);
diff --git a/src/VNSISession.cpp b/src/VNSISession.cpp
index 8dcd067..4a34557 100644
--- a/src/VNSISession.cpp
+++ b/src/VNSISession.cpp
@@ -84,7 +84,7 @@ bool cVNSISession::Open(const std::string& hostname, int port, const char *name)
 
   if (!m_socket->IsOpen() && !m_abort)
   {
-    XBMC->Log(LOG_ERROR, "%s - failed to connect to the backend (%s)", __FUNCTION__, m_socket->GetError().c_str());
+    XBMC->Log(LOG_DEBUG, "%s - failed to connect to the backend (%s)", __FUNCTION__, m_socket->GetError().c_str());
     return false;
   }
 
@@ -343,20 +343,20 @@ void cVNSISession::OnDisconnect()
 {
 }
 
-bool cVNSISession::TryReconnect()
+cVNSISession::eCONNECTIONSTATE cVNSISession::TryReconnect()
 {
   if (!Open(m_hostname, m_port))
-    return false;
+    return CONN_HOST_NOT_REACHABLE;
 
   if (!Login())
-    return false;
+    return CONN_LOGIN_FAILED;
 
   XBMC->Log(LOG_DEBUG, "%s - reconnected", __FUNCTION__);
   m_connectionLost = false;
 
   OnReconnect();
 
-  return true;
+  return CONN_ESABLISHED;
 }
 
 bool cVNSISession::IsOpen()
diff --git a/src/VNSISession.h b/src/VNSISession.h
index c680a2d..6193ee3 100644
--- a/src/VNSISession.h
+++ b/src/VNSISession.h
@@ -55,13 +55,19 @@ public:
   const std::string& GetServerName() const { return m_server; }
   const std::string& GetVersion() const { return m_version; }
 
-
+  enum eCONNECTIONSTATE
+  {
+    CONN_ESABLISHED = 0,
+    CONN_HOST_NOT_REACHABLE,
+    CONN_LOGIN_FAILED,
+    CONN_UNKNOWN
+  };
 
 protected:
 
   void SleepMs(int ms);
 
-  bool TryReconnect();
+  eCONNECTIONSTATE TryReconnect();
   bool IsOpen();
 
   virtual void OnDisconnect();

-- 
kodi-pvr-vdr-vnsi packaging



More information about the pkg-multimedia-commits mailing list