mirror of
https://github.com/tsukumijima/px4_drv.git
synced 2025-07-23 20:20:36 +02:00
winusb: DriverHost_PX4: チューナーオープン処理のバグを修正
同じチューナーを何度も開こうとして無限ループに陥ることのあるバグを修正 https://mevius.5ch.net/test/read.cgi/avi/1629554684/129 https://mevius.5ch.net/test/read.cgi/avi/1629554684/131
This commit is contained in:
@@ -62,25 +62,12 @@ void CtrlServer::CtrlConnection::Worker() noexcept
|
|||||||
}
|
}
|
||||||
|
|
||||||
px4::command::CtrlOpenCmd *open = reinterpret_cast<px4::command::CtrlOpenCmd *>(buf.get());
|
px4::command::CtrlOpenCmd *open = reinterpret_cast<px4::command::CtrlOpenCmd *>(buf.get());
|
||||||
|
std::uint32_t data_id;
|
||||||
|
|
||||||
while (true) {
|
receiver = receiver_manager_.SearchAndOpen(open->receiver_info, info, data_id);
|
||||||
receiver = receiver_manager_.Search(open->receiver_info, info);
|
if (receiver) {
|
||||||
if (!receiver)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (receiver->Open())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
std::uint32_t data_id;
|
|
||||||
|
|
||||||
if (!receiver_manager_.GenerateDataId(receiver, data_id)) {
|
|
||||||
receiver->Close();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
open->receiver_info = info;
|
open->receiver_info = info;
|
||||||
open->receiver_info.data_id = data_id;
|
open->receiver_info.data_id = data_id;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
open->status = (receiver) ? px4::command::CtrlStatusCode::SUCCEEDED : px4::command::CtrlStatusCode::FAILED;
|
open->status = (receiver) ? px4::command::CtrlStatusCode::SUCCEEDED : px4::command::CtrlStatusCode::FAILED;
|
||||||
|
@@ -30,7 +30,7 @@ bool ReceiverManager::Unregister(px4::ReceiverBase *receiver)
|
|||||||
|
|
||||||
static GUID empty_guid = { 0 };
|
static GUID empty_guid = { 0 };
|
||||||
|
|
||||||
px4::ReceiverBase* ReceiverManager::Search(px4::command::ReceiverInfo &key, px4::command::ReceiverInfo &info)
|
px4::ReceiverBase* ReceiverManager::SearchAndOpen(px4::command::ReceiverInfo &key, px4::command::ReceiverInfo &info, std::uint32_t &data_id)
|
||||||
{
|
{
|
||||||
std::shared_lock<std::shared_mutex> lock(mtx_);
|
std::shared_lock<std::shared_mutex> lock(mtx_);
|
||||||
|
|
||||||
@@ -58,9 +58,19 @@ px4::ReceiverBase* ReceiverManager::Search(px4::command::ReceiverInfo &key, px4:
|
|||||||
if ((key.index >= 0) && (key.index != k.index))
|
if ((key.index >= 0) && (key.index != k.index))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
px4::ReceiverBase *r = it->first;
|
||||||
|
|
||||||
|
if (r->Open())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!GenerateDataId(r, data_id)) {
|
||||||
|
r->Close();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
info = k;
|
info = k;
|
||||||
|
|
||||||
return it->first;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@@ -25,7 +25,7 @@ public:
|
|||||||
|
|
||||||
bool Register(px4::command::ReceiverInfo &info, px4::ReceiverBase *receiver);
|
bool Register(px4::command::ReceiverInfo &info, px4::ReceiverBase *receiver);
|
||||||
bool Unregister(px4::ReceiverBase *receiver);
|
bool Unregister(px4::ReceiverBase *receiver);
|
||||||
px4::ReceiverBase* Search(px4::command::ReceiverInfo &key, px4::command::ReceiverInfo &info);
|
px4::ReceiverBase* SearchAndOpen(px4::command::ReceiverInfo &key, px4::command::ReceiverInfo &info, std::uint32_t &data_id);
|
||||||
px4::ReceiverBase* SearchByDataId(std::uint32_t data_id);
|
px4::ReceiverBase* SearchByDataId(std::uint32_t data_id);
|
||||||
bool GenerateDataId(px4::ReceiverBase *receiver, std::uint32_t &data_id);
|
bool GenerateDataId(px4::ReceiverBase *receiver, std::uint32_t &data_id);
|
||||||
void ClearDataId(px4::ReceiverBase *receiver);
|
void ClearDataId(px4::ReceiverBase *receiver);
|
||||||
|
Reference in New Issue
Block a user