Skip to content

Commit

Permalink
[core] Minor connection logging improvement (Haivision#2930).
Browse files Browse the repository at this point in the history
Also downgraded some logs from 'note' level to 'debug'.
  • Loading branch information
maxsharabayko committed Apr 26, 2024
1 parent fa60e2b commit 1cdae55
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
3 changes: 3 additions & 0 deletions srtcore/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,9 @@ int srt::CUDTUnited::newConnection(const SRTSOCKET listen,
HLOGC(cnlog.Debug, log << "newConnection: mapping peer " << ns->m_PeerID
<< " to that socket (" << ns->m_SocketID << ")");
m_PeerRec[ns->getPeerSpec()].insert(ns->m_SocketID);

LOGC(cnlog.Note, log << "@" << ns->m_SocketID << " connection on listener @" << listen
<< " (" << ns->m_SelfAddr.str() << ") from peer @" << ns->m_PeerID << " (" << peer.str() << ")");
}
catch (...)
{
Expand Down
13 changes: 7 additions & 6 deletions srtcore/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2092,9 +2092,9 @@ int srt::CUDT::processSrtMsg_HSREQ(const uint32_t *srtdata, size_t bytelen, uint
return SRT_CMD_NONE;
}

LOGC(cnlog.Note, log << "HSREQ/rcv: cmd=" << SRT_CMD_HSREQ << "(HSREQ) len=" << bytelen
<< hex << " vers=0x" << srtdata[SRT_HS_VERSION] << " opts=0x" << srtdata[SRT_HS_FLAGS]
<< dec << " delay=" << SRT_HS_LATENCY_RCV::unwrap(srtdata[SRT_HS_LATENCY]));
LOGC(cnlog.Debug, log << "HSREQ/rcv: cmd=" << SRT_CMD_HSREQ << "(HSREQ) len=" << bytelen
<< hex << " vers=0x" << srtdata[SRT_HS_VERSION] << " opts=0x" << srtdata[SRT_HS_FLAGS]
<< dec << " delay=" << SRT_HS_LATENCY_RCV::unwrap(srtdata[SRT_HS_LATENCY]));

m_uPeerSrtVersion = srtdata[SRT_HS_VERSION];
m_uPeerSrtFlags = srtdata[SRT_HS_FLAGS];
Expand Down Expand Up @@ -4938,8 +4938,9 @@ EConnectStatus srt::CUDT::postConnect(const CPacket* pResponse, bool rendezvous,
}

*/

LOGC(cnlog.Note, log << CONID() << "Connection established to: " << m_PeerAddr.str());

LOGC(cnlog.Note, log << CONID() << "Connection established from ("
<< m_SourceAddr.str() << ") to peer @" << m_PeerID << " (" << m_PeerAddr.str() << ")");

return CONN_ACCEPT;
}
Expand Down Expand Up @@ -11209,7 +11210,7 @@ int srt::CUDT::processConnectRequest(const sockaddr_any& addr, CPacket& packet)
}
}
}
LOGC(cnlog.Note, log << CONID() << "listen ret: " << hs.m_iReqType << " - " << RequestTypeStr(hs.m_iReqType));
LOGC(cnlog.Debug, log << CONID() << "listen ret: " << hs.m_iReqType << " - " << RequestTypeStr(hs.m_iReqType));

return RejectReasonForURQ(hs.m_iReqType);
}
Expand Down
6 changes: 3 additions & 3 deletions srtcore/queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1407,7 +1407,7 @@ srt::EConnectStatus srt::CRcvQueue::worker_ProcessConnectionRequest(CUnit* unit,
ScopedLock cg(m_LSLock);
if (m_pListener)
{
LOGC(cnlog.Note, log << "PASSING request from: " << addr.str() << " to agent:" << m_pListener->socketID());
LOGC(cnlog.Debug, log << "PASSING request from: " << addr.str() << " to listener:" << m_pListener->socketID());
listener_ret = m_pListener->processConnectRequest(addr, unit->m_Packet);

// This function does return a code, but it's hard to say as to whether
Expand All @@ -1426,8 +1426,8 @@ srt::EConnectStatus srt::CRcvQueue::worker_ProcessConnectionRequest(CUnit* unit,

if (have_listener) // That is, the above block with m_pListener->processConnectRequest was executed
{
LOGC(cnlog.Note,
log << CONID() << "Listener managed the connection request from: " << addr.str()
LOGC(cnlog.Debug,
log << CONID() << "Listener got the connection request from: " << addr.str()
<< " result:" << RequestTypeStr(UDTRequestType(listener_ret)));
return listener_ret == SRT_REJ_UNKNOWN ? CONN_CONTINUE : CONN_REJECT;
}
Expand Down

0 comments on commit 1cdae55

Please sign in to comment.