Skip to content

Commit

Permalink
fixed possible crash at shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
orignal committed Dec 19, 2024
1 parent 7497741 commit 3995448
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions libi2pd/Transports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ namespace transport
m_Thread->join ();
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>
Expand Down
2 changes: 1 addition & 1 deletion libi2pd/Transports.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ namespace transport
private:

const int m_QueueSize;
std::queue<std::shared_ptr<Keys> > m_Queue;
i2p::util::MemoryPoolMt<Keys> m_KeysPool;
std::queue<std::shared_ptr<Keys> > m_Queue;

bool m_IsRunning;
std::unique_ptr<std::thread> m_Thread;
Expand Down

0 comments on commit 3995448

Please sign in to comment.