summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2018-06-20 18:20:46 +0200
committerGerrit Code Review <noreply-gerritcodereview@google.com>2018-06-20 18:20:46 +0200
commitddc81680e6ec10cd6e93354f1c310362dd13dcfd (patch)
tree5e3e0e761952b6ab82e846ed9712208d48f98edd
parentMerge "updater_sample: add privileged system app docs" (diff)
parentupdater: Defer the creation of the new data writer. (diff)
downloadandroid_bootable_recovery-ddc81680e6ec10cd6e93354f1c310362dd13dcfd.tar
android_bootable_recovery-ddc81680e6ec10cd6e93354f1c310362dd13dcfd.tar.gz
android_bootable_recovery-ddc81680e6ec10cd6e93354f1c310362dd13dcfd.tar.bz2
android_bootable_recovery-ddc81680e6ec10cd6e93354f1c310362dd13dcfd.tar.lz
android_bootable_recovery-ddc81680e6ec10cd6e93354f1c310362dd13dcfd.tar.xz
android_bootable_recovery-ddc81680e6ec10cd6e93354f1c310362dd13dcfd.tar.zst
android_bootable_recovery-ddc81680e6ec10cd6e93354f1c310362dd13dcfd.zip
Diffstat (limited to '')
-rw-r--r--updater/blockimg.cpp48
1 files changed, 24 insertions, 24 deletions
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(&params.nti.mu, nullptr);
- pthread_cond_init(&params.nti.cv, nullptr);
- pthread_attr_t attr;
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
-
- int error = pthread_create(&params.thread, &attr, unzip_new_data, &params.nti);
- if (error != 0) {
- PLOG(ERROR) << "pthread_create failed";
- return StringValue("");
- }
- }
-
static constexpr size_t kTransferListHeaderLines = 4;
std::vector<std::string> 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(&params.nti.mu, nullptr);
+ pthread_cond_init(&params.nti.cv, nullptr);
+ pthread_attr_t attr;
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+ int error = pthread_create(&params.thread, &attr, unzip_new_data, &params.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