ging/licode — pull request #180 by jnoring (2014-10-02 19:23:36+00:00)
Title: Some mutex cleanup, fix for a deadlock

We've hit deadlocks in production where Thread #1 is holding WebRtcConenction::receiveVideoMutex, writeMutex, updateStateMutex and trying to get NiceConnection::agentMutex. Thread #2 is holding NiceConnection::agentMutex and NiceConnection::stateMutex and trying to get updateStateMutex. The crux of the issue seems to be the updateIceState call, and particularly when ice negotiation fails.

I've changed around how mutexs are held in portions of the app, and wherever posssible I avoid manual locking/unlocking of a mutex, and instead rely on RAII (i.e. auto lock goes out of scope, the mutex is unlocked)