diff options
author | Chih-Chung Chang <chihchung@google.com> | 2010-07-01 21:06:45 +0800 |
---|---|---|
committer | Steve Kondik <shade@chemlab.org> | 2010-07-22 17:11:37 -0400 |
commit | 801adc2b4f5e04b9c5082bc11b824f29370bd33b (patch) | |
tree | b9ce9328a6319de35686e2acde560061b5dace41 /camera | |
parent | afa6c110722ddd01e2c2698c30444c8bfca4db5f (diff) | |
download | frameworks_base-801adc2b4f5e04b9c5082bc11b824f29370bd33b.zip frameworks_base-801adc2b4f5e04b9c5082bc11b824f29370bd33b.tar.gz frameworks_base-801adc2b4f5e04b9c5082bc11b824f29370bd33b.tar.bz2 |
Flush binder buffer after setting raw heap to avoid leaking a reference.
The problem was:
1. In handleShutter(), thread A in CameraService calls
registerBuffers(IMemoryHeap) and it's received by thread B
in system_server. [transaction 1]
2. While thread A is waiting for the reply, thread B calls
back to thread A to get the id of the heap
(IMemoryHeap.getHeapID). [transaction 2]
3. Thread A replies transaction 2 and is preemptied in kernel.
Thread B gets the reply and finishes registerBuffers and send
reply for transaction 1.
4. When thread A runs again, it gets the reply for transaction 1
and returns to handleShutter().
5. At this point the transaction buffer for transaction 2 (which
holds a reference to IMemoryHeap) is not freed because the
BC_FREE_BUFFER command is kept in thread A's local command
queue and not sent to the kernel.
6. Normally when thread A makes next transaction, the
BC_FREE_BUFFER command will be sent together (piggyback) with
the commands for that transaction. But in this case thread A
is a callback thread from camera driver, so it does not make
any binder calls afterwards, and the IMemoryHeap is never freed
(until the next time handleShutter is called).
Change-Id: I435a258187509bdbbaf353339eb9ea577610cbd2
Diffstat (limited to 'camera')
-rw-r--r-- | camera/libcameraservice/CameraService.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/camera/libcameraservice/CameraService.cpp b/camera/libcameraservice/CameraService.cpp index c475414..1ee5635 100644 --- a/camera/libcameraservice/CameraService.cpp +++ b/camera/libcameraservice/CameraService.cpp @@ -967,6 +967,7 @@ void CameraService::Client::handleShutter( mHardware->getRawHeap()); mSurface->registerBuffers(buffers); + IPCThreadState::self()->flushCommands(); } } |