summaryrefslogtreecommitdiff
path: root/libs/binder/ProcessState.cpp
diff options
context:
space:
mode:
author Wale Ogunwale <ogunwale@google.com> 2015-04-13 16:16:10 -0700
committer Wale Ogunwale <ogunwale@google.com> 2015-04-14 13:17:25 -0700
commit376b822728c582a9deb26ce339deb5204ae4d22e (patch)
tree4da29f139d56f197760860b9e98523396e4bcc7e /libs/binder/ProcessState.cpp
parente88e3669632972fedc85b23a2b108f56222c6eb4 (diff)
Added IPCThreadState::blockUntilThreadAvailable() method.
Will be used by the system_server watchdog to monitor the availability of binder threads in the process to handle incoming IPC requests. Bug: 19297165 Change-Id: I39175f3869ad14da5620fddb47f454e6e4ee2b25
Diffstat (limited to 'libs/binder/ProcessState.cpp')
-rw-r--r--libs/binder/ProcessState.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/libs/binder/ProcessState.cpp b/libs/binder/ProcessState.cpp
index 303d6cf3a2..016d3c54b0 100644
--- a/libs/binder/ProcessState.cpp
+++ b/libs/binder/ProcessState.cpp
@@ -42,12 +42,13 @@
#include <sys/stat.h>
#define BINDER_VM_SIZE ((1*1024*1024) - (4096 *2))
+#define DEFAULT_MAX_BINDER_THREADS 15
// ---------------------------------------------------------------------------
namespace android {
-
+
class PoolThread : public Thread
{
public:
@@ -294,7 +295,9 @@ void ProcessState::spawnPooledThread(bool isMain)
status_t ProcessState::setThreadPoolMaxThreadCount(size_t maxThreads) {
status_t result = NO_ERROR;
- if (ioctl(mDriverFD, BINDER_SET_MAX_THREADS, &maxThreads) == -1) {
+ if (ioctl(mDriverFD, BINDER_SET_MAX_THREADS, &maxThreads) != -1) {
+ mMaxThreads = maxThreads;
+ } else {
result = -errno;
ALOGE("Binder ioctl to set max threads failed: %s", strerror(-result));
}
@@ -322,7 +325,7 @@ static int open_driver()
close(fd);
fd = -1;
}
- size_t maxThreads = 15;
+ size_t maxThreads = DEFAULT_MAX_BINDER_THREADS;
result = ioctl(fd, BINDER_SET_MAX_THREADS, &maxThreads);
if (result == -1) {
ALOGE("Binder ioctl to set max threads failed: %s", strerror(errno));
@@ -336,6 +339,10 @@ static int open_driver()
ProcessState::ProcessState()
: mDriverFD(open_driver())
, mVMStart(MAP_FAILED)
+ , mThreadCountLock(PTHREAD_MUTEX_INITIALIZER)
+ , mThreadCountDecrement(PTHREAD_COND_INITIALIZER)
+ , mExecutingThreadsCount(0)
+ , mMaxThreads(DEFAULT_MAX_BINDER_THREADS)
, mManagesContexts(false)
, mBinderContextCheckFunc(NULL)
, mBinderContextUserData(NULL)