summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@android.com>2011-04-05 12:41:35 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-04-05 12:41:35 -0700
commitaefb1ea5b08a612da42e852366acfedcb802a6fd (patch)
tree939224293037c8471a569b2429303a8c9b49d47b /services
parent31c91b335ed95c1b1d1e6c4d521a49f1dd860636 (diff)
parent84338c4559cd675cc8727c44bd1b6ad485b1a272 (diff)
downloadframeworks_base-aefb1ea5b08a612da42e852366acfedcb802a6fd.zip
frameworks_base-aefb1ea5b08a612da42e852366acfedcb802a6fd.tar.gz
frameworks_base-aefb1ea5b08a612da42e852366acfedcb802a6fd.tar.bz2
Merge "Fix deadlock in MountService"
Diffstat (limited to 'services')
-rw-r--r--services/java/com/android/server/MountService.java49
1 files changed, 32 insertions, 17 deletions
diff --git a/services/java/com/android/server/MountService.java b/services/java/com/android/server/MountService.java
index 7e5fd29..3257c26 100644
--- a/services/java/com/android/server/MountService.java
+++ b/services/java/com/android/server/MountService.java
@@ -448,31 +448,46 @@ class MountService extends IMountService.Stub implements INativeDaemonConnectorC
* to make the media scanner run.
*/
if ("simulator".equals(SystemProperties.get("ro.product.device"))) {
- notifyVolumeStateChange(null, "/sdcard", VolumeState.NoMedia, VolumeState.Mounted);
+ notifyVolumeStateChange(null, "/sdcard", VolumeState.NoMedia,
+ VolumeState.Mounted);
return;
}
new Thread() {
@Override
public void run() {
try {
+ // it is not safe to call vold with mVolumeStates locked
+ // so we make a copy of the paths and states and process them
+ // outside the lock
+ String[] paths, states;
+ int count;
synchronized (mVolumeStates) {
- for (String path : mVolumeStates.keySet()) {
- String state = mVolumeStates.get(path);
-
- if (state.equals(Environment.MEDIA_UNMOUNTED)) {
- int rc = doMountVolume(path);
- if (rc != StorageResultCode.OperationSucceeded) {
- Slog.e(TAG, String.format("Boot-time mount failed (%d)",
- rc));
- }
- } else if (state.equals(Environment.MEDIA_SHARED)) {
- /*
- * Bootstrap UMS enabled state since vold indicates
- * the volume is shared (runtime restart while ums enabled)
- */
- notifyVolumeStateChange(null, path, VolumeState.NoMedia,
- VolumeState.Shared);
+ Set<String> keys = mVolumeStates.keySet();
+ count = keys.size();
+ paths = (String[])keys.toArray(new String[count]);
+ states = new String[count];
+ for (int i = 0; i < count; i++) {
+ states[i] = mVolumeStates.get(paths[i]);
+ }
+ }
+
+ for (int i = 0; i < count; i++) {
+ String path = paths[i];
+ String state = states[i];
+
+ if (state.equals(Environment.MEDIA_UNMOUNTED)) {
+ int rc = doMountVolume(path);
+ if (rc != StorageResultCode.OperationSucceeded) {
+ Slog.e(TAG, String.format("Boot-time mount failed (%d)",
+ rc));
}
+ } else if (state.equals(Environment.MEDIA_SHARED)) {
+ /*
+ * Bootstrap UMS enabled state since vold indicates
+ * the volume is shared (runtime restart while ums enabled)
+ */
+ notifyVolumeStateChange(null, path, VolumeState.NoMedia,
+ VolumeState.Shared);
}
}