MCPcopy Create free account
hub / github.com/COVESA/vsomeip / offer_service

Method offer_service

implementation/routing/src/routing_manager_client.cpp:248–291  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

246}
247
248bool routing_manager_client::offer_service(client_t _client, service_t _service, instance_t _instance, major_version_t _major,
249 minor_version_t _minor) {
250
251 {
252 std::scoped_lock its_lock(provider_mutex_);
253 auto its_info = find_service(_service, _instance, its_lock);
254 if (its_info) {
255 if (its_info->get_major() != _major || its_info->get_minor() != _minor) {
256 VSOMEIP_ERROR_P << "Service property mismatch (" << hex4(_client) << "): [" << hex4(_service) << "." << hex4(_instance)
257 << ":" << static_cast<std::uint32_t>(its_info->get_major()) << "." << its_info->get_minor()
258 << "] passed: " << static_cast<std::uint32_t>(_major) << ":" << _minor;
259 return false;
260 }
261 return true; // we are already offering this service -> no need to do anything else!
262 }
263 its_info = std::make_shared<serviceinfo>(_service, _instance, _major, _minor, DEFAULT_TTL, true);
264 provided_services_[_service][_instance] = its_info;
265
266 // Set major version for all registered events of this service and instance
267 const auto search = provided_events_.find(service_instance_t{_service, _instance});
268
269 if (search != provided_events_.end()) {
270 for (const auto& [event_id, event_ptr] : search->second) {
271 event_ptr->set_version(_major);
272 }
273 }
274 }
275
276 {
277 // order matters:
278 // 1. Ensure that it is part of the pending_offers set
279 // 2. check for the state
280 // otherwise:
281 // state might be not be registered, but turn registered just after the check,
282 // rushing ahead sending the pending offers that do not contain this offer yet.
283 protocol::service offer(_service, _instance, _major, _minor);
284 std::scoped_lock its_lock(pending_offers_mutex_);
285 pending_offers_.insert(offer);
286 if (state_machine_->state() == routing_client_state_e::ST_REGISTERED) {
287 send_offer_service(_client, _service, _instance, _major, _minor);
288 }
289 }
290 return true;
291}
292
293bool routing_manager_client::send_offer_service(client_t _client, service_t _service, instance_t _instance, major_version_t _major,
294 minor_version_t _minor) {

Callers

nothing calls this directly

Calls 7

hex4Function · 0.85
endMethod · 0.80
set_versionMethod · 0.80
insertMethod · 0.80
stateMethod · 0.80
get_majorMethod · 0.45
get_minorMethod · 0.45

Tested by

no test coverage detected