diff options
author | Dimitry Ivanov <dimitry@google.com> | 2017-01-19 12:48:27 -0800 |
---|---|---|
committer | Dimitry Ivanov <dimitry@google.com> | 2017-01-23 15:01:05 -0800 |
commit | e74c3ea1e2dfb81eeef00ecc399ef78c37fe7868 (patch) | |
tree | d2714b3783d0c6f61b3f535bf9c91dc8031fca26 | |
parent | c3c04acae68fade4b57b1f61a8f4f8c863154122 (diff) | |
download | vold-nougat-mr2-dev.tar.gz |
Fix deadlock between vold and initandroid-7.1.2_r9android-7.1.2_r8android-7.1.2_r6android-7.1.2_r5android-7.1.2_r4android-7.1.2_r36android-7.1.2_r33android-7.1.2_r32android-7.1.2_r30android-7.1.2_r3android-7.1.2_r29android-7.1.2_r28android-7.1.2_r27android-7.1.2_r25android-7.1.2_r24android-7.1.2_r23android-7.1.2_r2android-7.1.2_r19android-7.1.2_r18android-7.1.2_r17android-7.1.2_r16android-7.1.2_r15android-7.1.2_r14android-7.1.2_r13android-7.1.2_r12android-7.1.2_r11android-7.1.2_r10android-7.1.2_r1nougat-mr2.3-releasenougat-mr2.2-releasenougat-mr2.1-releasenougat-mr2-releasenougat-mr2-pixel-releasenougat-mr2-dev
By setting property after listeners are initialized
we avoid deadlock between vold and init where
vold is waiting on property_service while init is blocked
(and therefore is not able to accept connections) on vdc
which is attempting to communicate with vold.
(This also speeds up boot by 250ms)
Test: Boot a device, check locks and make sure there is no timeout
on property_set(.)
Test: Successfully boot a device with new property service protocol.
Bug: http://b/34278978
Change-Id: I9547d2f19cb35aa452bf01fbff0eb4b32a4824a4
(cherry picked from commit c976e73bbdfd512482d0ea0c5e10afd53ba85e1e)
-rw-r--r-- | main.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
@@ -39,7 +39,7 @@ #include <dirent.h> #include <fs_mgr.h> -static int process_config(VolumeManager *vm); +static int process_config(VolumeManager *vm, bool* has_adoptable); static void coldboot(const char *path); static void parse_args(int argc, char** argv); @@ -106,7 +106,9 @@ int main(int argc, char** argv) { exit(1); } - if (process_config(vm)) { + bool has_adoptable; + + if (process_config(vm, &has_adoptable)) { PLOG(ERROR) << "Error reading configuration... continuing anyways"; } @@ -131,6 +133,10 @@ int main(int argc, char** argv) { exit(1); } + // This call should go after listeners are started to avoid + // a deadlock between vold and init (see b/34278978 for details) + property_set("vold.has_adoptable", has_adoptable ? "1" : "0"); + // Eventually we'll become the monitoring thread while(1) { sleep(1000); @@ -207,7 +213,7 @@ static void coldboot(const char *path) { } } -static int process_config(VolumeManager *vm) { +static int process_config(VolumeManager *vm, bool* has_adoptable) { std::string path(android::vold::DefaultFstabPath()); fstab = fs_mgr_read_fstab(path.c_str()); if (!fstab) { @@ -216,7 +222,7 @@ static int process_config(VolumeManager *vm) { } /* Loop through entries looking for ones that vold manages */ - bool has_adoptable = false; + *has_adoptable = false; for (int i = 0; i < fstab->num_entries; i++) { if (fs_mgr_is_voldmanaged(&fstab->recs[i])) { if (fs_mgr_is_nonremovable(&fstab->recs[i])) { @@ -230,7 +236,7 @@ static int process_config(VolumeManager *vm) { if (fs_mgr_is_encryptable(&fstab->recs[i])) { flags |= android::vold::Disk::Flags::kAdoptable; - has_adoptable = true; + *has_adoptable = true; } if (fs_mgr_is_noemulatedsd(&fstab->recs[i]) || property_get_bool("vold.debug.default_primary", false)) { @@ -241,6 +247,5 @@ static int process_config(VolumeManager *vm) { new VolumeManager::DiskSource(sysPattern, nickname, flags))); } } - property_set("vold.has_adoptable", has_adoptable ? "1" : "0"); return 0; } |