mirror of
https://gitee.com/xiaohuolufeihua/bizhang_-obav.git
synced 2026-05-22 09:28:58 +00:00
orb: rm static from DeviceMaster::_node_map & use the non-static getDeviceNode in uORB::Manager
Reasons: - DeviceMaster::_node_map does not need to be shared among instances, because there is at most 1 instance per Flavor and different Flavors have non-intersecting device paths. - Keeping it static would also require a static lock - DeviceMaster::_node_map was not locked at all when used from uORB::Manager So this fixes two synchronization issues: - Different DeviceMaster objects could access the same static data in parallel - getDeviceNode() called from uORB::Manager did not use any locking at all
This commit is contained in:
@@ -450,10 +450,10 @@ int16_t uORB::Manager::process_add_subscription(const char *messageName,
|
||||
_remote_subscriber_topics.insert(messageName);
|
||||
char nodepath[orb_maxpath];
|
||||
int ret = uORB::Utils::node_mkpath(nodepath, PUBSUB, messageName);
|
||||
DeviceMaster *device_master = get_device_master(PUBSUB);
|
||||
|
||||
if (ret == OK) {
|
||||
// get the node name.
|
||||
uORB::DeviceNode *node = uORB::DeviceMaster::GetDeviceNode(nodepath);
|
||||
if (ret == OK && device_master) {
|
||||
uORB::DeviceNode *node = device_master->getDeviceNode(nodepath);
|
||||
|
||||
if (node == nullptr) {
|
||||
PX4_DEBUG("[posix-uORB::Manager::process_add_subscription(%d)]DeviceNode(%s) not created yet",
|
||||
@@ -482,9 +482,10 @@ int16_t uORB::Manager::process_remove_subscription(
|
||||
_remote_subscriber_topics.erase(messageName);
|
||||
char nodepath[orb_maxpath];
|
||||
int ret = uORB::Utils::node_mkpath(nodepath, PUBSUB, messageName);
|
||||
DeviceMaster *device_master = get_device_master(PUBSUB);
|
||||
|
||||
if (ret == OK) {
|
||||
uORB::DeviceNode *node = uORB::DeviceMaster::GetDeviceNode(nodepath);
|
||||
if (ret == OK && device_master) {
|
||||
uORB::DeviceNode *node = device_master->getDeviceNode(nodepath);
|
||||
|
||||
// get the node name.
|
||||
if (node == nullptr) {
|
||||
@@ -511,9 +512,10 @@ int16_t uORB::Manager::process_received_message(const char *messageName,
|
||||
int16_t rc = -1;
|
||||
char nodepath[orb_maxpath];
|
||||
int ret = uORB::Utils::node_mkpath(nodepath, PUBSUB, messageName);
|
||||
DeviceMaster *device_master = get_device_master(PUBSUB);
|
||||
|
||||
if (ret == OK) {
|
||||
uORB::DeviceNode *node = uORB::DeviceMaster::GetDeviceNode(nodepath);
|
||||
if (ret == OK && device_master) {
|
||||
uORB::DeviceNode *node = device_master->getDeviceNode(nodepath);
|
||||
|
||||
// get the node name.
|
||||
if (node == nullptr) {
|
||||
|
||||
Reference in New Issue
Block a user