From 79fb6408810d776278bf3499c5273eb04159b076 Mon Sep 17 00:00:00 2001 From: "Alexander Kutsan (GitHub)" Date: Mon, 31 Aug 2020 16:14:58 +0300 Subject: 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 Co-authored-by: Igor Gapchuk Co-authored-by: Dmitriy Boltovskiy --- .../include/application_manager/request_info.h | 5 +++++ src/components/application_manager/src/request_info.cc | 9 +++++++++ src/components/application_manager/test/request_info_test.cc | 1 - 3 files changed, 14 insertions(+), 1 deletion(-) 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 */ 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 > requests; const date_time::TimeDuration& time = date_time::getCurrentTime(); for (uint32_t i = 0; i < count_of_requests_for_test_; ++i) { std::shared_ptr request = CreateTestInfo( -- cgit v1.2.1