From 7391575afdd6c27bf444dcde7a140f1b17629b8c Mon Sep 17 00:00:00 2001 From: Mark Salyzyn Date: Tue, 16 Sep 2014 09:19:47 -0700 Subject: [PATCH] logd: in nonblocking read, sched_yield() synchronization - sched_yield and lock synchronization in reader thread startup to give writer thread a chance to catch up (cherry picked from commit f669acb01880216b6c1d29fc226f2c3ec3a6368a) Bug: 17512203 Change-Id: I43cf0b4e2829b22b3ab4e537fa95ce13c76a869c --- logd/LogReader.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/logd/LogReader.cpp b/logd/LogReader.cpp index 8458c19e9..26df0873f 100644 --- a/logd/LogReader.cpp +++ b/logd/LogReader.cpp @@ -92,6 +92,11 @@ bool LogReader::onDataAvailable(SocketClient *cli) { bool nonBlock = false; if (strncmp(buffer, "dumpAndClose", 12) == 0) { + // Allow writer to get some cycles, and wait for pending notifications + sched_yield(); + LogTimeEntry::lock(); + LogTimeEntry::unlock(); + sched_yield(); nonBlock = true; }