diff options
author | Alexander Kutsan (GitHub) <akutsan@luxoft.com> | 2020-08-31 16:14:58 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-31 09:14:58 -0400 |
commit | 79fb6408810d776278bf3499c5273eb04159b076 (patch) | |
tree | a0e860d51b2712afef8b9ff113000436011e33e3 | |
parent | 979492b415698d1bba26efbfd5d9ee08bbb01147 (diff) | |
download | sdl_core-79fb6408810d776278bf3499c5273eb04159b076.tar.gz |
Fix SIGKILL due to not clearing the requestinfo set. (#3376)
* SDLCORE-666: Fix SIGKILL due to not clearing the requestinfo set.
SDLCORE-666
Added RequestInfoSet Destructor for properly clearing the time_sorted_pending_requests_ set
to avoid double release of the same while destroying the RequestController Object.
* Update fix for SIGKILL due to not clearing the requestinfo set
- Change the RemoveRequest method on the Erase method in the RequestInfoSet
destructor;
- Remove redundant TestRequestsInfo collection in the Unit test
Co-authored-by: Sidhartha <ssing314@ford.com>
Co-authored-by: Igor Gapchuk <igapchuck@luxoft.com>
Co-authored-by: Dmitriy Boltovskiy <dboltovskyi@luxoft.com>
3 files changed, 14 insertions, 1 deletions
diff --git a/src/components/application_manager/include/application_manager/request_info.h b/src/components/application_manager/include/application_manager/request_info.h index 6900a50926..c6cf00caea 100644 --- a/src/components/application_manager/include/application_manager/request_info.h +++ b/src/components/application_manager/include/application_manager/request_info.h @@ -180,6 +180,11 @@ typedef std::set<RequestInfoPtr, RequestInfoHashComparator> */ class RequestInfoSet { public: + /** + * @brief destructor + */ + ~RequestInfoSet(); + /* * @brief Add requests into colletion by log(n) time * @param request_info - request to add diff --git a/src/components/application_manager/src/request_info.cc b/src/components/application_manager/src/request_info.cc index 4f1e0a8f07..b6f53b6085 100644 --- a/src/components/application_manager/src/request_info.cc +++ b/src/components/application_manager/src/request_info.cc @@ -116,6 +116,15 @@ FakeRequestInfo::FakeRequestInfo(uint32_t app_id, uint32_t correaltion_id) { correlation_id_ = correaltion_id; } +RequestInfoSet::~RequestInfoSet() { + sync_primitives::AutoLock lock(pending_requests_lock_); + auto it = time_sorted_pending_requests_.begin(); + while (!time_sorted_pending_requests_.empty()) { + Erase(*it); + it = time_sorted_pending_requests_.begin(); + } +} + bool RequestInfoSet::Add(RequestInfoPtr request_info) { DCHECK_OR_RETURN(request_info, false); LOG4CXX_DEBUG( diff --git a/src/components/application_manager/test/request_info_test.cc b/src/components/application_manager/test/request_info_test.cc index a0b1793cf5..118ca1e41e 100644 --- a/src/components/application_manager/test/request_info_test.cc +++ b/src/components/application_manager/test/request_info_test.cc @@ -90,7 +90,6 @@ class RequestInfoTest : public ::testing::Test { }; TEST_F(RequestInfoTest, RequestInfoEqualEndTime) { - std::vector<std::shared_ptr<TestRequestInfo> > requests; const date_time::TimeDuration& time = date_time::getCurrentTime(); for (uint32_t i = 0; i < count_of_requests_for_test_; ++i) { std::shared_ptr<TestRequestInfo> request = CreateTestInfo( |