fixes #129504 - Fix a deadlock in IOManager::WaitBlock.
fixes #129504 - Fix a deadlock in IOManager::WaitBlock.

Fix the deadlock.
If there're two events like "cancelThread" and "callOnRemoteClose", sent almost at the same time,
then it's possible that one entry is removing from m_handles in "WaitBlock::unregisterEvent" function,
and the other is in "WaitBlock::run".
In this case, the "m_inUseCount" has already been set to -1, and WaitBlock thread go ahead to lock
IOManager::m_mutex, but at meantime, "WaitBlock::unregisterEvent" is still waiting for event of
"m_reconfigured", and IOManager::m_mutex was locked before call "WaitBlock::unregisterEvent".
That's the deadlock.

To reproduce it, just let thread.cancel and connector.Shutdown been called in a short interval of time.

The dump file can show the problem (Thread 17 and 18):
https://redmine.mozycorp.com/attachments/download/46509/dump.txt

Test Done:
Backup and Pause in Kalypso works fine without deadlock anymore.

Change-Id: I6a01a16fe8185f176d6a2eaf66d6c39d4338e8a2
Signed-off-by: Solon Chen <d71559596efb07a187137058471851089dd52131@emc.com>
Reviewed-on: https://gerrit.dechocorp.com/79326
Reviewed-by: Kevin Cai <17c90eb5054a9a23c0bb0267ffc129b57a75ec96@emc.com>
Reviewed-by: Jenkins <49695b0f9c673fd73dab0ff3f84b5ced9302cc6a@mozy.com>
Reviewed-by: Andrew Skowronski <96924f7a4dbe24093bb2da18f50a76703cb4a362@mozy.com>
Reviewed-by: Pancho Avila <319d15d775dfc3f201c557dd1d67f8ac91576825@mozy.com>

mozy/mordor,mozy/mordor,mozy/mordor