OSDN Git Service

Fix file descriptor leak of layer buffer acquire fences
authorlambdadroid <lambdadroid@gmail.com>
Fri, 11 Jan 2019 16:26:14 +0000 (17:26 +0100)
committerlambdadroid <lambdadroid@gmail.com>
Fri, 11 Jan 2019 16:26:14 +0000 (17:26 +0100)
Even if the layer buffers are not used at the moment (because we
always fallback to client composition), the acquire fences still
need to be closed to avoid leaking file descriptors.

During client composition, SurfaceFlinger will wait for the
layer buffers if necessary.

DrmComposer.cpp

index 255439b..450448d 100644 (file)
@@ -322,7 +322,17 @@ Error DrmComposerHal::setLayerCursorPosition(Display /*displayId*/,
 }
 
 Error DrmComposerHal::setLayerBuffer(Display /*displayId*/, Layer /*layer*/,
-        buffer_handle_t /*buffer*/, int32_t /*acquireFence*/) {
+        buffer_handle_t /*buffer*/, int32_t acquireFence) {
+
+    if (acquireFence >= 0) {
+        /*
+         * This buffer will be only used by client composition.
+         * During client composition, SurfaceFlinger will wait for the buffer
+         * (if necessary), so there is no need to do it here.
+         */
+        close(acquireFence);
+    }
+
     return Error::NONE; // Ignored
 }