aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Op den Kamp <lars@opdenkamp.eu>2012-12-30 18:29:41 +0100
committerLars Op den Kamp <lars@opdenkamp.eu>2012-12-30 19:49:16 +0100
commitaf668c4f325efe21d34b7dccb0d2f089683e200d (patch)
treecb30083cb6bc914b7dfe496d0b1db469a5ad8ff6
parent93845ec3ed5ee1d041deae199ef40b197ff3fb6f (diff)
[pvr] throttle connection attempts, no more than 1 attempt per 5 seconds
-rw-r--r--xbmc/pvr/addons/PVRClients.cpp11
-rw-r--r--xbmc/pvr/addons/PVRClients.h1
2 files changed, 12 insertions, 0 deletions
diff --git a/xbmc/pvr/addons/PVRClients.cpp b/xbmc/pvr/addons/PVRClients.cpp
index c49e9be987..ae11936738 100644
--- a/xbmc/pvr/addons/PVRClients.cpp
+++ b/xbmc/pvr/addons/PVRClients.cpp
@@ -918,6 +918,17 @@ bool CPVRClients::UpdateAndInitialiseClients(bool bInitialiseAllClients /* = fal
}
}
+ // throttle connection attempts, no more than 1 attempt per 5 seconds
+ if (!bDisabled && addon->Enabled())
+ {
+ time_t now;
+ CDateTime::GetCurrentDateTime().GetAsTime(now);
+ std::map<int, time_t>::iterator it = m_connectionAttempts.find(iClientId);
+ if (it != m_connectionAttempts.end() && now < it->second)
+ continue;
+ m_connectionAttempts[iClientId] = now + 5;
+ }
+
// re-check the enabled status. newly installed clients get disabled when they're added to the db
if (!bDisabled && addon->Enabled() && (status = addon->Create(iClientId)) != ADDON_STATUS_OK)
{
diff --git a/xbmc/pvr/addons/PVRClients.h b/xbmc/pvr/addons/PVRClients.h
index 1265be4ccd..7725fa1e0d 100644
--- a/xbmc/pvr/addons/PVRClients.h
+++ b/xbmc/pvr/addons/PVRClients.h
@@ -631,5 +631,6 @@ namespace PVR
bool m_bNoAddonWarningDisplayed; /*!< true when a warning was displayed that no add-ons were found, false otherwise */
CCriticalSection m_critSection;
CAddonDatabase m_addonDb;
+ std::map<int, time_t> m_connectionAttempts; /*!< last connection attempt per add-on */
};
}