better loging of failed OpenStream

unstable
Tom Early 4 years ago
parent eb16567323
commit 7f81e70233

@ -128,15 +128,12 @@ void CM17Protocol::Task(void)
} }
else if ( IsValidKeepAlivePacket(Buffer, Callsign) ) else if ( IsValidKeepAlivePacket(Buffer, Callsign) )
{ {
std::cout << "M17 keepalive packet from " << Callsign << " at " << Ip << std::endl;
// find all clients with that callsign & ip and keep them alive // find all clients with that callsign & ip and keep them alive
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
auto it = clients->begin(); auto it = clients->begin();
std::shared_ptr<CClient>client = nullptr; std::shared_ptr<CClient>client = nullptr;
while ( (client = clients->FindNextClient(Callsign, Ip, EProtocol::m17, it)) != nullptr ) while ( (client = clients->FindNextClient(Callsign, Ip, EProtocol::m17, it)) != nullptr )
{ {
std::cout << "marking " << Callsign << " @ " << Ip << " Alive!" << std::endl;
client->Alive(); client->Alive();
} }
g_Reflector.ReleaseClients(); g_Reflector.ReleaseClients();

@ -156,11 +156,22 @@ std::shared_ptr<CPacketStream> CReflector::OpenStream(std::unique_ptr<CDvHeaderP
{ {
// check sid is not zero // check sid is not zero
if ( 0U == DvHeader->GetStreamId() ) if ( 0U == DvHeader->GetStreamId() )
{
std::cerr << "StreamId for client " << client->GetCallsign() << " is zero!" << std::endl;
return nullptr; return nullptr;
}
// check if client is valid candidate // check if client is valid candidate
if ( ! m_Clients.IsClient(client) || client->IsAMaster() ) if ( ! m_Clients.IsClient(client) )
{
std::cerr << "Client " << client->GetCallsign() << " is not a client!" << std::endl;
return nullptr; return nullptr;
}
if ( client->IsAMaster() )
{
std::cerr << "Client " << client->GetCallsign() << " is already a master!" << std::endl;
return nullptr;
}
// check if no stream with same streamid already open // check if no stream with same streamid already open
// to prevent loops // to prevent loops
@ -174,7 +185,10 @@ std::shared_ptr<CPacketStream> CReflector::OpenStream(std::unique_ptr<CDvHeaderP
char module = DvHeader->GetModule(); char module = DvHeader->GetModule();
auto stream = GetStream(module); auto stream = GetStream(module);
if ( stream == nullptr ) if ( stream == nullptr )
{
std::cerr << "Can't find module '" << module << "' for Client " << client->GetCallsign() << std::endl;
return nullptr; return nullptr;
}
stream->Lock(); stream->Lock();
// is it available ? // is it available ?

Loading…
Cancel
Save

Powered by TurnKey Linux.