From ede5b350b5db3dc141a0e3758011919df940916f Mon Sep 17 00:00:00 2001 From: Gregor Fuis Date: Thu, 23 Feb 2012 19:29:22 +0100 Subject: [PATCH] xbmc: add patch xbmc-1fef727-990-let_the_scripts_react_on_the_abortRequest_before.patch --- ...pts_react_on_the_abortRequest_before.patch | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 packages/mediacenter/xbmc/patches/xbmc-1fef727-990-let_the_scripts_react_on_the_abortRequest_before.patch diff --git a/packages/mediacenter/xbmc/patches/xbmc-1fef727-990-let_the_scripts_react_on_the_abortRequest_before.patch b/packages/mediacenter/xbmc/patches/xbmc-1fef727-990-let_the_scripts_react_on_the_abortRequest_before.patch new file mode 100644 index 0000000000..79223654c5 --- /dev/null +++ b/packages/mediacenter/xbmc/patches/xbmc-1fef727-990-let_the_scripts_react_on_the_abortRequest_before.patch @@ -0,0 +1,71 @@ +From e6bf089bbf486c9879d3abc5ce31a99b67558ea7 Mon Sep 17 00:00:00 2001 +From: Memphiz +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 + +