HWComposer: Fix an fd leak on boot with HDMI
authorDan Stoza <stoza@google.com>
Tue, 10 Jun 2014 17:19:10 +0000 (10:19 -0700)
committerDan Stoza <stoza@google.com>
Tue, 10 Jun 2014 17:19:10 +0000 (10:19 -0700)
When the device is booting with an attached external display, every
frame leaks a file descriptor until the display manager enables the
external display, resulting in hundreds of leaked descriptors. This
plugs the leak.

Change-Id: Ib7e2af3638dab28c2ed04c02ddf9c485edf2bb9d

libhwc/hwc.cpp

index 546b047283cae6625d8dd2a94362e1b5d669d2e8..94e8c597ac9ec246748c8b18dcbcf8c141a129cc 100644 (file)
@@ -1616,6 +1616,10 @@ static int exynos5_set_hdmi(exynos5_hwc_composer_device_1_t *pdev,
                     contents->retireFenceFd = merged;
                 }
             } else {
+                if (layer.acquireFenceFd >= 0) {
+                    close(layer.acquireFenceFd);
+                    layer.acquireFenceFd = -1;
+                }
                 hdmi_hide_layer(pdev, pdev->hdmi_layers[1]);
             }
         }