diff options
author | Juergen Gehring <juergen.gehring@bmw.de> | 2018-01-25 00:40:07 -0800 |
---|---|---|
committer | Juergen Gehring <juergen.gehring@bmw.de> | 2018-01-25 00:40:07 -0800 |
commit | a89a645014e17f383e07b6dc6899a4a8925cc324 (patch) | |
tree | d1a6f31158cd96ec724e13e2c9d7023378106b64 /implementation/routing/src | |
parent | 8bb2ed134d75803e8e6e3c4f4baa253e4d74edf4 (diff) | |
download | vSomeIP-a89a645014e17f383e07b6dc6899a4a8925cc324.tar.gz |
vsomeip 2.10.62.10.6
Diffstat (limited to 'implementation/routing/src')
-rw-r--r-- | implementation/routing/src/routing_manager_impl.cpp | 44 | ||||
-rw-r--r-- | implementation/routing/src/routing_manager_proxy.cpp | 49 | ||||
-rw-r--r-- | implementation/routing/src/routing_manager_stub.cpp | 2 |
3 files changed, 69 insertions, 26 deletions
diff --git a/implementation/routing/src/routing_manager_impl.cpp b/implementation/routing/src/routing_manager_impl.cpp index 6af17a4..15f1201 100644 --- a/implementation/routing/src/routing_manager_impl.cpp +++ b/implementation/routing/src/routing_manager_impl.cpp @@ -1283,6 +1283,7 @@ void routing_manager_impl::on_connect(std::shared_ptr<endpoint> _endpoint) { if (found_endpoint->second.get() == _endpoint.get()) { std::shared_ptr<serviceinfo> its_info(find_service(its_service.first, its_instance.first)); if (!its_info) { + _endpoint->set_connected(true); return; } services_to_report_.push_front( @@ -1290,7 +1291,7 @@ void routing_manager_impl::on_connect(std::shared_ptr<endpoint> _endpoint) { its_instance.first, its_info->get_major(), its_info->get_minor(), - false, nullptr }); + false, _endpoint }); } } found_endpoint = its_client.second.find(true); @@ -1298,6 +1299,7 @@ void routing_manager_impl::on_connect(std::shared_ptr<endpoint> _endpoint) { if (found_endpoint->second.get() == _endpoint.get()) { std::shared_ptr<serviceinfo> its_info(find_service(its_service.first, its_instance.first)); if (!its_info) { + _endpoint->set_connected(true); return; } services_to_report_.push_front( @@ -1335,6 +1337,9 @@ void routing_manager_impl::on_connect(std::shared_ptr<endpoint> _endpoint) { VSOMEIP_ERROR<< "routing_manager_impl::on_connect: " << ec.message(); } } + if (services_to_report_.empty()) { + _endpoint->set_connected(true); + } } void routing_manager_impl::on_disconnect(std::shared_ptr<endpoint> _endpoint) { @@ -2437,6 +2442,16 @@ void routing_manager_impl::expire_subscriptions(const boost::asio::ip::address & clear_remote_subscriber(its_service.first, its_instance.first, its_client, its_endpoint); + if (its_eventgroup.second->get_targets().size() == 0) { + std::set<std::shared_ptr<event> > its_events + = its_eventgroup.second->get_events(); + for (auto e : its_events) { + if (e->is_shadow()) { + e->unset_payload(); + } + } + } + if (target) { stub_->send_unsubscribe(target, its_client, its_service.first, its_instance.first, its_eventgroup.first, ANY_EVENT, true); @@ -3350,6 +3365,16 @@ routing_manager_impl::expire_subscriptions() { clear_remote_subscriber(its_service.first, its_instance.first, its_client, its_endpoint); + if (its_eventgroup.second->get_targets().size() == 0) { + std::set<std::shared_ptr<event> > its_events + = its_eventgroup.second->get_events(); + for (auto e : its_events) { + if (e->is_shadow()) { + e->unset_payload(); + } + } + } + if (target) { stub_->send_unsubscribe(target, its_client, its_service.first, its_instance.first, its_eventgroup.first, ANY_EVENT, true); @@ -3931,16 +3956,12 @@ void routing_manager_impl::set_routing_state(routing_state_e _routing_state) { } void routing_manager_impl::on_net_if_state_changed(std::string _if, bool _available) { - if (_available != if_state_running_) { - if (_available) { - VSOMEIP_INFO << "Network interface \"" << _if << "\" is up and running."; - start_ip_routing(); -#ifndef _WIN32 - if (netlink_connector_) { - netlink_connector_->unregister_net_if_changes_handler(); - } -#endif - } + if (!if_state_running_ && _available) { + VSOMEIP_INFO << "Network interface \"" << _if << "\" is up and running."; + start_ip_routing(); + } else { + VSOMEIP_WARNING << "Network interface \"" << _if << "\" state changed: " + << std::string((_available) ? "up" : "down"); } } @@ -4026,6 +4047,7 @@ void routing_manager_impl::call_sd_endpoint_connected( if (_error) { return; } + _endpoint->set_connected(true); if (discovery_) { discovery_->on_endpoint_connected(_service, _instance, _endpoint); diff --git a/implementation/routing/src/routing_manager_proxy.cpp b/implementation/routing/src/routing_manager_proxy.cpp index a4af448..8dd8515 100644 --- a/implementation/routing/src/routing_manager_proxy.cpp +++ b/implementation/routing/src/routing_manager_proxy.cpp @@ -774,6 +774,7 @@ bool routing_manager_proxy::send_to( } void routing_manager_proxy::on_connect(std::shared_ptr<endpoint> _endpoint) { + _endpoint->set_connected(true); { std::lock_guard<std::mutex> its_lock(sender_mutex_); if (_endpoint != sender_) { @@ -850,6 +851,7 @@ void routing_manager_proxy::on_message(const byte_t *_data, length_t _size, client_t its_subscriber; bool its_reliable; pending_subscription_id_t its_subscription_id(DEFAULT_SUBSCRIPTION); + std::uint32_t its_remote_subscriber_count(0); if (_size > VSOMEIP_COMMAND_SIZE_POS_MAX) { its_command = _data[VSOMEIP_COMMAND_TYPE_POS]; @@ -983,7 +985,7 @@ void routing_manager_proxy::on_message(const byte_t *_data, length_t _size, std::memcpy(&its_subscription_id, &_data[VSOMEIP_COMMAND_PAYLOAD_POS + 10], sizeof(its_subscription_id)); { - std::unique_lock<std::mutex> its_lock(incoming_subscriptions_mutex_); + std::unique_lock<std::recursive_mutex> its_lock(incoming_subscriptions_mutex_); if (its_subscription_id != DEFAULT_SUBSCRIPTION) { its_lock.unlock(); // Remote subscriber: Notify routing manager initially + count subscribes @@ -991,7 +993,7 @@ void routing_manager_proxy::on_message(const byte_t *_data, length_t _size, host_->on_subscription(its_service, its_instance, its_eventgroup, its_client, true, [this, self, its_client, its_service, its_instance, - its_eventgroup, its_event, its_subscription_id] + its_eventgroup, its_event, its_subscription_id, its_major] (const bool _subscription_accepted){ if(_subscription_accepted) { send_subscribe_ack(its_client, its_service, its_instance, @@ -1007,7 +1009,17 @@ void routing_manager_proxy::on_message(const byte_t *_data, length_t _size, notify_remote_initially(its_service, its_instance, its_eventgroup, its_already_subscribed_events); } - (void)get_remote_subscriber_count(its_service, its_instance, its_eventgroup, true); + std::uint32_t its_count = get_remote_subscriber_count( + its_service, its_instance, its_eventgroup, true); + VSOMEIP_INFO << "SUBSCRIBE(" + << std::hex << std::setw(4) << std::setfill('0') << its_client <<"): [" + << std::hex << std::setw(4) << std::setfill('0') << its_service << "." + << std::hex << std::setw(4) << std::setfill('0') << its_instance << "." + << std::hex << std::setw(4) << std::setfill('0') << its_eventgroup << ":" + << std::hex << std::setw(4) << std::setfill('0') << its_event << ":" + << std::dec << (uint16_t)its_major << "]" + << (bool)(its_subscription_id != DEFAULT_SUBSCRIPTION) << " " + << std::dec << its_count; }); } else if (is_client_known(its_client)) { its_lock.unlock(); @@ -1048,13 +1060,15 @@ void routing_manager_proxy::on_message(const byte_t *_data, length_t _size, pending_incoming_subscripitons_[its_client].insert(subscription); } } - VSOMEIP_INFO << "SUBSCRIBE(" - << std::hex << std::setw(4) << std::setfill('0') << its_client <<"): [" - << std::hex << std::setw(4) << std::setfill('0') << its_service << "." - << std::hex << std::setw(4) << std::setfill('0') << its_instance << "." - << std::hex << std::setw(4) << std::setfill('0') << its_eventgroup << ":" - << std::hex << std::setw(4) << std::setfill('0') << its_event << ":" - << std::dec << (uint16_t)its_major << "]"; + if (its_subscription_id == DEFAULT_SUBSCRIPTION) { // local subscription + VSOMEIP_INFO << "SUBSCRIBE(" + << std::hex << std::setw(4) << std::setfill('0') << its_client <<"): [" + << std::hex << std::setw(4) << std::setfill('0') << its_service << "." + << std::hex << std::setw(4) << std::setfill('0') << its_instance << "." + << std::hex << std::setw(4) << std::setfill('0') << its_eventgroup << ":" + << std::hex << std::setw(4) << std::setfill('0') << its_event << ":" + << std::dec << (uint16_t)its_major << "]"; + } break; case VSOMEIP_UNSUBSCRIBE: @@ -1078,7 +1092,9 @@ void routing_manager_proxy::on_message(const byte_t *_data, length_t _size, routing_manager_base::unsubscribe(its_client, its_service, its_instance, its_eventgroup, its_event); } else { // Remote subscriber: withdraw subscription only if no more remote subscriber exists - if (!get_remote_subscriber_count(its_service, its_instance, its_eventgroup, false)) { + its_remote_subscriber_count = get_remote_subscriber_count(its_service, + its_instance, its_eventgroup, false); + if (!its_remote_subscriber_count) { routing_manager_base::unsubscribe(VSOMEIP_ROUTING_CLIENT, its_service, its_instance, its_eventgroup, its_event); } @@ -1088,7 +1104,9 @@ void routing_manager_proxy::on_message(const byte_t *_data, length_t _size, << std::hex << std::setw(4) << std::setfill('0') << its_service << "." << std::hex << std::setw(4) << std::setfill('0') << its_instance << "." << std::hex << std::setw(4) << std::setfill('0') << its_eventgroup << "." - << std::hex << std::setw(4) << std::setfill('0') << its_event << "]"; + << std::hex << std::setw(4) << std::setfill('0') << its_event << "] " + << (bool)is_remote_subscriber << " " + << std::dec << its_remote_subscriber_count; break; case VSOMEIP_SUBSCRIBE_NACK: @@ -1334,7 +1352,7 @@ void routing_manager_proxy::on_routing_info(const byte_t *_data, major_version_t major_; event_t event_; }; - std::lock_guard<std::mutex> its_lock(incoming_subscriptions_mutex_); + std::lock_guard<std::recursive_mutex> its_lock(incoming_subscriptions_mutex_); std::forward_list<struct subscription_info> subscription_actions; if (pending_incoming_subscripitons_.size()) { { @@ -1371,7 +1389,10 @@ void routing_manager_proxy::on_routing_info(const byte_t *_data, send_pending_notify_ones(si.service_id_, si.instance_id_, si.eventgroup_id_, si.client_id_); } - pending_incoming_subscripitons_.erase(si.client_id_); + { + std::lock_guard<std::recursive_mutex> its_lock2(incoming_subscriptions_mutex_); + pending_incoming_subscripitons_.erase(si.client_id_); + } }); } } diff --git a/implementation/routing/src/routing_manager_stub.cpp b/implementation/routing/src/routing_manager_stub.cpp index 010c8d0..8d48436 100644 --- a/implementation/routing/src/routing_manager_stub.cpp +++ b/implementation/routing/src/routing_manager_stub.cpp @@ -161,7 +161,7 @@ const std::shared_ptr<configuration> routing_manager_stub::get_configuration() c } void routing_manager_stub::on_connect(std::shared_ptr<endpoint> _endpoint) { - (void)_endpoint; + _endpoint->set_connected(true); } void routing_manager_stub::on_disconnect(std::shared_ptr<endpoint> _endpoint) { |