diff options
author | Lutz Bichler <Lutz.Bichler@bmw.de> | 2015-02-02 12:24:48 +0100 |
---|---|---|
committer | Lutz Bichler <Lutz.Bichler@bmw.de> | 2015-02-02 12:24:48 +0100 |
commit | 5f12188acebf57ef89574cb5c6df135bbb11e55f (patch) | |
tree | a86ff080e73d90fcbca7a48452431a021490bcf4 | |
parent | 2804f6190cd9f613cc69f768f3789b88e0ad7cc4 (diff) | |
download | vSomeIP-5f12188acebf57ef89574cb5c6df135bbb11e55f.tar.gz |
Ensure a local is not deleted while sending.
-rw-r--r-- | implementation/routing/include/routing_manager_impl.hpp | 2 | ||||
-rw-r--r-- | implementation/routing/src/routing_manager_impl.cpp | 11 |
2 files changed, 10 insertions, 3 deletions
diff --git a/implementation/routing/include/routing_manager_impl.hpp b/implementation/routing/include/routing_manager_impl.hpp index ef715ce..46542f0 100644 --- a/implementation/routing/include/routing_manager_impl.hpp +++ b/implementation/routing/include/routing_manager_impl.hpp @@ -226,7 +226,7 @@ private: std::map<instance_t, std::map<eventgroup_t, std::set<client_t> > > > eventgroup_clients_; // Mutexes - std::recursive_mutex endpoint_mutex_; + mutable std::recursive_mutex endpoint_mutex_; std::mutex serialize_mutex_; }; diff --git a/implementation/routing/src/routing_manager_impl.cpp b/implementation/routing/src/routing_manager_impl.cpp index 0084dba..53730c9 100644 --- a/implementation/routing/src/routing_manager_impl.cpp +++ b/implementation/routing/src/routing_manager_impl.cpp @@ -334,10 +334,14 @@ bool routing_manager_impl::send(client_t _client, const byte_t *_data, } bool routing_manager_impl::send_local( - std::shared_ptr<endpoint> &_target, client_t _client, + std::shared_ptr<endpoint>& _target, client_t _client, const byte_t *_data, uint32_t _size, instance_t _instance, bool _flush, bool _reliable) const { + + std::lock_guard<std::recursive_mutex> its_lock(endpoint_mutex_); + + if (_target) { std::vector<byte_t> its_command( VSOMEIP_COMMAND_HEADER_SIZE + _size + sizeof(instance_t) + sizeof(bool) + sizeof(bool)); @@ -358,7 +362,10 @@ bool routing_manager_impl::send_local( + sizeof(instance_t) + sizeof(bool)], &_flush, sizeof(bool)); - return _target->send(&its_command[0], its_command.size(),_flush); + return _target->send(&its_command[0], its_command.size(),_flush); + } + + return false; } bool routing_manager_impl::send_to( |