Skip to content

Commit

Permalink
Fix NSM logs with empty Container Id strings
Browse files Browse the repository at this point in the history
Summary
Moved the config_command from register_application() to find_or_create_local()
Details
Moved the config_command from register_application() to find_or_create_local() to fix NSM logs
with an empty "Container Id" string. The container id was empty because there was no sending of
the config command between the clients and the application (client), it was only between the clients
and the daemon, not providing the container ids to the application.
To avoid sending the config command in all messages and incorrectly causing a query limit,
a flag was added to only send the config command when the endpoint is created.
  • Loading branch information
danielsantiago authored and Duarte Fonseca committed Feb 19, 2025
1 parent 8378f98 commit ca06bbc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
20 changes: 20 additions & 0 deletions implementation/endpoints/src/endpoint_manager_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,37 @@ void endpoint_manager_base::remove_local(const client_t _client) {
}

std::shared_ptr<endpoint> endpoint_manager_base::find_or_create_local(client_t _client) {
bool its_local_endpoint_created {false};
std::shared_ptr<endpoint> its_endpoint {nullptr};
{
std::scoped_lock its_lock {local_endpoint_mutex_};
its_endpoint = find_local_unlocked(_client);
if (!its_endpoint) {
VSOMEIP_INFO << "emb::" << __func__ << ": create_client " << std::hex << _client;
its_endpoint = create_local_unlocked(_client);
its_local_endpoint_created = true;
}
}
if (its_endpoint) {
its_endpoint->start();

if (its_local_endpoint_created) {
// Send a `config_command` to share our hostname with the other application.
protocol::config_command its_command;
its_command.set_client(get_client());
its_command.insert("hostname", get_client_host());

std::vector<byte_t> its_buffer;
protocol::error_e its_error;
its_command.serialize(its_buffer, its_error);

if (its_error == protocol::error_e::ERROR_OK) {
its_endpoint->send(&its_buffer[0], static_cast<uint32_t>(its_buffer.size()));
} else {
VSOMEIP_ERROR << __func__ << ": config command serialization failed(" << std::dec
<< int(its_error) << ")";
}
}
} else {
VSOMEIP_ERROR << "emb::" << __func__ << ": couldn't find or create endpoint for client "
<< std::hex << _client;
Expand Down
16 changes: 0 additions & 16 deletions implementation/routing/src/routing_manager_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2263,22 +2263,6 @@ void routing_manager_client::register_application() {
std::dynamic_pointer_cast<routing_manager_client>(shared_from_this()),
std::placeholders::_1));
}

// Send a `config_command` to share our hostname with the other application.
protocol::config_command its_command_config;
its_command_config.set_client(get_client());
its_command_config.insert("hostname", get_client_host());

std::vector<byte_t> its_buffer_config;
its_command_config.serialize(its_buffer_config, its_error);

if (its_error == protocol::error_e::ERROR_OK) {
sender_->send(&its_buffer_config[0],
static_cast<uint32_t>(its_buffer_config.size()));
} else {
VSOMEIP_ERROR << __func__ << ": config command serialization failed("
<< std::dec << int(its_error) << ")";
}
}
}
} else {
Expand Down

0 comments on commit ca06bbc

Please sign in to comment.