From f59a4b393f4844c5bbc8d6212364bdddea33d232 Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Tue, 2 Jul 2013 11:15:41 -0700 Subject: fix scheduling policy service death detection Check status of transactions to scheduling policy service and re-acquire a binder interface in case of DEAD_OBJECT. Bug: 8875559. Change-Id: I1e00bd44e2d4723b3ec95d5c31d9652ba08e238a --- services/audioflinger/ISchedulingPolicyService.cpp | 16 +++++++++---- services/audioflinger/SchedulingPolicyService.cpp | 28 +++++++++++++++------- 2 files changed, 31 insertions(+), 13 deletions(-) (limited to 'services') diff --git a/services/audioflinger/ISchedulingPolicyService.cpp b/services/audioflinger/ISchedulingPolicyService.cpp index 0079968..f55bc02 100644 --- a/services/audioflinger/ISchedulingPolicyService.cpp +++ b/services/audioflinger/ISchedulingPolicyService.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#define LOG_TAG "SchedulingPolicyService" +#define LOG_TAG "ISchedulingPolicyService" //#define LOG_NDEBUG 0 #include @@ -45,9 +45,17 @@ public: data.writeInt32(tid); data.writeInt32(prio); uint32_t flags = asynchronous ? IBinder::FLAG_ONEWAY : 0; - remote()->transact(REQUEST_PRIORITY_TRANSACTION, data, &reply, flags); - // fail on exception - if (reply.readExceptionCode() != 0) return -1; + status_t status = remote()->transact(REQUEST_PRIORITY_TRANSACTION, data, &reply, flags); + if (status != NO_ERROR) { + return status; + } + if (asynchronous) { + return NO_ERROR; + } + // fail on exception: force binder reconnection + if (reply.readExceptionCode() != 0) { + return DEAD_OBJECT; + } return reply.readInt32(); } }; diff --git a/services/audioflinger/SchedulingPolicyService.cpp b/services/audioflinger/SchedulingPolicyService.cpp index 36e62e9..70a3f1a 100644 --- a/services/audioflinger/SchedulingPolicyService.cpp +++ b/services/audioflinger/SchedulingPolicyService.cpp @@ -14,6 +14,9 @@ * limitations under the License. */ +#define LOG_TAG "SchedulingPolicyService" +//#define LOG_NDEBUG 0 + #include #include #include "ISchedulingPolicyService.h" @@ -28,25 +31,32 @@ static Mutex sMutex; int requestPriority(pid_t pid, pid_t tid, int32_t prio, bool asynchronous) { // FIXME merge duplicated code related to service lookup, caching, and error recovery - sp sps; + int ret; for (;;) { sMutex.lock(); - sps = sSchedulingPolicyService; + sp sps = sSchedulingPolicyService; sMutex.unlock(); - if (sps != 0) { - break; - } - sp binder = defaultServiceManager()->checkService(_scheduling_policy); - if (binder != 0) { + if (sps == 0) { + sp binder = defaultServiceManager()->checkService(_scheduling_policy); + if (binder == 0) { + sleep(1); + continue; + } sps = interface_cast(binder); sMutex.lock(); sSchedulingPolicyService = sps; sMutex.unlock(); + } + ret = sps->requestPriority(pid, tid, prio, asynchronous); + if (ret != DEAD_OBJECT) { break; } - sleep(1); + ALOGW("SchedulingPolicyService died"); + sMutex.lock(); + sSchedulingPolicyService.clear(); + sMutex.unlock(); } - return sps->requestPriority(pid, tid, prio, asynchronous); + return ret; } } // namespace android -- cgit v1.1