Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/entity-unregistration #1086

Merged
merged 13 commits into from
May 10, 2023
Merged

Conversation

rex-schilasky
Copy link
Contributor

@rex-schilasky rex-schilasky commented Apr 27, 2023

Pull request type

  • Feature

What is the current behavior?
Destroyed entities (publisher, subscriber, client, server) do not active unregister from the monitoring layer. These entities are removed after a monitoring timeout that can be defined in the global configuration ecal.ini file ([monitoring]/timeout).

What is the new behavior?
New additional unregistration messages are fired by all ecal entities on destruction. Entities disappear immediately from the monitoring layer.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

@@ -137,8 +137,7 @@ namespace eCAL
RemReceiveCallback();

// first unregister data reader
if(g_subgate()) g_subgate()->Unregister(m_datareader->GetTopicName(), m_datareader);
if(g_registration_provider()) g_registration_provider()->UnregisterTopic(m_datareader->GetTopicName(), m_datareader->GetTopicID());
if(g_subgate()) g_subgate()->Unregister(m_datareader->GetTopicName(), m_datareader);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: implicit conversion 'eCAL::CSubGate *' -> bool [readability-implicit-bool-conversion]

Suggested change
if(g_subgate()) g_subgate()->Unregister(m_datareader->GetTopicName(), m_datareader);
if(g_subgate() != nullptr) g_subgate()->Unregister(m_datareader->GetTopicName(), m_datareader);

@rex-schilasky rex-schilasky marked this pull request as draft April 27, 2023 07:50
@rex-schilasky rex-schilasky added the enhancement New feature or request label Apr 27, 2023
@rex-schilasky rex-schilasky added this to the eCAL 5.12 milestone Apr 27, 2023
@rex-schilasky rex-schilasky marked this pull request as ready for review April 27, 2023 09:41
Copy link
Contributor

@KerstinKeller KerstinKeller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comment regarding the expmap.
The rest in general looks good, but it's a bit much to really tell if everythingis ok.

ecal/core/src/ecal_expmap.h Outdated Show resolved Hide resolved
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

@@ -222,70 +216,42 @@ namespace eCAL
case eCAL::pb::bct_reg_process:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: switch has 2 consecutive identical branches [bugprone-branch-clone]

    case eCAL::pb::bct_reg_process:
    ^
Additional context

ecal/core/src/ecal_registration_receiver.cpp:220: last of these clones ends here

      break;
           ^

size_t ret_size(0);
if (g_subgate()) ret_size = g_subgate()->ApplySample(topic_name_, topic_id_, buf_, len_, id_, clock_, time_, hash_, eCAL::pb::tl_ecal_shm);
return ret_size;
if (g_subgate())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: implicit conversion 'eCAL::CSubGate *' -> bool [readability-implicit-bool-conversion]

Suggested change
if (g_subgate())
if (g_subgate() != nullptr)

