Skip to content

Commit

Permalink
fix issue with potentional concurrency crash when updating lookup tab…
Browse files Browse the repository at this point in the history
…les in PEER_LINK;
  • Loading branch information
gatekeep committed Jan 17, 2025
1 parent a82f848 commit 3b395a9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/common/Thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ bool Thread::run()

void Thread::wait()
{
if (!m_started)
return;
#if defined(_WIN32)
::WaitForSingleObject(m_thread, INFINITE);
::CloseHandle(m_thread);
Expand Down
6 changes: 6 additions & 0 deletions src/common/lookups/LookupTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ namespace lookups
*/
void filename(std::string filename) { m_filename = filename; };

/**
* @brief Helper to set the reload time of this lookup table.
* @param reloadTime Lookup time in seconds.
*/
void setReloadTime(uint32_t reloadTime) { m_reloadTime = 0U; }

protected:
std::string m_filename;
uint32_t m_reloadTime;
Expand Down
6 changes: 6 additions & 0 deletions src/common/lookups/TalkgroupRulesLookup.h
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,12 @@ namespace lookups
*/
void filename(std::string filename) { m_rulesFile = filename; };

/**
* @brief Helper to set the reload time of this lookup table.
* @param reloadTime Lookup time in seconds.
*/
void setReloadTime(uint32_t reloadTime) { m_reloadTime = 0U; }

private:
std::string m_rulesFile;
uint32_t m_reloadTime;
Expand Down
3 changes: 3 additions & 0 deletions src/fne/network/PeerNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ void PeerNetwork::userPacketHandler(uint32_t peerId, FrameQueue::OpcodePair opco
file.close();

m_tidLookup->stop(true);
m_tidLookup->setReloadTime(0U);
m_tidLookup->filename(filename);
m_tidLookup->reload();

Expand Down Expand Up @@ -359,6 +360,7 @@ void PeerNetwork::userPacketHandler(uint32_t peerId, FrameQueue::OpcodePair opco
file.close();

m_ridLookup->stop(true);
m_ridLookup->setReloadTime(0U);
m_ridLookup->filename(filename);
m_ridLookup->reload();

Expand Down Expand Up @@ -496,6 +498,7 @@ void PeerNetwork::userPacketHandler(uint32_t peerId, FrameQueue::OpcodePair opco
file.close();

m_pidLookup->stop(true);
m_pidLookup->setReloadTime(0U);
m_pidLookup->filename(filename);
m_pidLookup->reload();

Expand Down

0 comments on commit 3b395a9

Please sign in to comment.