Skip to content

Commit

Permalink
core: add missing locks in command queue
Browse files Browse the repository at this point in the history
  • Loading branch information
julianoes committed Nov 11, 2024
1 parent 6a93d83 commit 54db792
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions src/mavsdk/core/mavlink_command_sender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,16 @@ void MavlinkCommandSender::queue_command_async(

CommandIdentification identification = identification_from_command(command);

for (const auto& work : _work_queue) {
if (work->identification == identification && callback == nullptr) {
if (_command_debugging) {
LogDebug() << "Dropping command " << static_cast<int>(identification.command)
<< " that is already being sent";
{
LockedQueue<Work>::Guard work_queue_guard(_work_queue);
for (const auto& work : _work_queue) {
if (work->identification == identification && callback == nullptr) {
if (_command_debugging) {
LogDebug() << "Dropping command " << static_cast<int>(identification.command)
<< " that is already being sent";
}
return;
}
return;
}
}

Expand All @@ -117,13 +120,16 @@ void MavlinkCommandSender::queue_command_async(

CommandIdentification identification = identification_from_command(command);

for (const auto& work : _work_queue) {
if (work->identification == identification && callback == nullptr) {
if (_command_debugging) {
LogDebug() << "Dropping command " << static_cast<int>(identification.command)
<< " that is already being sent";
{
LockedQueue<Work>::Guard work_queue_guard(_work_queue);
for (const auto& work : _work_queue) {
if (work->identification == identification && callback == nullptr) {
if (_command_debugging) {
LogDebug() << "Dropping command " << static_cast<int>(identification.command)
<< " that is already being sent";
}
return;
}
return;
}
}

Expand Down

0 comments on commit 54db792

Please sign in to comment.