adamsutton/xbmc-pvr-addons — pull request #55 by ksooo (2014-11-07 11:32:52+00:00)
Title: [pvr.tvh] Fix: Never lock m_mutex when doing a callback to kodi. Otherwi...

Never lock m_mutex when doing a callback to Kodi. Otherwise kodi will easily deadlock!

Story: When using pvr.tvh (0.9.5) I randomly ran into deadlocks of Kodi. But no deadlocks with pvr.hts, though. All deadlocks exposed the same problem. In difference to pvr.hts, pvr.tvh holds own mutex while doing callbacks to kodi (TransferXYZ function calls). This is evil wrt. concurrency.

Example (Annoteded gdb-provided callstack): http://paste.ubuntu.com/8862842/

Note: The diff is not easily readable, but the change is straightforward: While holding the object's mutex, collect the data to be transferred back to Kodi. Then, release the mutex and transfer the collected data. Follow this common concurrency pattern for all kind of data to be transferred.

Note2: pvr.hts follows (and always did follow, afaict) this pattern and consequently does only do callbacks without object's mutex locked.