Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions include/Hdlcpp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,8 @@ class Hdlcpp {

int writeFrame(TransportAddress address, Frame frame, uint8_t sequenceNumber, ConstContainer data)
{
std::lock_guard<std::mutex> writeLock(writeFrameMutex);

int result;

if ((result = encode(address, frame, sequenceNumber, data, { writeBuffer })) < 0)
Expand Down Expand Up @@ -550,7 +552,11 @@ class Hdlcpp {
static constexpr uint8_t FlagSequence = 0x7e;
static constexpr uint8_t ControlEscape = 0x7d;

// Whenever writeMutex and writeFrameMutex both needs to be locked from the
// same thread, writeMutex must be locked first.
std::mutex writeMutex;
std::mutex writeFrameMutex;

TransportRead transportRead;
TransportWrite transportWrite;
Buffer<uint8_t> readBuffer;
Expand Down