Skip to content

Commit

Permalink
SocketKeeper before unlock
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsharabayko committed Aug 21, 2024
1 parent c90095a commit ac90912
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions srtcore/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,8 @@ class CUDTUnited
// This is only for a use together with an empty constructor.
bool acquire(CUDTUnited& glob, CUDTSocket* s)
{
if (s == NULL)
return false;
const bool caught = glob.acquireSocket(s);
socket = caught ? s : NULL;
return caught;
Expand Down
6 changes: 3 additions & 3 deletions srtcore/group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -785,13 +785,13 @@ void CUDTGroup::getOpt(SRT_SOCKOPT optname, void* pw_optval, int& w_optlen)
enterCS(m_GroupLock);
gli_t gi = m_Group.begin();
CUDTSocket* const ps = (gi != m_Group.end()) ? gi->ps : NULL;
CUDTUnited::SocketKeeper sk(CUDT::uglobal(), ps);
leaveCS(m_GroupLock);
if (ps)
if (sk.socket)
{
CUDTUnited::SocketKeeper sk(CUDT::uglobal(), ps);
// Return the value from the first member socket, if any is present
// Note: Will throw exception if the request is wrong.
ps->core().getOpt(optname, (pw_optval), (w_optlen));
sk.socket->core().getOpt(optname, (pw_optval), (w_optlen));
is_set_on_socket = true;
}
}
Expand Down

0 comments on commit ac90912

Please sign in to comment.