mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-23 19:20:41 +00:00
router: on linux add a mutex around the queue (#6709)
UDP reception happens on an other thread, avoid data races and potential data corruption issues.
This commit is contained in:
@@ -8,6 +8,9 @@
|
||||
#include "PointerQueue.h"
|
||||
#include "RadioInterface.h"
|
||||
#include "concurrency/OSThread.h"
|
||||
#ifdef ARCH_PORTDUINO
|
||||
#include <mutex>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* A mesh aware router that supports multiple interfaces.
|
||||
@@ -19,6 +22,12 @@ class Router : protected concurrency::OSThread, protected PacketHistory
|
||||
/// forwarded to the phone.
|
||||
PointerQueue<meshtastic_MeshPacket> fromRadioQueue;
|
||||
|
||||
#ifdef ARCH_PORTDUINO
|
||||
/// linux calls enqueueReceivedMessage from an other thread when receiving UDP packets,
|
||||
/// to avoid a data race with LoRa, lock that method.
|
||||
std::mutex queueMutex;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
RadioInterface *iface = NULL;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user