mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-28 11:47:48 +02:00
exclude garlic thread
This commit is contained in:
parent
002ccdf2c7
commit
296b2d7372
4 changed files with 5 additions and 90 deletions
59
Garlic.cpp
59
Garlic.cpp
|
@ -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 ());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue