From 9110d2ae3095864eb1aefd1f694c1d37ded002a3 Mon Sep 17 00:00:00 2001 From: Rex Schilasky <49162693+rex-schilasky@users.noreply.github.com> Date: Fri, 26 Jul 2024 16:47:21 +0200 Subject: [PATCH] [core] registration-sender-datarace-fix (#1674) --- .../src/registration/shm/ecal_registration_sender_shm.cpp | 7 ++++--- .../src/registration/shm/ecal_registration_sender_shm.h | 1 - .../src/registration/udp/ecal_registration_sender_udp.cpp | 5 +++-- .../src/registration/udp/ecal_registration_sender_udp.h | 1 - 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ecal/core/src/registration/shm/ecal_registration_sender_shm.cpp b/ecal/core/src/registration/shm/ecal_registration_sender_shm.cpp index c040037d62..c8fed5d3bc 100644 --- a/ecal/core/src/registration/shm/ecal_registration_sender_shm.cpp +++ b/ecal/core/src/registration/shm/ecal_registration_sender_shm.cpp @@ -54,12 +54,13 @@ bool eCAL::CRegistrationSenderSHM::SendSampleList(const Registration::SampleList { bool return_value{true}; // serialize whole sample list - if (SerializeToBuffer(sample_list, m_sample_list_buffer)) + std::vector sample_list_buffer; + if (SerializeToBuffer(sample_list, sample_list_buffer)) { - if (!m_sample_list_buffer.empty()) + if (!sample_list_buffer.empty()) { // broadcast sample list over shm - return_value &= m_memfile_broadcast_writer.Write(m_sample_list_buffer.data(), m_sample_list_buffer.size()); + return_value &= m_memfile_broadcast_writer.Write(sample_list_buffer.data(), sample_list_buffer.size()); } } return return_value; diff --git a/ecal/core/src/registration/shm/ecal_registration_sender_shm.h b/ecal/core/src/registration/shm/ecal_registration_sender_shm.h index 7f449e4b37..67f4638b18 100644 --- a/ecal/core/src/registration/shm/ecal_registration_sender_shm.h +++ b/ecal/core/src/registration/shm/ecal_registration_sender_shm.h @@ -51,7 +51,6 @@ namespace eCAL bool SendSampleList(const Registration::SampleList& sample_list) override; private: - std::vector m_sample_list_buffer; CMemoryFileBroadcast m_memfile_broadcast; CMemoryFileBroadcastWriter m_memfile_broadcast_writer; }; diff --git a/ecal/core/src/registration/udp/ecal_registration_sender_udp.cpp b/ecal/core/src/registration/udp/ecal_registration_sender_udp.cpp index 784220220e..ab8d5feda2 100644 --- a/ecal/core/src/registration/udp/ecal_registration_sender_udp.cpp +++ b/ecal/core/src/registration/udp/ecal_registration_sender_udp.cpp @@ -61,10 +61,11 @@ namespace eCAL bool CRegistrationSenderUDP::SendSample(const Registration::Sample& sample_) { // serialize single sample - if (SerializeToBuffer(sample_, m_sample_buffer)) + std::vector sample_buffer; + if (SerializeToBuffer(sample_, sample_buffer)) { // send single sample over udp - return m_reg_sample_snd.Send("reg_sample", m_sample_buffer) != 0; + return m_reg_sample_snd.Send("reg_sample", sample_buffer) != 0; } return false; } diff --git a/ecal/core/src/registration/udp/ecal_registration_sender_udp.h b/ecal/core/src/registration/udp/ecal_registration_sender_udp.h index 65967cd1f9..ad49e8edf1 100644 --- a/ecal/core/src/registration/udp/ecal_registration_sender_udp.h +++ b/ecal/core/src/registration/udp/ecal_registration_sender_udp.h @@ -50,6 +50,5 @@ namespace eCAL bool SendSample(const Registration::Sample& sample_); UDP::CSampleSender m_reg_sample_snd; - std::vector m_sample_buffer; }; } \ No newline at end of file