Add time out to JobWatch 92/188092/4 accepted/tizen/4.0/unified/20180904.005150 submit/tizen_4.0/20180831.082853
authorseolheui, kim <s414.kim@samsung.com>
Fri, 31 Aug 2018 07:42:14 +0000 (16:42 +0900)
committerseolheui, kim <s414.kim@samsung.com>
Fri, 31 Aug 2018 08:27:19 +0000 (17:27 +0900)
Change-Id: Idfac8fcb7bf1e5da993a5382bf68e2a392f052e3
Signed-off-by: seolheui, kim <s414.kim@samsung.com>
server/internal-encryption.cpp

index b762cc2..9c13f3d 100644 (file)
@@ -53,9 +53,6 @@ namespace ode {
 namespace {
 
 const char *PRIVILEGE_PLATFORM = "http://tizen.org/privilege/internal/default/platform";
-const std::vector<std::string> blackListSystemdUnits = {
-       "samsung-log-mgr.service",
-};
 
 // watches systemd jobs
 class JobWatch {
@@ -105,7 +102,19 @@ JobWatch::~JobWatch() {
 bool JobWatch::waitForJob(const std::string& job) {
        while(true) {
                std::unique_lock<std::mutex> lock(jobsMutex);
-               jobsCv.wait(lock, [this]{ return !removedJobs.empty(); });
+               bool timeout = true;
+               auto sec = std::chrono::seconds(1);
+               jobsCv.wait_for(lock, 5*sec, [this, &timeout]{
+                               if (!removedJobs.empty()) {
+                                       timeout = false;
+                                       return true;
+                               }
+                               return false;});
+
+               if (timeout) {
+                       INFO(SINK, "job: " + job + ", result: time out");
+                       return false;
+               }
 
                while(!removedJobs.empty()) {
                        bool match = (removedJobs.front().job == job);
@@ -182,10 +191,6 @@ void stopSystemdUnits()
                }
        }
 
-       for (auto unit : blackListSystemdUnits) {
-               unitsToStop.erase(unitsToStop.find(unit));
-       }
-
        auto stopUnit = [&systemDBus](const std::string &unit) {
                INFO(SINK, "Stopping unit: " + unit);
                JobWatch watch(systemDBus);