summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2001-07-12 10:27:18 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2001-07-12 10:27:18 +0200
commit3d2cf4e12aefdd7c6ccd8a9a1de3689bceabfab5 (patch)
tree91c405ba6a099956101267da217b732d89d2944c /thread.c
parent103177a9e75396d18fbbe56a6fa993bb4bfe6263 (diff)
downloadvdr-3d2cf4e12aefdd7c6ccd8a9a1de3689bceabfab5.tar.gz
vdr-3d2cf4e12aefdd7c6ccd8a9a1de3689bceabfab5.tar.bz2
Additional 'emergency exit' in case channel switching doesn't work several times in a row
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/thread.c b/thread.c
index aa6ed64c..e253ea04 100644
--- a/thread.c
+++ b/thread.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: thread.c 1.8 2001/05/25 09:37:00 kls Exp $
+ * $Id: thread.c 1.9 2001/06/27 11:34:41 kls Exp $
*/
#include "thread.h"
@@ -47,6 +47,8 @@ void cMutex::Unlock(void)
// The signal handler is necessary to be able to use SIGIO to wake up any
// pending 'select()' call.
+time_t cThread::lastPanic = 0;
+int cThread::panicLevel = 0;
bool cThread::signalHandlerInstalled = false;
bool cThread::emergencyExitRequested = false;
@@ -139,6 +141,25 @@ void cThread::WakeUp(void)
kill(parentPid, SIGIO); // makes any waiting 'select()' call return immediately
}
+#define MAXPANICLEVEL 10
+
+void cThread::RaisePanic(void)
+{
+ if (lastPanic > 0) {
+ if (time(NULL) - lastPanic < 5)
+ panicLevel++;
+ else if (panicLevel > 0)
+ panicLevel--;
+ }
+ lastPanic = time(NULL);
+ if (panicLevel > MAXPANICLEVEL) {
+ esyslog(LOG_ERR, "ERROR: max. panic level exceeded");
+ EmergencyExit(true);
+ }
+ else
+ dsyslog(LOG_INFO, "panic level: %d", panicLevel);
+}
+
bool cThread::EmergencyExit(bool Request)
{
if (!Request)