From 0a883c18f6063ba088e7eca327e330ae07b539a7 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Mon, 18 Jun 2018 12:49:06 -0700 Subject: updater: Defer the creation of the new data writer. This avoids leaving the created new data writer thread unjoined, in the presence of transfer list parsing errors, or the early exit case on `total_blocks == 0`. Also fix a minor issue when dumping the errno on pthread_create error (pthread_create returns the error number, as opposed to setting errno). Test: Run recovery_component_test on marlin. Change-Id: Icfac27fef0c64736eb8c76264da73c223b4960cb --- updater/blockimg.cpp | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'updater') diff --git a/updater/blockimg.cpp b/updater/blockimg.cpp index ff1d20a78..cdf24f8b1 100644 --- a/updater/blockimg.cpp +++ b/updater/blockimg.cpp @@ -1603,29 +1603,6 @@ static Value* PerformBlockImageUpdate(const char* name, State* state, } } - if (params.canwrite) { - params.nti.za = za; - params.nti.entry = new_entry; - params.nti.brotli_compressed = android::base::EndsWith(new_data_fn->data, ".br"); - if (params.nti.brotli_compressed) { - // Initialize brotli decoder state. - params.nti.brotli_decoder_state = BrotliDecoderCreateInstance(nullptr, nullptr, nullptr); - } - params.nti.receiver_available = true; - - pthread_mutex_init(¶ms.nti.mu, nullptr); - pthread_cond_init(¶ms.nti.cv, nullptr); - pthread_attr_t attr; - pthread_attr_init(&attr); - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); - - int error = pthread_create(¶ms.thread, &attr, unzip_new_data, ¶ms.nti); - if (error != 0) { - PLOG(ERROR) << "pthread_create failed"; - return StringValue(""); - } - } - static constexpr size_t kTransferListHeaderLines = 4; std::vector lines = android::base::Split(transfer_list_value->data, "\n"); if (lines.size() < kTransferListHeaderLines) { @@ -1668,9 +1645,32 @@ static Value* PerformBlockImageUpdate(const char* name, State* state, if (res == -1) { return StringValue(""); } - params.createdstash = res; + // Set up the new data writer. + if (params.canwrite) { + params.nti.za = za; + params.nti.entry = new_entry; + params.nti.brotli_compressed = android::base::EndsWith(new_data_fn->data, ".br"); + if (params.nti.brotli_compressed) { + // Initialize brotli decoder state. + params.nti.brotli_decoder_state = BrotliDecoderCreateInstance(nullptr, nullptr, nullptr); + } + params.nti.receiver_available = true; + + pthread_mutex_init(¶ms.nti.mu, nullptr); + pthread_cond_init(¶ms.nti.cv, nullptr); + pthread_attr_t attr; + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); + + int error = pthread_create(¶ms.thread, &attr, unzip_new_data, ¶ms.nti); + if (error != 0) { + LOG(ERROR) << "pthread_create failed: " << strerror(error); + return StringValue(""); + } + } + // When performing an update, save the index and cmdline of the current command into the // last_command_file. // Upon resuming an update, read the saved index first; then -- cgit v1.2.3 From 69364fe553c8ceda03b5fa2de7d2459d76da8fb7 Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Wed, 20 Jun 2018 14:18:18 +0900 Subject: e2fsdroid and mke2fs are dynamic executable in recovery partition The two utilities are now converted to dynamic executables as shared libraries are supported in recovery mode. As part of the conversion, their location has moved from /sbin to /system/bin. Reflect the change in the program 'recovery' Bug: 79146551 Test: adb reboot recovery, and select 'Wipe data/factory reset'. The data partition is formatted and there is no selinux denial. Change-Id: Ie7cfc4c50ab1e6767e4a5170533ccf826ec7d7f3 --- updater/install.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'updater') diff --git a/updater/install.cpp b/updater/install.cpp index bd22467ab..5dbe4a984 100644 --- a/updater/install.cpp +++ b/updater/install.cpp @@ -511,8 +511,8 @@ Value* FormatFn(const char* name, State* state, const std::vector(e2fsdroid_argv)); if (status != 0) { LOG(ERROR) << name << ": e2fsdroid failed (" << status << ") on " << location; -- cgit v1.2.3