| 38 | Although hard deadlock (where application just freezes) should never happen when the above guidelines are used, there may be cases when application gets a ''soft deadlock'' state. When this happens, application will not freeze permanently, but rather it will freeze for few seconds while PJSUA-LIB is trying to acquire the locks, and these message may appear in the log: |
| 39 | |
| 40 | ''Timed-out trying to acquire PJSUA mutex (possibly system has deadlocked) in pjsua_xxx'' |
| 41 | |
| 42 | This could happen for example in the following scenario: |
| 43 | 1. application callback is called |
| 44 | 1. application posts a job to a worker thread, and blocks until it gets result from the worker thread |
| 45 | 1. the worker thread calls some PJSUA-LIB call API |
| 46 | 1. when PJSUA-LIB tries to acquire locks with {{{acquire_call()}}} on behalf of the worker thread, it will fail to get them because the locks are currently being held by the callback thread (in step no 1 above). In this case, rather than ''deadlocking'' permanently, PJSUA-LIB will timeout after it retries acquiring the locks for few seconds, and returns PJ_ETIMEDOUT error to {{{acquire_call()}}} caller. |
| 47 | |
| 48 | This problem is not caused by PJSUA-LIB, and in fact PJSUA-LIB has helped us not to deadlock permanently. |
| 49 | |
| 50 | As for the solution, quoting the famous saying, I'll leave that as an exercise for the reader. ;-) |
| 51 | |