Skip to content

Commit

Permalink
[core] Run the accept hook before opening caller's socket
Browse files Browse the repository at this point in the history
In listener mode, open the socket created for a connecting caller only
after its accept hook has been run. This gives the hook an opportunity
to set some 'pre' options (like SRTO_RCVBUF) on the socket before it
gets passed to srt_accept().
  • Loading branch information
xhaakon authored and maxsharabayko committed Jan 14, 2021
1 parent dccaf76 commit 6e78ecb
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions srtcore/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -627,9 +627,6 @@ int CUDTUnited::newConnection(const SRTSOCKET listen, const sockaddr_any& peer,
m_Sockets[ns->m_SocketID] = ns;
}

// bind to the same addr of listening socket
ns->m_pUDT->open();
updateListenerMux(ns, ls);
if (ls->m_pUDT->m_cbAcceptHook)
{
if (!ls->m_pUDT->runAcceptHook(ns->m_pUDT, peer.get(), w_hs, hspkt))
Expand All @@ -640,6 +637,11 @@ int CUDTUnited::newConnection(const SRTSOCKET listen, const sockaddr_any& peer,
goto ERR_ROLLBACK;
}
}

// bind to the same addr of listening socket
ns->m_pUDT->open();
updateListenerMux(ns, ls);

ns->m_pUDT->acceptAndRespond(ls->m_SelfAddr, peer, hspkt, (w_hs));
}
catch (...)
Expand Down

0 comments on commit 6e78ecb

Please sign in to comment.