exclude garlic thread

This commit is contained in:
orignal 2014-10-08 07:55:46 -04:00
parent 002ccdf2c7
commit 296b2d7372
4 changed files with 5 additions and 90 deletions

View file

@ -472,64 +472,5 @@ namespace garlic
}
DeleteI2NPMessage (msg);
}
GarlicRouting routing;
void GarlicRouting::HandleGarlicMessage (I2NPMessage * msg)
{
auto pool = msg->from ? msg->from->GetTunnelPool () : nullptr;
if (pool)
pool->GetGarlicDestination ().HandleGarlicMessage (msg);
else
{
LogPrint ("Local destination doesn't exist");
DeleteI2NPMessage (msg);
}
}
void GarlicRouting::Start ()
{
m_IsRunning = true;
m_Thread = new std::thread (std::bind (&GarlicRouting::Run, this));
}
void GarlicRouting::Stop ()
{
m_IsRunning = false;
m_Queue.WakeUp ();
if (m_Thread)
{
m_Thread->join ();
delete m_Thread;
m_Thread = 0;
}
}
void GarlicRouting::PostI2NPMsg (I2NPMessage * msg)
{
if (msg) m_Queue.Put (msg);
}
void GarlicRouting::Run ()
{
while (m_IsRunning)
{
try
{
I2NPMessage * msg = m_Queue.GetNext ();
if (msg->GetHeader ()->typeID == eI2NPGarlic)
HandleGarlicMessage (msg);
else
{
LogPrint ("Garlic: unexpected message type ", msg->GetHeader ()->typeID);
i2p::HandleI2NPMessage (msg);
}
}
catch (std::exception& ex)
{
LogPrint ("GarlicRouting: ", ex.what ());
}
}
}
}
}