summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Nelissen <marcone@google.com>2014-09-03 15:52:23 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-09-03 15:52:23 +0000
commitea8462ccd1a882f2c7c785250bcfaa2606b53cb5 (patch)
treee5125d090918b769896b73470f53ba52b80bdf9c
parent23c8cf958b1a756d5e0c78c46eac676676be4fdd (diff)
parent047dd13ca42ff7cea10821ef64eb09229fa3e751 (diff)
downloadframeworks_av-ea8462ccd1a882f2c7c785250bcfaa2606b53cb5.zip
frameworks_av-ea8462ccd1a882f2c7c785250bcfaa2606b53cb5.tar.gz
frameworks_av-ea8462ccd1a882f2c7c785250bcfaa2606b53cb5.tar.bz2
Merge "Fix more potential deadlocks in ALooperRoster" into lmp-dev
-rw-r--r--include/media/stagefright/foundation/ALooperRoster.h2
-rw-r--r--media/libstagefright/foundation/ALooperRoster.cpp41
2 files changed, 12 insertions, 31 deletions
diff --git a/include/media/stagefright/foundation/ALooperRoster.h b/include/media/stagefright/foundation/ALooperRoster.h
index 940fc55..4d76b64 100644
--- a/include/media/stagefright/foundation/ALooperRoster.h
+++ b/include/media/stagefright/foundation/ALooperRoster.h
@@ -56,8 +56,6 @@ private:
KeyedVector<uint32_t, sp<AMessage> > mReplies;
- status_t postMessage_l(const sp<AMessage> &msg, int64_t delayUs);
-
DISALLOW_EVIL_CONSTRUCTORS(ALooperRoster);
};
diff --git a/media/libstagefright/foundation/ALooperRoster.cpp b/media/libstagefright/foundation/ALooperRoster.cpp
index 0f44b52..e0dc768 100644
--- a/media/libstagefright/foundation/ALooperRoster.cpp
+++ b/media/libstagefright/foundation/ALooperRoster.cpp
@@ -99,35 +99,13 @@ void ALooperRoster::unregisterStaleHandlers() {
status_t ALooperRoster::postMessage(
const sp<AMessage> &msg, int64_t delayUs) {
- Mutex::Autolock autoLock(mLock);
- return postMessage_l(msg, delayUs);
-}
-
-status_t ALooperRoster::postMessage_l(
- const sp<AMessage> &msg, int64_t delayUs) {
- ssize_t index = mHandlers.indexOfKey(msg->target());
- if (index < 0) {
- ALOGW("failed to post message '%s'. Target handler not registered.",
- msg->debugString().c_str());
- return -ENOENT;
- }
-
- const HandlerInfo &info = mHandlers.valueAt(index);
-
- sp<ALooper> looper = info.mLooper.promote();
+ sp<ALooper> looper = findLooper(msg->target());
if (looper == NULL) {
- ALOGW("failed to post message. "
- "Target handler %d still registered, but object gone.",
- msg->target());
-
- mHandlers.removeItemsAt(index);
return -ENOENT;
}
-
looper->post(msg, delayUs);
-
return OK;
}
@@ -181,18 +159,23 @@ sp<ALooper> ALooperRoster::findLooper(ALooper::handler_id handlerID) {
status_t ALooperRoster::postAndAwaitResponse(
const sp<AMessage> &msg, sp<AMessage> *response) {
+ sp<ALooper> looper = findLooper(msg->target());
+
+ if (looper == NULL) {
+ ALOGW("failed to post message. "
+ "Target handler %d still registered, but object gone.",
+ msg->target());
+ response->clear();
+ return -ENOENT;
+ }
+
Mutex::Autolock autoLock(mLock);
uint32_t replyID = mNextReplyID++;
msg->setInt32("replyID", replyID);
- status_t err = postMessage_l(msg, 0 /* delayUs */);
-
- if (err != OK) {
- response->clear();
- return err;
- }
+ looper->post(msg, 0 /* delayUs */);
ssize_t index;
while ((index = mReplies.indexOfKey(replyID)) < 0) {