Don't stop the echo server when input is closed
Bug: 383627436
Test: run connectVsock repeatedly
Change-Id: Ie45681f56217d208db35cf7e2449ecb2963f663b
diff --git a/tests/testapk/src/native/testbinary.cpp b/tests/testapk/src/native/testbinary.cpp
index 632f648..7edabfd 100644
--- a/tests/testapk/src/native/testbinary.cpp
+++ b/tests/testapk/src/native/testbinary.cpp
@@ -99,6 +99,9 @@
char* line = nullptr;
size_t size = 0;
if (getline(&line, &size, input) < 0) {
+ if (errno == 0) {
+ return {}; // the input was closed
+ }
return ErrnoError() << "Failed to read";
}
@@ -136,12 +139,12 @@
}
std::thread accept_thread{[listening_fd = std::move(server_fd)] {
- auto result = run_echo_reverse_server(listening_fd);
- if (!result.ok()) {
- __android_log_write(ANDROID_LOG_ERROR, TAG, result.error().message().c_str());
- // Make sure the VM exits so the test will fail solidly
- exit(1);
+ Result<void> result;
+ while ((result = run_echo_reverse_server(listening_fd)).ok()) {
}
+ __android_log_write(ANDROID_LOG_ERROR, TAG, result.error().message().c_str());
+ // Make sure the VM exits so the test will fail solidly
+ exit(1);
}};
accept_thread.detach();