Browse Source

fixed possible crash at shutdown

pull/2094/merge
orignal 3 days ago
parent
commit
3995448014
  1. 7
      libi2pd/Transports.cpp
  2. 2
      libi2pd/Transports.h

7
libi2pd/Transports.cpp

@ -55,6 +55,13 @@ namespace transport
m_Thread->join (); m_Thread->join ();
m_Thread = nullptr; m_Thread = nullptr;
} }
if (!m_Queue.empty ())
{
// clean up queue
std::queue<std::shared_ptr<Keys> > tmp;
std::swap (m_Queue, tmp);
}
m_KeysPool.CleanUpMt ();
} }
template<typename Keys> template<typename Keys>

2
libi2pd/Transports.h

@ -54,8 +54,8 @@ namespace transport
private: private:
const int m_QueueSize; const int m_QueueSize;
std::queue<std::shared_ptr<Keys> > m_Queue;
i2p::util::MemoryPoolMt<Keys> m_KeysPool; i2p::util::MemoryPoolMt<Keys> m_KeysPool;
std::queue<std::shared_ptr<Keys> > m_Queue;
bool m_IsRunning; bool m_IsRunning;
std::unique_ptr<std::thread> m_Thread; std::unique_ptr<std::thread> m_Thread;

Loading…
Cancel
Save