summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYifan Hong <elsk@google.com>2024-02-01 16:54:36 -0800
committerYifan Hong <elsk@google.com>2024-02-01 17:14:49 -0800
commit6b13e50920d2b6693861eed9c86e81939e05a12e (patch)
treeb0bf2973c71f0367bc31c112d4b8a595ece10b8c
parentcb59ad9732e2e0b5edcf95a86c968e81cbe9a7a7 (diff)
downloadnative-6b13e50920d2b6693861eed9c86e81939e05a12e.tar.gz
lshal: flush at the end of Lshal::main().
The _exit() call in main() terminates the whole process early without debug information properly flushed. That is, the PipeRelay thread might have finished but the written data is not flushed. Hence properly flush at the end of Lshal::main to ensure the debug data is properly written to the output stream. Test: manually with adb shell lshal debug android.hardware.media.c2@1.2::IComponentStore/software Test: manually with adb bugreport then check lshal-debug/android.hardware.media.c2@1.2__IComponentStore_software.txt Bug: 323268003 Bug: 311143089 Change-Id: I792d778eaad0fcd58be12e57c864a1d4c79de2d6
-rw-r--r--cmds/lshal/Lshal.cpp5
-rw-r--r--cmds/lshal/NullableOStream.h5
2 files changed, 10 insertions, 0 deletions
diff --git a/cmds/lshal/Lshal.cpp b/cmds/lshal/Lshal.cpp
index 6115da75b2..5cdcb23d13 100644
--- a/cmds/lshal/Lshal.cpp
+++ b/cmds/lshal/Lshal.cpp
@@ -232,6 +232,11 @@ Status Lshal::main(const Arg &arg) {
return static_cast<HelpCommand*>(help)->usageOfCommand(mCommand);
}
+ // After Lshal::main() finishes, caller may call _exit(), causing debug
+ // information to prematurely ends. Hence flush().
+ err().flush();
+ out().flush();
+
return status;
}
diff --git a/cmds/lshal/NullableOStream.h b/cmds/lshal/NullableOStream.h
index 7cffcf8193..1576486c1d 100644
--- a/cmds/lshal/NullableOStream.h
+++ b/cmds/lshal/NullableOStream.h
@@ -59,6 +59,11 @@ public:
operator bool() const { // NOLINT(google-explicit-constructor)
return mOs != nullptr;
}
+ void flush() {
+ if (mOs) {
+ mOs->flush();
+ }
+ }
private:
template<typename>
friend class NullableOStream;