Fix endless loop after resetting log prop (#1536)

This commit is contained in:
LoveSy 2022-01-16 00:00:15 +08:00 committed by GitHub
parent 47d88050d3
commit 29781f7a0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 10 deletions

View File

@ -14,11 +14,7 @@ using namespace std::string_view_literals;
using namespace std::chrono_literals;
constexpr size_t kMaxLogSize = 4 * 1024 * 1024;
#ifdef NDEBUG
constexpr size_t kLogBufferSize = 256 * 1024;
#else
constexpr size_t kLogBufferSize = 4 * 1024 * 1024;
#endif
constexpr size_t kLogBufferSize = 64 * 1024;
namespace {
constexpr std::array<char, ANDROID_LOG_SILENT + 1> kLogChar = {
@ -265,16 +261,19 @@ void Logcat::EnsureLogWatchDog() {
(logd_main_size != kErr && logd_main_size >= kLogBufferSize &&
logd_crash_size != kErr &&
logd_crash_size >= kLogBufferSize))) {
SetIntProp(kLogdSizeProp, kLogBufferSize);
SetIntProp(kLogdMainSizeProp, kLogBufferSize);
SetIntProp(kLogdCrashSizeProp, kLogBufferSize);
SetIntProp(kLogdSizeProp, std::max(kLogBufferSize, logd_size));
SetIntProp(kLogdMainSizeProp, std::max(kLogBufferSize, logd_main_size));
SetIntProp(kLogdCrashSizeProp, std::max(kLogBufferSize, logd_crash_size));
SetStrProp(kLogdTagProp, "");
SetStrProp("ctl.start", "logd-reinit");
Log("Reset log settings\n");
}
const auto *pi = __system_property_find(kLogdTagProp.data());
uint32_t serial;
if (!__system_property_wait(pi, 0, &serial, nullptr)) break;
__system_property_read_callback(pi, [](auto *c, auto, auto, auto s) {
*reinterpret_cast<uint32_t *>(c) = s;
}, &serial);
if (!__system_property_wait(pi, serial, &serial, nullptr)) break;
Log("\nResetting log settings\n");
}
}).detach();
}