Compare commits

..

No commits in common. "1c44b770a8d0f2f31f80eaa02a09dc1bd1481fea" and "6b6dd58a0ef58979e8bacc0c4039e0b80f63819a" have entirely different histories.

4 changed files with 10 additions and 10 deletions

View File

@ -16,9 +16,8 @@ LogEntry::LogEntry(time_t time_, std::string message_) : time(time_), message(st
std::string format_log(const LogEntry& entry) { std::string format_log(const LogEntry& entry) {
struct tm tm;
char time_as_str[128] = {0}; char time_as_str[128] = {0};
strftime(time_as_str, 127 * sizeof(char), "%c", localtime_r(&entry.time, &tm)); strftime(time_as_str, 127 * sizeof(char), "%c", localtime(&entry.time));
return std::string(1, '[') + time_as_str + "] " + entry.message; return std::string(1, '[') + time_as_str + "] " + entry.message;
} }

View File

@ -159,6 +159,9 @@ void LogcatThread::_put_if_not_stopped(LogcatThreadItem item) {
if (this->atomic_ring_buffer.try_put_and_increment_write(item)) { if (this->atomic_ring_buffer.try_put_and_increment_write(item)) {
break; break;
} }
#ifndef NDEBUG
printf("spinlocking!!!\n");
#endif
if (this->_stop_source.stop_requested()) { if (this->_stop_source.stop_requested()) {
break; break;
} }
@ -232,7 +235,7 @@ void LogcatThread::_run_epoll_round() {
} }
} }
void LogcatThread::_try_reap(bool has_request) { void LogcatThread::_try_reap(bool stop_requested) {
int wstatus; int wstatus;
int res = waitpid(this->_logcat_pid, &wstatus, WNOHANG); int res = waitpid(this->_logcat_pid, &wstatus, WNOHANG);
if (res == -1) { if (res == -1) {
@ -256,13 +259,13 @@ void LogcatThread::_try_reap(bool has_request) {
this->logcat_process_running.clear(); this->logcat_process_running.clear();
if (WIFEXITED(wstatus)) { if (WIFEXITED(wstatus)) {
if (WEXITSTATUS(wstatus) && !has_request) { if (WEXITSTATUS(wstatus) && !stop_requested) {
LogEntry log_entry = {time(nullptr), std::string("Logcat exited with ") + std::to_string(WEXITSTATUS(wstatus))}; LogEntry log_entry = {time(nullptr), std::string("Logcat exited with ") + std::to_string(WEXITSTATUS(wstatus))};
print_log(log_entry); print_log(log_entry);
this->_put_if_not_stopped(std::move(log_entry)); this->_put_if_not_stopped(std::move(log_entry));
} }
} else if (WIFSIGNALED(wstatus)) { } else if (WIFSIGNALED(wstatus)) {
if (!has_request) { if (!stop_requested) {
LogEntry log_entry = {time(nullptr), std::string("Logcat exited with -") + std::to_string(WTERMSIG(wstatus))}; LogEntry log_entry = {time(nullptr), std::string("Logcat exited with -") + std::to_string(WTERMSIG(wstatus))};
print_log(log_entry); print_log(log_entry);
this->_put_if_not_stopped(std::move(log_entry)); this->_put_if_not_stopped(std::move(log_entry));
@ -359,7 +362,7 @@ bool LogcatThread::_run_process_round(LogcatProcessRequest request) {
}; };
if (this->_logcat_pid != -1) { if (this->_logcat_pid != -1) {
this->_try_reap(request != LogcatProcessRequest::None); this->_try_reap(request == LogcatProcessRequest::Stop);
} }
return task_done; return task_done;

View File

@ -22,9 +22,8 @@ static inline void render_table(ImFont* monospace_font, bool* autoscrolling) {
size_t i = static_cast<size_t>(i_u); size_t i = static_cast<size_t>(i_u);
const LogEntry* log_entry = &log_entries[i]; const LogEntry* log_entry = &log_entries[i];
struct tm tm;
char time_as_str[128] = {0}; char time_as_str[128] = {0};
strftime(time_as_str, 127 * sizeof(char), "%c", localtime_r(&log_entry->time, &tm)); strftime(time_as_str, 127 * sizeof(char), "%c", localtime(&log_entry->time));
ImGui::TableNextRow(); ImGui::TableNextRow();
if (ImGui::TableSetColumnIndex(0)) ImGui::TextUnformatted(time_as_str); if (ImGui::TableSetColumnIndex(0)) ImGui::TextUnformatted(time_as_str);

View File

@ -27,9 +27,8 @@ static inline void render_table(ImFont* monospace_font, std::vector<LogcatEntry>
while (clipper.Step()) { while (clipper.Step()) {
for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) { for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) {
const LogcatEntry* logcat_entry = &logcat_entries[filtered_logcat_entry_offsets[static_cast<size_t>(i)]]; const LogcatEntry* logcat_entry = &logcat_entries[filtered_logcat_entry_offsets[static_cast<size_t>(i)]];
struct tm tm;
char time_as_str[128] = {0}; char time_as_str[128] = {0};
strftime(time_as_str, 127 * sizeof(char), "%c", localtime_r(&logcat_entry->time, &tm)); strftime(time_as_str, 127 * sizeof(char), "%c", localtime(&logcat_entry->time));
ImGui::TableNextRow(); ImGui::TableNextRow();
if (ImGui::TableSetColumnIndex(0)) ImGui::TextUnformatted(time_as_str); if (ImGui::TableSetColumnIndex(0)) ImGui::TextUnformatted(time_as_str);