diff options
author | Johannes Carlsson <johannes.carlsson.x@sonyericsson.com> | 2010-03-08 10:19:31 +0100 |
---|---|---|
committer | Steve Kondik <shade@chemlab.org> | 2010-04-11 21:20:14 -0400 |
commit | 1cd1c3a3b2a85226d73bad609cf9add4d468a6c2 (patch) | |
tree | cb5ec80bf866aadf4c0b89bbce905ae801b4ed0c | |
parent | 5c91bac141388f5e22402ab1dd309623299390bc (diff) | |
download | android_frameworks_base-1cd1c3a3b2a85226d73bad609cf9add4d468a6c2.tar.gz android_frameworks_base-1cd1c3a3b2a85226d73bad609cf9add4d468a6c2.tar.bz2 android_frameworks_base-1cd1c3a3b2a85226d73bad609cf9add4d468a6c2.zip |
Everytime Bluetooth was turned off two file descriptors were not closed
Using close instead of shutdown on the file descriptors and only clear the file
descriptor that was closed. If both file descriptors are cleared the thread
will not be able to close it.
-rw-r--r-- | core/jni/android_server_BluetoothEventLoop.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/core/jni/android_server_BluetoothEventLoop.cpp b/core/jni/android_server_BluetoothEventLoop.cpp index b9fdcba84c5..286e1f19b67 100644 --- a/core/jni/android_server_BluetoothEventLoop.cpp +++ b/core/jni/android_server_BluetoothEventLoop.cpp @@ -635,7 +635,10 @@ static void *eventLoopMain(void *ptr) { NULL, NULL, NULL, NULL, NULL); tearDownEventLoop(nat); nat->vm->DetachCurrentThread(); - shutdown(nat->controlFdR,SHUT_RDWR); + + int fd = nat->controlFdR; + nat->controlFdR = 0; + close(fd); return NULL; } case EVENT_LOOP_ADD: @@ -724,9 +727,12 @@ static jboolean startEventLoopNative(JNIEnv *env, jobject object) { done: if (JNI_FALSE == result) { - if (nat->controlFdW || nat->controlFdR) { - shutdown(nat->controlFdW, SHUT_RDWR); + if (nat->controlFdW) { + close(nat->controlFdW); nat->controlFdW = 0; + } + if (nat->controlFdR) { + close(nat->controlFdR); nat->controlFdR = 0; } if (nat->me) env->DeleteGlobalRef(nat->me); @@ -763,9 +769,10 @@ static void stopEventLoopNative(JNIEnv *env, jobject object) { nat->watchData = NULL; nat->pollDataSize = 0; nat->pollMemberCount = 0; - shutdown(nat->controlFdW, SHUT_RDWR); + + int fd = nat->controlFdW; nat->controlFdW = 0; - nat->controlFdR = 0; + close(fd); } pthread_mutex_unlock(&(nat->thread_mutex)); #endif // HAVE_BLUETOOTH |