mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-08-02 07:27:49 +00:00
xbmc-pvr: add patch xbmc-pvr-2a2a780-990-let_the_scripts_react_on_the_abortRequest_before.patch
This commit is contained in:
parent
ede5b350b5
commit
130c1ba851
@ -0,0 +1,71 @@
|
||||
From e6bf089bbf486c9879d3abc5ce31a99b67558ea7 Mon Sep 17 00:00:00 2001
|
||||
From: Memphiz <memphis@machzwo.de>
|
||||
Date: Sat, 11 Feb 2012 17:28:52 +0100
|
||||
Subject: [PATCH] [fix] - let the scripts react on the abortRequest before
|
||||
killing them
|
||||
|
||||
---
|
||||
xbmc/interfaces/python/XBPyThread.cpp | 18 ++++++++++++++++++
|
||||
xbmc/interfaces/python/XBPyThread.h | 2 ++
|
||||
2 files changed, 20 insertions(+), 0 deletions(-)
|
||||
|
||||
diff --git a/xbmc/interfaces/python/XBPyThread.cpp b/xbmc/interfaces/python/XBPyThread.cpp
|
||||
index c9f0a12..d3c616f 100644
|
||||
--- a/xbmc/interfaces/python/XBPyThread.cpp
|
||||
+++ b/xbmc/interfaces/python/XBPyThread.cpp
|
||||
@@ -375,6 +375,13 @@ void XBPyThread::Process()
|
||||
PyThreadState_Swap(NULL);
|
||||
PyEval_ReleaseLock();
|
||||
|
||||
+ //set stopped event - this allows ::stop to run and kill remaining threads
|
||||
+ //this event has to be fired without holding m_pExecuter->m_critSection
|
||||
+ //before
|
||||
+ //Also the GIL (PyEval_AcquireLock) must not be held
|
||||
+ //if not obeyed there is still no deadlock because ::stop waits with timeout (smart one!)
|
||||
+ stoppedEvent.Set();
|
||||
+
|
||||
{ CSingleLock lock(m_pExecuter->m_critSection);
|
||||
m_threadState = NULL;
|
||||
}
|
||||
@@ -428,6 +435,17 @@ void XBPyThread::stop()
|
||||
if(!m || PyObject_SetAttrString(m, (char*)"abortRequested", PyBool_FromLong(1)))
|
||||
CLog::Log(LOGERROR, "XBPyThread::stop - failed to set abortRequested");
|
||||
|
||||
+ PyThreadState_Swap(old);
|
||||
+ PyEval_ReleaseLock();
|
||||
+
|
||||
+ if(!stoppedEvent.WaitMSec(5000))//let the script 5 secs for shut stuff down
|
||||
+ {
|
||||
+ CLog::Log(LOGERROR, "XBPyThread::stop - script didn't stop in proper time - lets kill it");
|
||||
+ }
|
||||
+
|
||||
+ //everything which didn't exit by now gets killed
|
||||
+ PyEval_AcquireLock();
|
||||
+ old = PyThreadState_Swap((PyThreadState*)m_threadState);
|
||||
for(PyThreadState* state = ((PyThreadState*)m_threadState)->interp->tstate_head; state; state = state->next)
|
||||
{
|
||||
Py_XDECREF(state->async_exc);
|
||||
diff --git a/xbmc/interfaces/python/XBPyThread.h b/xbmc/interfaces/python/XBPyThread.h
|
||||
index 2b83b52..55a6fbd 100644
|
||||
--- a/xbmc/interfaces/python/XBPyThread.h
|
||||
+++ b/xbmc/interfaces/python/XBPyThread.h
|
||||
@@ -23,6 +23,7 @@
|
||||
#define XBPYTHREAD_H_
|
||||
|
||||
#include "threads/Thread.h"
|
||||
+#include "threads/Event.h"
|
||||
#include "addons/IAddon.h"
|
||||
|
||||
class XBPython;
|
||||
@@ -42,6 +43,7 @@ class XBPyThread : public CThread
|
||||
|
||||
protected:
|
||||
XBPython *m_pExecuter;
|
||||
+ CEvent stoppedEvent;
|
||||
void *m_threadState;
|
||||
|
||||
char m_type;
|
||||
--
|
||||
1.7.5.4
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user