Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Protecting RCV buffer access #1335

Merged

Conversation

maxsharabayko
Copy link
Collaborator

This PR protects access to CRcvBuffer::readMsg(..) with m_RcvBufferLock.
Together with #1333 fixes #486

In case of the receiver, there are two threads accessing CUnitQueue.
Both of these threads were protecting access to CRcvBuffer and eventually to CUnitQueue with different mutexes, meaning there was no protection from simultaneous writing via makeUnit*(..) functions.

The thread that receives packets from the network has the following call stack:

  • CUDT::processData(CUnit* in_unit)
    locks m_RcvBufferLock
  • CRcvBuffer::addData(CUnit* unit, int offset)
  • m_pUnitQueue->makeUnitGood(unit, "addData")

Another thread is the application thread that reads data from the buffer.
Call stack:

  • CUDT::receiveMessage(..)
    locks m_RecvLock
  • CRcvBuffer::readMsg(..)
  • CRcvBuffer::extractData(..)
  • freeUnitAt(..)
  • m_pUnitQueue->makeUnitFree(..)

@maxsharabayko maxsharabayko added Type: Bug Indicates an unexpected problem or unintended behavior [core] Area: Changes in SRT library core labels Jun 9, 2020
@maxsharabayko maxsharabayko added this to the v1.5.0 - Sprint 16 milestone Jun 9, 2020
srtcore/core.cpp Outdated Show resolved Hide resolved
@maxsharabayko maxsharabayko merged commit 903e023 into Haivision:master Jun 11, 2020
@maxsharabayko maxsharabayko deleted the hotfix/unitqueue-access-mtx branch June 11, 2020 15:21
@mbakholdina mbakholdina modified the milestones: v1.5.0 - Sprint 16, v1.4.2 Oct 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[core] Area: Changes in SRT library core Type: Bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LOCAL STORAGE DEPLETED
3 participants