From e8db871de7b26bf4fe7ae8d400c4a2c503cfe3a2 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Mon, 16 Apr 2012 19:30:56 -0700 Subject: [PATCH] double checked locking pattern is not safe on SMP Change-Id: Ie6dd564bdcd45647cb4d62ab259462e3db112576 --- libs/binder/ProcessState.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libs/binder/ProcessState.cpp b/libs/binder/ProcessState.cpp index 9fa412ca1..5399e5288 100644 --- a/libs/binder/ProcessState.cpp +++ b/libs/binder/ProcessState.cpp @@ -73,10 +73,11 @@ protected: sp ProcessState::self() { - if (gProcess != NULL) return gProcess; - - AutoMutex _l(gProcessMutex); - if (gProcess == NULL) gProcess = new ProcessState; + Mutex::Autolock _l(gProcessMutex); + if (gProcess != NULL) { + return gProcess; + } + gProcess = new ProcessState; return gProcess; }