Skip to content

Commit

Permalink
[core] Added some SRT_ATTR_EXCLUDES to CUDT (#2979).
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsharabayko authored Jul 30, 2024
1 parent bc2f48e commit dbf5965
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion srtcore/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,7 @@ class CUDT
/// @param seqno [in] The sequence number of the first packets following those to be dropped.
/// @param reason A reason for dropping (see @a DropReason).
/// @return The number of packets dropped.
SRT_ATTR_EXCLUDES(m_RcvBufferLock, m_RcvLossLock)
int rcvDropTooLateUpTo(int seqno, DropReason reason = DROP_TOO_LATE);

static loss_seqs_t defaultPacketArrival(void* vself, CPacket& pkt);
Expand Down Expand Up @@ -962,6 +963,7 @@ class CUDT
bool frequentLogAllowed(size_t logid, const time_point& tnow, std::string& why);

private: // Receiving related data
SRT_ATTR_GUARDED_BY(m_RcvBufferLock)
CRcvBuffer* m_pRcvBuffer; //< Receiver buffer
SRT_ATTR_GUARDED_BY(m_RcvLossLock)
CRcvLossList* m_pRcvLossList; //< Receiver loss list
Expand Down Expand Up @@ -992,6 +994,7 @@ class CUDT
bool m_bTsbPd; // Peer sends TimeStamp-Based Packet Delivery Packets
bool m_bGroupTsbPd; // TSBPD should be used for GROUP RECEIVER instead

SRT_ATTR_GUARDED_BY(m_RcvTsbPdStartupLock)
sync::CThread m_RcvTsbPdThread; // Rcv TsbPD Thread handle
sync::Condition m_RcvTsbPdCond; // TSBPD signals if reading is ready. Use together with m_RecvLock
bool m_bTsbPdNeedsWakeup; // Signal TsbPd thread to wake up on RCV buffer state change.
Expand Down Expand Up @@ -1126,6 +1129,8 @@ class CUDT
/// @retval false Nothing was extracted for sending, @a nexttime should be ignored
bool packData(CPacket& packet, time_point& nexttime, sockaddr_any& src_addr);

/// Also excludes srt::CUDTUnited::m_GlobControlLock.
SRT_ATTR_EXCLUDES(m_RcvTsbPdStartupLock, m_StatsLock, m_RecvLock, m_RcvLossLock, m_RcvBufferLock)
int processData(CUnit* unit);

/// This function passes the incoming packet to the initial processing
Expand All @@ -1149,8 +1154,10 @@ class CUDT
/// and shall not be used when ENABLE_BONDING=0.
time_point getPktTsbPdTime(void* grp, const CPacket& packet);

SRT_ATTR_EXCLUDES(m_RcvTsbPdStartupLock)
/// Checks and spawns the TSBPD thread if required.
int checkLazySpawnTsbPdThread();

void processClose();

/// Process the request after receiving the handshake from caller.
Expand All @@ -1167,9 +1174,9 @@ class CUDT
void processKeepalive(const CPacket& ctrlpkt, const time_point& tsArrival);


SRT_ATTR_REQUIRES(m_RcvBufferLock)
/// Retrieves the available size of the receiver buffer.
/// Expects that m_RcvBufferLock is locked.
SRT_ATTR_REQUIRES(m_RcvBufferLock)
size_t getAvailRcvBufferSizeNoLock() const;

private: // Trace
Expand Down
3 changes: 2 additions & 1 deletion srtcore/srt_attr_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ used by SRT library internally.
#define SRT_ATTR_RELEASE_GENERIC(...)
#define SRT_ATTR_TRY_ACQUIRE(...) _Acquires_nonreentrant_lock_(expr)
#define SRT_ATTR_TRY_ACQUIRE_SHARED(...)
#define SRT_ATTR_EXCLUDES(...)
#define SRT_ATTR_EXCLUDES(...) // the caller must not hold the given capabilities
#define SRT_ATTR_ASSERT_CAPABILITY(expr)
#define SRT_ATTR_ASSERT_SHARED_CAPABILITY(x)
#define SRT_ATTR_RETURN_CAPABILITY(x)
Expand Down Expand Up @@ -179,6 +179,7 @@ used by SRT library internally.
#define SRT_ATTR_TRY_ACQUIRE_SHARED(...) \
THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_shared_capability(__VA_ARGS__))

// The caller must not hold the given capabilities.
#define SRT_ATTR_EXCLUDES(...) \
THREAD_ANNOTATION_ATTRIBUTE__(locks_excluded(__VA_ARGS__))

Expand Down

0 comments on commit dbf5965

Please sign in to comment.