diff --git a/include/fastdds/dds/core/policy/ParameterTypes.hpp b/include/fastdds/dds/core/policy/ParameterTypes.hpp index f00bba995b7..79610f18f60 100644 --- a/include/fastdds/dds/core/policy/ParameterTypes.hpp +++ b/include/fastdds/dds/core/policy/ParameterTypes.hpp @@ -1301,27 +1301,25 @@ class ParameterPropertyList_t : public Parameter_t bool push_back( std::pair p) { - //Realloc if needed; - uint32_t size1 = (uint32_t) p.first.length() + 1; - uint32_t alignment1 = ((size1 + 3u) & ~3u) - size1; - - uint32_t size2 = (uint32_t) p.second.length() + 1; - uint32_t alignment2 = ((size2 + 3u) & ~3u) - size2; + return push_back(p.first, p.second); + } - if (limit_size_ && (properties_.max_size < properties_.length + - size1 + alignment1 + 4 + - size2 + alignment2 + 4)) - { - return false; - } - properties_.reserve(properties_.length + - size1 + alignment1 + 4 + - size2 + alignment2 + 4); + /** + * @brief Introduce a new property in the ParameterPropertyList + * @param key Key part of the new property + * @param value Value part of the new property + * @return true if it is introduced, false if not. + */ + bool push_back( + const std::string& key, + const std::string& value) + { + auto str1 = reinterpret_cast(key.c_str()); + uint32_t size1 = (uint32_t) key.length() + 1; + auto str2 = reinterpret_cast(value.c_str()); + uint32_t size2 = (uint32_t) value.length() + 1; - push_back_helper((fastrtps::rtps::octet*)p.first.c_str(), size1, alignment1); - push_back_helper((fastrtps::rtps::octet*)p.second.c_str(), size2, alignment2); - ++Nproperties_; - return true; + return push_back(str1, size1, str2, size2); } /** @@ -1636,7 +1634,7 @@ void set_proxy_property( else { // if not exists add - properties.push_back(pair); + properties.push_back(pair.first, pair.second); } } diff --git a/src/cpp/rtps/DataSharing/DataSharingListener.cpp b/src/cpp/rtps/DataSharing/DataSharingListener.cpp index 6fe3f61c690..858178da28b 100644 --- a/src/cpp/rtps/DataSharing/DataSharingListener.cpp +++ b/src/cpp/rtps/DataSharing/DataSharingListener.cpp @@ -79,6 +79,8 @@ void DataSharingListener::run() void DataSharingListener::start() { + std::lock_guard guard(mutex_); + // Check the thread bool was_running = is_running_.exchange(true); if (was_running) @@ -92,17 +94,26 @@ void DataSharingListener::start() void DataSharingListener::stop() { - // Notify the listening thread that is no longer running - bool was_running = is_running_.exchange(false); - if (!was_running) + std::thread* thr = nullptr; + { - return; + std::lock_guard guard(mutex_); + + // Notify the listening thread that is no longer running + bool was_running = is_running_.exchange(false); + if (!was_running) + { + return; + } + + thr = listening_thread_; + listening_thread_ = nullptr; } // Notify the thread and wait for it to finish notification_->notify(); - listening_thread_->join(); - delete listening_thread_; + thr->join(); + delete thr; } void DataSharingListener::process_new_data () diff --git a/src/cpp/rtps/DataSharing/DataSharingNotification.hpp b/src/cpp/rtps/DataSharing/DataSharingNotification.hpp index 639ff9cbbcf..78af4fde31b 100644 --- a/src/cpp/rtps/DataSharing/DataSharingNotification.hpp +++ b/src/cpp/rtps/DataSharing/DataSharingNotification.hpp @@ -93,7 +93,7 @@ class DataSharingNotification #pragma warning(push) #pragma warning(disable:4324) - struct alignas (void*) Notification + struct alignas (uint64_t) Notification { //! CV to wait for new notifications Segment::condition_variable notification_cv; diff --git a/src/cpp/rtps/DataSharing/DataSharingPayloadPool.hpp b/src/cpp/rtps/DataSharing/DataSharingPayloadPool.hpp index 25dc08dfa85..bd6d0aa520b 100644 --- a/src/cpp/rtps/DataSharing/DataSharingPayloadPool.hpp +++ b/src/cpp/rtps/DataSharing/DataSharingPayloadPool.hpp @@ -137,7 +137,7 @@ class DataSharingPayloadPool : public IPayloadPool #pragma warning(push) #pragma warning(disable:4324) - class alignas (void*) PayloadNode + class alignas (uint64_t) PayloadNode { struct PayloadNodeMetaData @@ -333,7 +333,7 @@ class DataSharingPayloadPool : public IPayloadPool }; - struct alignas (void*) PoolDescriptor + struct alignas (uint64_t) PoolDescriptor { uint32_t history_size; //< Number of payloads in the history uint64_t notified_begin; //< The index of the oldest history entry already notified (ready to read) diff --git a/src/cpp/rtps/builtin/data/ParticipantProxyData.cpp b/src/cpp/rtps/builtin/data/ParticipantProxyData.cpp index 2218b5d0e39..f980689f53a 100644 --- a/src/cpp/rtps/builtin/data/ParticipantProxyData.cpp +++ b/src/cpp/rtps/builtin/data/ParticipantProxyData.cpp @@ -801,7 +801,7 @@ void ParticipantProxyData::set_persistence_guid( else { // if not exists add - m_properties.push_back(persistent_guid); + m_properties.push_back(persistent_guid.first, persistent_guid.second); } } diff --git a/src/cpp/rtps/builtin/discovery/participant/PDP.cpp b/src/cpp/rtps/builtin/discovery/participant/PDP.cpp index 4dcfb2e80b2..13a77ea1576 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDP.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDP.cpp @@ -347,8 +347,8 @@ void PDP::initializeParticipantProxyData( // Set participant type property std::stringstream participant_type; participant_type << mp_RTPSParticipant->getAttributes().builtin.discovery_config.discoveryProtocol; - participant_data->m_properties.push_back(std::pair({fastdds::dds::parameter_property_participant_type, participant_type.str()})); + auto ptype = participant_type.str(); + participant_data->m_properties.push_back(fastdds::dds::parameter_property_participant_type, ptype); } bool PDP::initPDP(