summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJared Suttles <jared.suttles@motorola.com>2009-11-04 16:53:44 -0600
committerMike Lockwood <lockwood@android.com>2009-11-06 08:28:58 -0500
commit8b1243e5e4930598e8e78ebd18e7b6cd6fb0445f (patch)
treef30e44a31e78a43f4d9f84e349c54518849bb363
parent0d72f7e9fc0d6f774eda5758d111bec5608bcf42 (diff)
downloadframeworks_base-8b1243e5e4930598e8e78ebd18e7b6cd6fb0445f.zip
frameworks_base-8b1243e5e4930598e8e78ebd18e7b6cd6fb0445f.tar.gz
frameworks_base-8b1243e5e4930598e8e78ebd18e7b6cd6fb0445f.tar.bz2
jni: GpsLocationProvider: Check for pending callbacks before waiting
This change fixes a corner case where a callback may not get handled until a second callback arrives. This can happen because there is a significant section of the wait_for_event function where the mutex is not locked, and the sPendingCallbacks member could be updated. We now check to see if there is a pending callback to handle before we wait for another callback. Change-Id: I20cfae1e780944bb74133940dda032efc4c55540 Signed-off-by: Fred Fettinger <fred.fettinger@motorola.com> Signed-off-by: Jared Suttles <jared.suttles@motorola.com> Signed-off-by: Mike Lockwood <lockwood@android.com>
-rwxr-xr-xcore/jni/android_location_GpsLocationProvider.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/core/jni/android_location_GpsLocationProvider.cpp b/core/jni/android_location_GpsLocationProvider.cpp
index 4aed277..f845878 100755
--- a/core/jni/android_location_GpsLocationProvider.cpp
+++ b/core/jni/android_location_GpsLocationProvider.cpp
@@ -266,7 +266,9 @@ static void android_location_GpsLocationProvider_delete_aiding_data(JNIEnv* env,
static void android_location_GpsLocationProvider_wait_for_event(JNIEnv* env, jobject obj)
{
pthread_mutex_lock(&sEventMutex);
- pthread_cond_wait(&sEventCond, &sEventMutex);
+ while (sPendingCallbacks == 0) {
+ pthread_cond_wait(&sEventCond, &sEventMutex);
+ }
// copy and clear the callback flags
int pendingCallbacks = sPendingCallbacks;