Skip to content

Commit

Permalink
[core] Not adding socket to group when address buffer is not set (#1544)
Browse files Browse the repository at this point in the history
  • Loading branch information
Llorx authored Sep 15, 2020
1 parent e756477 commit c576662
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions srtcore/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1118,28 +1118,28 @@ SRTSOCKET CUDTUnited::accept(const SRTSOCKET listen, sockaddr* pw_addr, int* pw_
throw CUDTException(MJ_SETUP, MN_CLOSED, 0);
}

if (pw_addr != NULL && pw_addrlen != NULL)
{
CUDTSocket* s = locateSocket(u);
if (s == NULL)
throw CUDTException(MJ_SETUP, MN_CLOSED, 0);

// Check if LISTENER has the SRTO_GROUPCONNECT flag set,
// and the already accepted socket has successfully joined
// the mirror group. If so, RETURN THE GROUP ID, not the socket ID.
if (ls->m_pUDT->m_OPT_GroupConnect == 1 && s->m_IncludedGroup)
{
u = s->m_IncludedGroup->m_GroupID;
s->core().m_OPT_GroupConnect = 1; // should be derived from ls, but make sure
}
else
{
// Set properly the SRTO_GROUPCONNECT flag
s->core().m_OPT_GroupConnect = 0;
}
CUDTSocket* s = locateSocket(u);
if (s == NULL)
throw CUDTException(MJ_SETUP, MN_CLOSED, 0);

ScopedLock cg(s->m_ControlLock);
// Check if LISTENER has the SRTO_GROUPCONNECT flag set,
// and the already accepted socket has successfully joined
// the mirror group. If so, RETURN THE GROUP ID, not the socket ID.
if (ls->m_pUDT->m_OPT_GroupConnect == 1 && s->m_IncludedGroup)
{
u = s->m_IncludedGroup->m_GroupID;
s->core().m_OPT_GroupConnect = 1; // should be derived from ls, but make sure
}
else
{
// Set properly the SRTO_GROUPCONNECT flag
s->core().m_OPT_GroupConnect = 0;
}

ScopedLock cg(s->m_ControlLock);

if (pw_addr != NULL && pw_addrlen != NULL)
{
// Check if the length of the buffer to fill the name in
// was large enough.
const int len = s->m_PeerAddr.size();
Expand Down

0 comments on commit c576662

Please sign in to comment.