diff options
author | Adrian Salido <salidoa@google.com> | 2016-09-30 14:32:00 -0700 |
---|---|---|
committer | gitbuildkicker <android-build@google.com> | 2016-10-03 17:08:41 -0700 |
commit | 8dd0c162c598cb872823cc367074c0f636f848d1 (patch) | |
tree | fdac63686ade130497740f45ceb37b9ee2cf882c | |
parent | b38dbf65e012488d45a17507c0a761b2a1380def (diff) | |
download | drm_hwcomposer-8dd0c162c598cb872823cc367074c0f636f848d1.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
(cherry picked from commit ff717ff5b00180242041c0bd74d4e26dcfb2d260)
-rw-r--r-- | drmdisplaycompositor.cpp | 10 |
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; |