summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Kutsan (GitHub) <akutsan@luxoft.com>2020-08-31 16:14:58 +0300
committerGitHub <noreply@github.com>2020-08-31 09:14:58 -0400
commit79fb6408810d776278bf3499c5273eb04159b076 (patch)
treea0e860d51b2712afef8b9ff113000436011e33e3
parent979492b415698d1bba26efbfd5d9ee08bbb01147 (diff)
downloadsdl_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>
-rw-r--r--src/components/application_manager/include/application_manager/request_info.h5
-rw-r--r--src/components/application_manager/src/request_info.cc9
-rw-r--r--src/components/application_manager/test/request_info_test.cc1
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(