Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
(further impossible fixes pending)

Co-authored-by: Maxim Sharabayko <maxlovic@gmail.com>
  • Loading branch information
ethouris and maxsharabayko authored Feb 28, 2024
1 parent 1830e3a commit 283021e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
1 change: 0 additions & 1 deletion srtcore/buffer_rcv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,6 @@ int CRcvBuffer::readMessage(char* data, size_t len, SRT_MSGCTRL* msgctrl, pair<i
return 0;
}

//const bool canReadInOrder = m_iFirstNonreadPos != m_iStartPos;
const int readPos = canReadInOrder ? m_iStartPos : m_iFirstNonOrderMsgPos;
const bool isReadingFromStart = (readPos == m_iStartPos); // Indicates if the m_iStartPos can be changed

Expand Down
8 changes: 4 additions & 4 deletions srtcore/buffer_rcv.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ namespace srt
// m_pUnit[i]->status_: 0: free, 1: good, 2: read, 3: dropped (can be combined with read?)
//
// thread safety:
// start_pos_: CUDT::m_RecvLock
// m_iStartPos: CUDT::m_RecvLock
// first_unack_pos_: CUDT::m_AckLock
// max_pos_inc_: none? (modified on add and ack
// first_nonread_pos_:
// m_iMaxPosOff: none? (modified on add and ack
// m_iFirstNonreadPos:
//
//
// m_iStartPos: the first packet that should be read (might be empty)
Expand Down Expand Up @@ -455,7 +455,7 @@ class CRcvBuffer
return m_iMaxPosOff;
}

// Unfortunately it still needs locking.
// Returns true if the buffer is full. Requires locking.
bool full() const
{
return size() == capacity();
Expand Down
4 changes: 2 additions & 2 deletions srtcore/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5544,7 +5544,7 @@ void * srt::CUDT::tsbpd(void* param)
tsNextDelivery = steady_clock::time_point(); // Ready to read, nothing to wait for.
}

SRT_ATR_UNUSED bool wakeup_on_signal = true;
SRT_ATR_UNUSED bool bWakeupOnSignal = true;

// We may just briefly unlocked the m_RecvLock, so we need to check m_bClosing again to avoid deadlock.
if (self->m_bClosing)
Expand Down Expand Up @@ -8183,7 +8183,7 @@ int srt::CUDT::sendCtrlAck(CPacket& ctrlpkt, int size)
}
}
#endif
// Signalling m_RecvDataCond is not dane when TSBPD is on.
// Signalling m_RecvDataCond is not done when TSBPD is on.
// This signalling is done in file mode in order to keep the
// API reader thread sleeping until there is a "bigger portion"
// of data to read. In TSBPD mode this isn't done because every
Expand Down
2 changes: 1 addition & 1 deletion srtcore/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -987,7 +987,7 @@ class CUDT

sync::CThread m_RcvTsbPdThread; // Rcv TsbPD Thread handle
sync::Condition m_RcvTsbPdCond; // TSBPD signals if reading is ready. Use together with m_RecvLock
sync::atomic<bool> m_bWakeOnRecv; // Expected to be woken up when received a packet
sync::atomic<bool> m_bWakeOnRecv; // Expected to wake up TSBPD when a read-ready data packet is received.
sync::Mutex m_RcvTsbPdStartupLock; // Protects TSBPD thread creating and joining

CallbackHolder<srt_listen_callback_fn> m_cbAcceptHook;
Expand Down

0 comments on commit 283021e

Please sign in to comment.