srt icon indicating copy to clipboard operation
srt copied to clipboard

[core] Fixed cycle-deadlock on m_ConnectionLock and refax on locks in SndUList

Open ethouris opened this issue 3 years ago • 1 comments

Changes:

  1. Refactored locks in SndUList and SndQueue. Actually m_WindowLock was also locking resources for SndUList and "borrowing" them from SndQueue was a poor design. Instead SndQueue is given limited access to these locks and the locks are contained in the SndUList, which should clear the controversies for using two different locks for the same purpose.
  2. Also changed the lock form into CEvent as the lock serves also the purpose of locking around a CV.
  3. Added temporary unlocking of mutexes that would be locked in the wrong order.
  4. Removed the lock for CUDTSocket::m_ControlLock that breaks the ordering against m_ConnectionLock. This lock is likely not necessary provided that m_GlobControlLock is also applied.

ethouris avatar Mar 05 '21 10:03 ethouris

Reviewing notes

  • CSndUList - list (heap) of CUDT sockets to send data packets.

    • m_ListLock - locks CSndUList modifications. update, pop, remove, getNextProcTime.
    • m_pWindowLock - pointer to mutex owned by CSndQueue, only used together with the CV to signal there was a new entry added if it was empty.
    • m_pWindowCond - a pointer to a CV owned by CSndQueue.
  • CSndQueue - a class that owns CSndUList.

    • m_WindowLock
    • m_WindowCond - CV used to wait for CSndUList to become non-empty. Also signalled in the destructor to unblock the worker thread.

maxsharabayko avatar Mar 23 '21 17:03 maxsharabayko

Closed.

  1. One fix is provided different way
  2. The other is left in #1824.
  3. Another fix is proven not necessary and developer info about this is updated.

ethouris avatar Jan 19 '24 15:01 ethouris