Skip to content

Commit

Permalink
Refs #21054: Apply Miguel suggestion
Browse files Browse the repository at this point in the history
Signed-off-by: Mario Dominguez <[email protected]>
  • Loading branch information
Mario-DL committed Jun 7, 2024
1 parent 0b5b994 commit 1c35ef6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion include/fastrtps/xmlparser/XMLParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ class XMLParser
private:

static std::mutex collections_mtx_;
static std::vector<std::string> flow_controller_descriptor_names_;
static std::set<std::string> flow_controller_descriptor_names_;
};

} // namespace xmlparser
Expand Down
20 changes: 11 additions & 9 deletions src/cpp/rtps/xmlparser/XMLElementParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ namespace fastrtps {
namespace xmlparser {

std::mutex XMLParser::collections_mtx_;
std::vector<std::string> XMLParser::flow_controller_descriptor_names_;
std::set<std::string> XMLParser::flow_controller_descriptor_names_;

using namespace eprosima::fastrtps::rtps;
using namespace eprosima::fastdds::xml::detail;
Expand Down Expand Up @@ -1058,13 +1058,14 @@ XMLP_ret XMLParser::getXMLFlowControllerDescriptorList(
{
std::lock_guard<std::mutex> lock(collections_mtx_);
// name - stringType
flow_controller_descriptor_names_.emplace_back(get_element_text(p_aux1));
flow_controller_descriptor->name = flow_controller_descriptor_names_.back().c_str();
if (flow_controller_descriptor_names_.back().empty())
auto element_inserted = flow_controller_descriptor_names_.insert(get_element_text(p_aux1));
if (element_inserted.first == flow_controller_descriptor_names_.end() ||
element_inserted.first->empty())
{
EPROSIMA_LOG_ERROR(XMLPARSER, "<" << p_aux1->Value() << "> getXMLString XML_ERROR!");
EPROSIMA_LOG_ERROR(XMLPARSER, "Node flow controller node '" << NAME << "' invalid");
return XMLP_ret::XML_ERROR;
}
flow_controller_descriptor->name = element_inserted.first->c_str();
name_defined = true;
}
else if (strcmp(name, SCHEDULER) == 0)
Expand Down Expand Up @@ -2845,13 +2846,14 @@ XMLP_ret XMLParser::getXMLPublishModeQos(
else if (strcmp(name, FLOW_CONTROLLER_NAME) == 0)
{
std::lock_guard<std::mutex> lock(collections_mtx_);
flow_controller_descriptor_names_.emplace_back(get_element_text(p_aux0));
publishMode.flow_controller_name = flow_controller_descriptor_names_.back().c_str();
if (flow_controller_descriptor_names_.back().empty())
auto element_inserted = flow_controller_descriptor_names_.insert(get_element_text(p_aux0));
if (element_inserted.first == flow_controller_descriptor_names_.end() ||
element_inserted.first->empty())
{
EPROSIMA_LOG_ERROR(XMLPARSER, "Node '" << FLOW_CONTROLLER_NAME << "' without content");
EPROSIMA_LOG_ERROR(XMLPARSER, "Node '" << FLOW_CONTROLLER_NAME << "' invalid");
return XMLP_ret::XML_ERROR;
}
publishMode.flow_controller_name = element_inserted.first->c_str();
}
else
{
Expand Down

0 comments on commit 1c35ef6

Please sign in to comment.