From 7fa9f05d2cbdf1d821f479248d561f9868051b8b Mon Sep 17 00:00:00 2001 From: nns779 <25547272+nns779@users.noreply.github.com> Date: Thu, 9 Sep 2021 21:24:23 +0900 Subject: [PATCH] =?UTF-8?q?winusb:=20DriverHost=5FPX4:=20cfe0712=20?= =?UTF-8?q?=E3=81=AE=E5=A4=89=E6=9B=B4=E3=81=AB=E3=82=88=E3=82=8B=E3=83=90?= =?UTF-8?q?=E3=82=B0=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit チューナーがまったく開けなくなってしまったので修正 --- winusb/src/DriverHost_PX4/receiver_manager.cpp | 4 +--- winusb/src/DriverHost_PX4/receiver_manager.hpp | 3 ++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/winusb/src/DriverHost_PX4/receiver_manager.cpp b/winusb/src/DriverHost_PX4/receiver_manager.cpp index 611d629..1e2e505 100644 --- a/winusb/src/DriverHost_PX4/receiver_manager.cpp +++ b/winusb/src/DriverHost_PX4/receiver_manager.cpp @@ -32,7 +32,7 @@ static GUID empty_guid = { 0 }; px4::ReceiverBase* ReceiverManager::SearchAndOpen(px4::command::ReceiverInfo &key, px4::command::ReceiverInfo &info, std::uint32_t &data_id) { - std::shared_lock lock(mtx_); + std::lock_guard lock(mtx_); for (auto it = data_.cbegin(); it != data_.cend(); ++it) { const px4::command::ReceiverInfo& k = it->second.info; @@ -93,8 +93,6 @@ px4::ReceiverBase* ReceiverManager::SearchByDataId(std::uint32_t data_id) bool ReceiverManager::GenerateDataId(px4::ReceiverBase *receiver, std::uint32_t &data_id) { - std::lock_guard lock(mtx_); - if (!data_.count(receiver)) return false; diff --git a/winusb/src/DriverHost_PX4/receiver_manager.hpp b/winusb/src/DriverHost_PX4/receiver_manager.hpp index d062791..f553bea 100644 --- a/winusb/src/DriverHost_PX4/receiver_manager.hpp +++ b/winusb/src/DriverHost_PX4/receiver_manager.hpp @@ -27,7 +27,6 @@ class ReceiverManager final { bool Unregister(px4::ReceiverBase *receiver); px4::ReceiverBase* SearchAndOpen(px4::command::ReceiverInfo &key, px4::command::ReceiverInfo &info, std::uint32_t &data_id); px4::ReceiverBase* SearchByDataId(std::uint32_t data_id); - bool GenerateDataId(px4::ReceiverBase *receiver, std::uint32_t &data_id); void ClearDataId(px4::ReceiverBase *receiver); private: @@ -36,6 +35,8 @@ class ReceiverManager final { bool valid_data_id; }; + bool GenerateDataId(px4::ReceiverBase *receiver, std::uint32_t &data_id); + std::shared_mutex mtx_; std::unordered_map data_; };