Avoid frequently wait if log tag prop not found (#1580)
This commit is contained in:
parent
223fdb5c10
commit
5fd296e3ad
|
|
@ -249,7 +249,7 @@ void Logcat::EnsureLogWatchDog() {
|
||||||
constexpr static auto kLogdMainSizeProp = "persist.logd.size.main"sv;
|
constexpr static auto kLogdMainSizeProp = "persist.logd.size.main"sv;
|
||||||
constexpr static auto kLogdCrashSizeProp = "persist.logd.size.crash"sv;
|
constexpr static auto kLogdCrashSizeProp = "persist.logd.size.crash"sv;
|
||||||
constexpr static size_t kErr = -1;
|
constexpr static size_t kErr = -1;
|
||||||
std::thread([this] {
|
std::thread watch_dog([this] {
|
||||||
while (true) {
|
while (true) {
|
||||||
auto logd_size = GetByteProp(kLogdSizeProp);
|
auto logd_size = GetByteProp(kLogdSizeProp);
|
||||||
auto logd_tag = GetStrProp(kLogdTagProp);
|
auto logd_tag = GetStrProp(kLogdTagProp);
|
||||||
|
|
@ -276,8 +276,12 @@ void Logcat::EnsureLogWatchDog() {
|
||||||
}
|
}
|
||||||
if (!__system_property_wait(pi, serial, &serial, nullptr)) break;
|
if (!__system_property_wait(pi, serial, &serial, nullptr)) break;
|
||||||
if (pi != nullptr) Log("\nResetting log settings\n");
|
if (pi != nullptr) Log("\nResetting log settings\n");
|
||||||
|
else std::this_thread::sleep_for(1s);
|
||||||
|
// log tag prop was not found; to avoid frequently trigger wait, sleep for a while
|
||||||
}
|
}
|
||||||
}).detach();
|
});
|
||||||
|
pthread_setname_np(watch_dog.native_handle(), "watchdog");
|
||||||
|
watch_dog.detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logcat::Run() {
|
void Logcat::Run() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue