summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitry Ivanov <dimitry@google.com>2017-01-19 12:48:27 -0800
committerDimitry Ivanov <dimitry@google.com>2017-01-23 15:01:05 -0800
commite74c3ea1e2dfb81eeef00ecc399ef78c37fe7868 (patch)
treed2714b3783d0c6f61b3f535bf9c91dc8031fca26
parentc3c04acae68fade4b57b1f61a8f4f8c863154122 (diff)
downloadvold-nougat-mr2-dev.tar.gz
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.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/main.cpp b/main.cpp
index 9cbcf888..68477ac6 100644
--- a/main.cpp
+++ b/main.cpp
@@ -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;
}