summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorRonghua Wu <ronghuawu@google.com>2015-11-02 19:27:09 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-11-02 19:27:09 +0000
commit83a22c5c818ebf4f9c80a2dd3fee49258e0c33a6 (patch)
tree07423dde85b3439ea496f4c16cb377feef8d72af /services
parent1d29e126cf152d3400021a2edd5cee123077317e (diff)
parent76d4c7ffa9cdeed39c93d685c9c03b0915262a8b (diff)
downloadframeworks_av-83a22c5c818ebf4f9c80a2dd3fee49258e0c33a6.zip
frameworks_av-83a22c5c818ebf4f9c80a2dd3fee49258e0c33a6.tar.gz
frameworks_av-83a22c5c818ebf4f9c80a2dd3fee49258e0c33a6.tar.bz2
Merge "Reduce lock time for dump to make sure not locked when calling back to IResourceManagerClient." into mnc-dr-dev
Diffstat (limited to 'services')
-rw-r--r--services/mediaresourcemanager/ResourceManagerService.cpp37
1 files changed, 26 insertions, 11 deletions
diff --git a/services/mediaresourcemanager/ResourceManagerService.cpp b/services/mediaresourcemanager/ResourceManagerService.cpp
index 4790754..6781a36 100644
--- a/services/mediaresourcemanager/ResourceManagerService.cpp
+++ b/services/mediaresourcemanager/ResourceManagerService.cpp
@@ -90,11 +90,7 @@ static ResourceInfo& getResourceInfoForEdit(
}
status_t ResourceManagerService::dump(int fd, const Vector<String16>& /* args */) {
- Mutex::Autolock lock(mLock);
-
String8 result;
- const size_t SIZE = 256;
- char buffer[SIZE];
if (checkCallingPermission(String16("android.permission.DUMP")) == false) {
result.format("Permission Denial: "
@@ -105,20 +101,35 @@ status_t ResourceManagerService::dump(int fd, const Vector<String16>& /* args */
return PERMISSION_DENIED;
}
+ PidResourceInfosMap mapCopy;
+ bool supportsMultipleSecureCodecs;
+ bool supportsSecureWithNonSecureCodec;
+ String8 serviceLog;
+ {
+ Mutex::Autolock lock(mLock);
+ mapCopy = mMap; // Shadow copy, real copy will happen on write.
+ supportsMultipleSecureCodecs = mSupportsMultipleSecureCodecs;
+ supportsSecureWithNonSecureCodec = mSupportsSecureWithNonSecureCodec;
+ serviceLog = mServiceLog->toString(" " /* linePrefix */);
+ }
+
+ const size_t SIZE = 256;
+ char buffer[SIZE];
snprintf(buffer, SIZE, "ResourceManagerService: %p\n", this);
result.append(buffer);
result.append(" Policies:\n");
- snprintf(buffer, SIZE, " SupportsMultipleSecureCodecs: %d\n", mSupportsMultipleSecureCodecs);
+ snprintf(buffer, SIZE, " SupportsMultipleSecureCodecs: %d\n", supportsMultipleSecureCodecs);
result.append(buffer);
- snprintf(buffer, SIZE, " SupportsSecureWithNonSecureCodec: %d\n", mSupportsSecureWithNonSecureCodec);
+ snprintf(buffer, SIZE, " SupportsSecureWithNonSecureCodec: %d\n",
+ supportsSecureWithNonSecureCodec);
result.append(buffer);
result.append(" Processes:\n");
- for (size_t i = 0; i < mMap.size(); ++i) {
- snprintf(buffer, SIZE, " Pid: %d\n", mMap.keyAt(i));
+ for (size_t i = 0; i < mapCopy.size(); ++i) {
+ snprintf(buffer, SIZE, " Pid: %d\n", mapCopy.keyAt(i));
result.append(buffer);
- const ResourceInfos &infos = mMap.valueAt(i);
+ const ResourceInfos &infos = mapCopy.valueAt(i);
for (size_t j = 0; j < infos.size(); ++j) {
result.append(" Client:\n");
snprintf(buffer, SIZE, " Id: %lld\n", (long long)infos[j].clientId);
@@ -136,7 +147,7 @@ status_t ResourceManagerService::dump(int fd, const Vector<String16>& /* args */
}
}
result.append(" Events logs (most recent at top):\n");
- result.append(mServiceLog->toString(" " /* linePrefix */));
+ result.append(serviceLog);
write(fd, result.string(), result.size());
return OK;
@@ -307,6 +318,10 @@ bool ResourceManagerService::reclaimResource(
}
}
+ if (failedClient == NULL) {
+ return true;
+ }
+
{
Mutex::Autolock lock(mLock);
bool found = false;
@@ -329,7 +344,7 @@ bool ResourceManagerService::reclaimResource(
}
}
- return (failedClient == NULL);
+ return false;
}
bool ResourceManagerService::getAllClients_l(