Skip to content

Commit

Permalink
Applied fixes from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikołaj Małecki committed Jul 18, 2024
1 parent 82bfbd3 commit 3d108fa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
13 changes: 6 additions & 7 deletions srtcore/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1916,11 +1916,11 @@ int srt::CUDTUnited::close(const SRTSOCKET u)
#if ENABLE_HEAVY_LOGGING
// Wrapping the log into a destructor so that it
// is printed AFTER the destructor of SocketKeeper.
struct ForceDestructor
struct ScopedExitLog
{
CUDTSocket* ps;
ForceDestructor(): ps(NULL){}
~ForceDestructor()
const CUDTSocket* const ps;
ScopedExitLog(const CUDTSocket* p): ps(p){}
~ScopedExitLog()
{
if (ps) // Could be not acquired by SocketKeeper, occasionally
{
Expand All @@ -1931,11 +1931,10 @@ int srt::CUDTUnited::close(const SRTSOCKET u)
#endif

SocketKeeper k(*this, u, ERH_THROW);
IF_HEAVY_LOGGING(fod.ps = k.socket);
IF_HEAVY_LOGGING(ScopedExitLog slog(k.socket));
HLOGC(smlog.Debug, log << "CUDTUnited::close/begin: @" << u << " busy=" << k.socket->isStillBusy());
int ret = close(k.socket);

return ret;
return close(k.socket);
}

#if ENABLE_BONDING
Expand Down
6 changes: 3 additions & 3 deletions srtcore/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ class CUDTUnited
int epoll_release(const int eid);

#if ENABLE_BONDING
// [[using locked(m_GlobControlLock)]]
SRT_ATR_NODISCARD SRT_ATTR_REQUIRES(m_GlobControlLock)
CUDTGroup& addGroup(SRTSOCKET id, SRT_GROUP_TYPE type)
{
// This only ensures that the element exists.
Expand All @@ -359,7 +359,7 @@ class CUDTUnited
void deleteGroup(CUDTGroup* g);
void deleteGroup_LOCKED(CUDTGroup* g);

// [[using locked(m_GlobControlLock)]]
SRT_ATR_NODISCARD SRT_ATTR_REQUIRES(m_GlobControlLock)
CUDTGroup* findPeerGroup_LOCKED(SRTSOCKET peergroup)
{
for (groups_t::iterator i = m_Groups.begin(); i != m_Groups.end(); ++i)
Expand Down Expand Up @@ -485,7 +485,7 @@ class CUDTUnited
// This is only for a use together with an empty constructor.
bool acquire(CUDTUnited& glob, CUDTSocket* s)
{
bool caught = glob.acquireSocket(s);
const bool caught = glob.acquireSocket(s);
socket = caught ? s : NULL;
return caught;
}
Expand Down

0 comments on commit 3d108fa

Please sign in to comment.