summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2017-06-11 09:37:32 +0200
committerandroid-build-team Robot <android-build-team-robot@google.com>2017-06-11 09:37:32 +0200
commit19f7fe0d2e805557d3af545b32de7b8c620644c7 (patch)
treee9926852906a12ab3ec401a04b5d941b35bc58dd
parentrelease-request-fad05353-cc19-4c26-af2f-d5c8a574970e-for-git_oc-mr1-release-4057695 snap-temp-L92600000069427650 (diff)
parentMerge "Fix a race condition for temperature_logger" am: 8e5fb46e87 am: efa40b4827 am: 54138462b4 (diff)
downloadandroid_bootable_recovery-19f7fe0d2e805557d3af545b32de7b8c620644c7.tar
android_bootable_recovery-19f7fe0d2e805557d3af545b32de7b8c620644c7.tar.gz
android_bootable_recovery-19f7fe0d2e805557d3af545b32de7b8c620644c7.tar.bz2
android_bootable_recovery-19f7fe0d2e805557d3af545b32de7b8c620644c7.tar.lz
android_bootable_recovery-19f7fe0d2e805557d3af545b32de7b8c620644c7.tar.xz
android_bootable_recovery-19f7fe0d2e805557d3af545b32de7b8c620644c7.tar.zst
android_bootable_recovery-19f7fe0d2e805557d3af545b32de7b8c620644c7.zip
-rw-r--r--install.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/install.cpp b/install.cpp
index a1f2e4fbd..db4ba9373 100644
--- a/install.cpp
+++ b/install.cpp
@@ -27,6 +27,7 @@
#include <unistd.h>
#include <algorithm>
+#include <atomic>
#include <chrono>
#include <condition_variable>
#include <functional>
@@ -294,11 +295,12 @@ int update_binary_command(const std::string& package, ZipArchiveHandle zip,
}
#endif // !AB_OTA_UPDATER
-static void log_max_temperature(int* max_temperature) {
+static void log_max_temperature(int* max_temperature, const std::atomic<bool>& logger_finished) {
CHECK(max_temperature != nullptr);
std::mutex mtx;
std::unique_lock<std::mutex> lck(mtx);
- while (finish_log_temperature.wait_for(lck, 20s) == std::cv_status::timeout) {
+ while (!logger_finished.load() &&
+ finish_log_temperature.wait_for(lck, 20s) == std::cv_status::timeout) {
*max_temperature = std::max(*max_temperature, GetMaxValueFromThermalZone());
}
}
@@ -403,7 +405,8 @@ static int try_update_binary(const std::string& package, ZipArchiveHandle zip, b
}
close(pipefd[1]);
- std::thread temperature_logger(log_max_temperature, max_temperature);
+ std::atomic<bool> logger_finished(false);
+ std::thread temperature_logger(log_max_temperature, max_temperature, std::ref(logger_finished));
*wipe_cache = false;
bool retry_update = false;
@@ -467,6 +470,7 @@ static int try_update_binary(const std::string& package, ZipArchiveHandle zip, b
int status;
waitpid(pid, &status, 0);
+ logger_finished.store(true);
finish_log_temperature.notify_one();
temperature_logger.join();