Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Catch exception from connect_complete. #980

Merged
merged 2 commits into from
Nov 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions srtcore/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -930,21 +930,6 @@ int CUDTUnited::connect(const SRTSOCKET u, const sockaddr* name, int namelen, in
return 0;
}

void CUDTUnited::connect_complete(const SRTSOCKET u)
{
CUDTSocket* s = locate(u);
if (!s)
throw CUDTException(MJ_NOTSUP, MN_SIDINVAL, 0);

// copy address information of local node
// the local port must be correctly assigned BEFORE CUDT::startConnect(),
// otherwise if startConnect() fails, the multiplexer cannot be located
// by garbage collection and will cause leak
s->m_pUDT->m_pSndQueue->m_pChannel->getSockAddr(s->m_pSelfAddr);
CIPAddress::pton(s->m_pSelfAddr, s->m_pUDT->m_piSelfIP, s->m_iIPversion);

s->m_Status = SRTS_CONNECTED;
}

int CUDTUnited::close(const SRTSOCKET u)
{
Expand Down
1 change: 0 additions & 1 deletion srtcore/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ friend class CRendezvousQueue;
static void TLSDestroy(void* e) {if (NULL != e) delete (CUDTException*)e;}

private:
void connect_complete(const SRTSOCKET u);
CUDTSocket* locate(const SRTSOCKET u);
CUDTSocket* locate(const sockaddr* peer, const SRTSOCKET id, int32_t isn);
void updateMux(CUDTSocket* s, const sockaddr* addr = NULL, const UDPSOCKET* = NULL);
Expand Down
21 changes: 20 additions & 1 deletion srtcore/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4321,7 +4321,26 @@ EConnectStatus CUDT::postConnect(const CPacket &response, bool rendezvous, CUDTE
m_pRcvQueue->removeConnector(m_SocketID, synchro);

// acknowledge the management module.
s_UDTUnited.connect_complete(m_SocketID);
CUDTSocket* s = s_UDTUnited.locate(m_SocketID);
if (!s)
{
if (eout)
{
*eout = CUDTException(MJ_NOTSUP, MN_SIDINVAL, 0);
}

m_RejectReason = SRT_REJ_CLOSE;
return CONN_REJECT;
}

// copy address information of local node
// the local port must be correctly assigned BEFORE CUDT::startConnect(),
// otherwise if startConnect() fails, the multiplexer cannot be located
// by garbage collection and will cause leak
s->m_pUDT->m_pSndQueue->m_pChannel->getSockAddr(s->m_pSelfAddr);
CIPAddress::pton(s->m_pSelfAddr, s->m_pUDT->m_piSelfIP, s->m_iIPversion);

s->m_Status = SRTS_CONNECTED;

// acknowledde any waiting epolls to write
s_UDTUnited.m_EPoll.update_events(m_SocketID, m_sPollID, UDT_EPOLL_OUT, true);
Expand Down