summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSascha Volkenandt <sascha (at) akv-soft (dot) de>2007-01-04 14:18:54 +0000
committerSascha Volkenandt <sascha (at) akv-soft (dot) de>2007-01-04 14:18:54 +0000
commit8db65a15e220b33371b1d3c502a05bf308316db4 (patch)
tree46016c25ea94f35bae5216673a57f0ca16b9072c
parent22feca64f3450d092cf593ba8c2cf34243ef9670 (diff)
downloadvdr-plugin-live-8db65a15e220b33371b1d3c502a05bf308316db4.tar.gz
vdr-plugin-live-8db65a15e220b33371b1d3c502a05bf308316db4.tar.bz2
- added read lock objekt for channels
-rw-r--r--pages/channels.ecpp26
-rw-r--r--tools.h15
2 files changed, 32 insertions, 9 deletions
diff --git a/pages/channels.ecpp b/pages/channels.ecpp
index 5f64d1d..02fb4a3 100644
--- a/pages/channels.ecpp
+++ b/pages/channels.ecpp
@@ -3,6 +3,7 @@
#include <vdr/plugin.h>
#include <vdr/channels.h>
#include "setup.h"
+#include "tools.h"
using namespace vdrlive;
@@ -15,17 +16,24 @@ using namespace vdrlive;
<div id="inhalt">
<{
- for (cChannel *channel = Channels.First(); channel && channel->Number() <= LiveSetup().GetLastChannel(); channel = Channels.Next(channel)) {
- if (!channel->GroupSep() && *channel->Name()) {
+ ReadLock channelsLock( Channels );
+ if (channelsLock) {
+ for (cChannel *channel = Channels.First(); channel && channel->Number() <= LiveSetup().GetLastChannel(); channel = Channels.Next(channel)) {
+ if (!channel->GroupSep() && *channel->Name()) {
}>
- <div class="channel">
- <a href="schedule.html?channel=<$ channel->Number() $>"><$ channel->Name() $></a>
- </div>
+ <div class="channel">
+ <a href="schedule.html?channel=<$ channel->Number() $>"><$ channel->Name() $></a>
+ </div>
<{
- }
- }
-
-
+ }
+ }
+ } else {
+}>
+ <div class="error">
+ Zugriff auf Kanäle temporär nicht möglich. Bitte später versuchen.
+ </div>
+<{
+ }
}>
</div>
</body>
diff --git a/tools.h b/tools.h
index 4a01ca8..18f968d 100644
--- a/tools.h
+++ b/tools.h
@@ -3,11 +3,26 @@
#include <ctime>
#include <string>
+#include <vdr/thread.h>
namespace vdrlive {
std::string FormatDateTime( char const* format, time_t time );
+class ReadLock
+{
+public:
+ ReadLock( cRwLock& lock, int timeout = 100 ): m_lock( lock ), m_locked( false ) { if ( m_lock.Lock( false, timeout ) ) m_locked = true; }
+ ~ReadLock() { if ( m_locked ) m_lock.Unlock(); }
+
+ operator bool() { return m_locked; }
+ bool operator!() { return !m_locked; }
+
+private:
+ cRwLock& m_lock;
+ bool m_locked;
+};
+
} // namespace vdrlive
#endif // VDR_LIVE_TOOLS_H