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

[core] check-sample-applier-process-id-fix #1676

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion ecal/core/src/registration/ecal_registration_sample_applier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,44 @@ namespace eCAL
return true;
}

bool CSampleApplier::IsSameProcess(const Registration::Sample& sample_)
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: method 'IsSameProcess' can be made const [readability-make-member-function-const]

Suggested change
bool CSampleApplier::IsSameProcess(const Registration::Sample& sample_)
bool CSampleApplier::IsSameProcess(const Registration::Sample& sample_) const

ecal/core/src/registration/ecal_registration_sample_applier.h:56:

-       bool IsSameProcess(const Registration::Sample& sample_);
+       bool IsSameProcess(const Registration::Sample& sample_) const;

{
int32_t pid(0);
switch (sample_.cmd_type)
{
case bct_reg_process:
case bct_unreg_process:
pid = sample_.process.pid;
break;
case bct_reg_publisher:
case bct_unreg_publisher:
case bct_reg_subscriber:
case bct_unreg_subscriber:
pid = sample_.topic.pid;
break;
case bct_reg_service:
case bct_unreg_service:
pid = sample_.service.pid;
break;
case bct_reg_client:
case bct_unreg_client:
pid = sample_.client.pid;
break;
default:
break;
}

return pid == m_pid;
}

bool CSampleApplier::AcceptRegistrationSample(const Registration::Sample& sample_)
{
// check if the sample is from the same host group
if (IsHostGroupMember(sample_))
{
// register if the sample is from another process
// or if loopback mode is enabled
return m_loopback || (sample_.topic.pid != m_pid);
return !IsSameProcess(sample_) || m_loopback;
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ namespace eCAL
void RemCustomApplySampleCallback(const std::string& customer_);

private:
bool IsSameProcess(const Registration::Sample& sample_);
bool IsHostGroupMember(const eCAL::Registration::Sample& sample_);
bool AcceptRegistrationSample(const Registration::Sample& sample_);

Expand Down
Loading