aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Salido <salidoa@google.com>2016-09-30 14:32:00 -0700
committerAdrian Salido <salidoa@google.com>2016-09-30 14:39:44 -0700
commitff717ff5b00180242041c0bd74d4e26dcfb2d260 (patch)
treefdac63686ade130497740f45ceb37b9ee2cf882c
parentb38dbf65e012488d45a17507c0a761b2a1380def (diff)
downloaddrm_hwcomposer-ff717ff5b00180242041c0bd74d4e26dcfb2d260.tar.gz
drm_hwcomposer: limit maximum depth of frame worker queue
Each element of the queue requires use of limited resources (file descriptors). If the queue doesn't get throttled when frame worker is not getting scheduled to consume the elements from it then it can quickly reach max fd limit and cause unexpected behavior such as system crash. Test: run cts including CtsMediaTestCases Bug: 31594201 Change-Id: I77345ae66da5675f4214f42f0c5bfb773bf5fd3f
-rw-r--r--drmdisplaycompositor.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/drmdisplaycompositor.cpp b/drmdisplaycompositor.cpp
index 92323b6..5da9152 100644
--- a/drmdisplaycompositor.cpp
+++ b/drmdisplaycompositor.cpp
@@ -191,6 +191,16 @@ int DrmDisplayCompositor::FrameWorker::Init() {
void DrmDisplayCompositor::FrameWorker::QueueFrame(
std::unique_ptr<DrmDisplayComposition> composition, int status) {
Lock();
+
+ // Block queue if it gets too large. Otherwise composition will
+ // start stacking up and eat limited resources (file descriptors)
+ // allocated for these.
+ while (frame_queue_.size() >= DRM_DISPLAY_COMPOSITOR_MAX_QUEUE_DEPTH) {
+ Unlock();
+ sched_yield();
+ Lock();
+ }
+
FrameState frame;
frame.composition = std::move(composition);
frame.status = status;