{
if (!g_subgate()) return 0;
if (!g_subgate()) return false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: implicit conversion 'eCAL::CSubGate *' -> bool [readability-implicit-bool-conversion]

Suggested change
if (!g_subgate()) return false;
if (g_subgate() == nullptr) return false;

@@ -40,7 +40,7 @@ namespace eCAL
{
public:
bool HasSample(const std::string& sample_name_);
size_t ApplySample(const eCAL::pb::Sample& ecal_sample_, eCAL::pb::eTLayerType layer_);
bool ApplySample(const eCAL::pb::Sample& ecal_sample_, eCAL::pb::eTLayerType layer_);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: annotate this function with 'override' or (rarely) 'final' [cppcoreguidelines-explicit-virtual-functions]

Suggested change
bool ApplySample(const eCAL::pb::Sample& ecal_sample_, eCAL::pb::eTLayerType layer_);
bool ApplySample(const eCAL::pb::Sample& ecal_sample_, eCAL::pb::eTLayerType layer_) override;

@hannemn hannemn self-requested a review April 28, 2023 13:23
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

std::string memfile_event = memfile_name + "_" + process_id;
MemFileDataCallbackT memfile_data_callback = std::bind(&CSHMReaderLayer::OnNewShmFileContent, this,
const std::string process_id = std::to_string(Process::GetProcessID());
const std::string memfile_event = memfile_name + "_" + process_id;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation]

        const std::string memfile_event = memfile_name + "_" + process_id;
                                                             ^

@@ -41,7 +40,7 @@

namespace eCAL
{
std::mutex CDataWriterTCP::g_tcp_writer_executor_mtx;
std::mutex CDataWriterTCP::g_tcp_writer_executor_mtx;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'g_tcp_writer_executor_mtx' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]

  std::mutex                            CDataWriterTCP::g_tcp_writer_executor_mtx;
                                                        ^

friendly welcome and goodbye messages (Initialize & Finalize)
logic fix in ecal.cpp and ecalc.cpp for GetVersion()
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

void RefreshRegistrations();

protected:
static std::atomic<bool> m_created;
static std::atomic<bool> m_created;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'm_created' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]

    static std::atomic<bool> m_created;
                             ^

ecal/core/src/ecal.cpp Outdated Show resolved Hide resolved
ecal/core/src/ecal.cpp Outdated Show resolved Hide resolved
ecal/core/src/ecal_expmap.h Outdated Show resolved Hide resolved
ecal/core/src/mon/ecal_monitoring_impl.cpp Outdated Show resolved Hide resolved
ecal/core/src/mon/ecal_monitoring_impl.cpp Outdated Show resolved Hide resolved
ecal/core/src/mon/ecal_monitoring_impl.cpp Outdated Show resolved Hide resolved
ecal/core/src/mon/ecal_monitoring_impl.cpp Outdated Show resolved Hide resolved
ecal/core/src/mon/ecal_monitoring_impl.cpp Outdated Show resolved Hide resolved
ecal/core/src/mon/ecal_monitoring_impl.h Show resolved Hide resolved
ecal/core/src/readwrite/ecal_reader.cpp Outdated Show resolved Hide resolved
ecal/core/src/readwrite/ecal_reader.cpp Outdated Show resolved Hide resolved
@rex-schilasky rex-schilasky merged commit 1dd4624 into master May 10, 2023
@rex-schilasky rex-schilasky deleted the feature/entity-unregistration branch May 10, 2023 13:05
@@ -104,18 +102,18 @@ namespace eCAL
// create new sample
m_ecal_sample.Clear();
m_ecal_sample.set_cmd_type(eCAL::pb::bct_set_sample);
auto ecal_sample_mutable_topic = m_ecal_sample.mutable_topic();
auto *ecal_sample_mutable_topic = m_ecal_sample.mutable_topic();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this not introduce a different behavior?

ecal/core/src/mon/ecal_monitoring_impl.cpp Outdated Show resolved Hide resolved
@@ -654,10 +657,14 @@ namespace eCAL
void CDataWriter::ApplyLocSubscription(const std::string& process_id_, const std::string& tid_, const std::string& ttype_, const std::string& tdesc_, const std::string& reader_par_)
{
Connect(tid_, ttype_, tdesc_);

// add key to local subscriber map
const std::string topic_key = process_id_ + tid_;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This introduces unwanted side-effects!

KerstinKeller added a commit that referenced this pull request Sep 12, 2023
Introduces two new structs (SLocalSubscriptionInfo and SExternSubscriptionInfo) and uses them for applying / unapplying registrations.
They are also stored in the ExpiredMap when topic are no longer visible on monitoring layer.
KerstinKeller added a commit that referenced this pull request Sep 13, 2023
Introduces two new structs (SLocalSubscriptionInfo and SExternSubscriptionInfo) and uses them for applying / unapplying registrations.
They are also stored in the ExpiredMap when topic are no longer visible on monitoring layer.
FlorianReimold pushed a commit that referenced this pull request Sep 20, 2023
Introduces two new structs (SLocalSubscriptionInfo and SExternSubscriptionInfo) and uses them for applying / unapplying registrations.
They are also stored in the ExpiredMap when topic are no longer visible on monitoring layer.
FlorianReimold pushed a commit that referenced this pull request Oct 27, 2023
Introduces two new structs (SLocalSubscriptionInfo and SExternSubscriptionInfo) and uses them for applying / unapplying registrations.
They are also stored in the ExpiredMap when topic are no longer visible on monitoring layer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants