mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-17 21:47:37 +00:00
Minor changes
This commit is contained in:
parent
b0292d7319
commit
f59309a445
@ -37,7 +37,9 @@ void setup_logfile(bool reset) {
|
|||||||
// Maximum message length for pipes to transfer atomically
|
// Maximum message length for pipes to transfer atomically
|
||||||
#define MAX_MSG_LEN (PIPE_BUF - sizeof(log_meta))
|
#define MAX_MSG_LEN (PIPE_BUF - sizeof(log_meta))
|
||||||
|
|
||||||
static void logfile_writer(int pipefd) {
|
static void *logfile_writer(void *arg) {
|
||||||
|
int pipefd = (long) arg;
|
||||||
|
|
||||||
run_finally close_pipes([=] {
|
run_finally close_pipes([=] {
|
||||||
// Close up all logging pipes when thread dies
|
// Close up all logging pipes when thread dies
|
||||||
close(pipefd);
|
close(pipefd);
|
||||||
@ -62,7 +64,7 @@ static void logfile_writer(int pipefd) {
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
// Read meta data
|
// Read meta data
|
||||||
if (read(pipefd, &meta, sizeof(meta)) != sizeof(meta))
|
if (read(pipefd, &meta, sizeof(meta)) != sizeof(meta))
|
||||||
return;
|
return nullptr;
|
||||||
|
|
||||||
if (meta.prio < 0) {
|
if (meta.prio < 0) {
|
||||||
if (!switched) {
|
if (!switched) {
|
||||||
@ -75,7 +77,7 @@ static void logfile_writer(int pipefd) {
|
|||||||
rename(LOGFILE, LOGFILE ".bak");
|
rename(LOGFILE, LOGFILE ".bak");
|
||||||
int fd = open(LOGFILE, O_WRONLY | O_APPEND | O_CREAT | O_CLOEXEC, 0644);
|
int fd = open(LOGFILE, O_WRONLY | O_APPEND | O_CREAT | O_CLOEXEC, 0644);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return;
|
return nullptr;
|
||||||
if (tmp.data)
|
if (tmp.data)
|
||||||
write(fd, tmp.data, tmp.len);
|
write(fd, tmp.data, tmp.len);
|
||||||
|
|
||||||
@ -87,7 +89,7 @@ static void logfile_writer(int pipefd) {
|
|||||||
|
|
||||||
// Read message
|
// Read message
|
||||||
if (read(pipefd, buf, meta.len) != meta.len)
|
if (read(pipefd, buf, meta.len) != meta.len)
|
||||||
return;
|
return nullptr;
|
||||||
|
|
||||||
timeval tv;
|
timeval tv;
|
||||||
tm tm;
|
tm tm;
|
||||||
@ -186,6 +188,7 @@ void start_log_daemon() {
|
|||||||
int fds[2];
|
int fds[2];
|
||||||
if (pipe2(fds, O_CLOEXEC) == 0) {
|
if (pipe2(fds, O_CLOEXEC) == 0) {
|
||||||
logd_fd = fds[1];
|
logd_fd = fds[1];
|
||||||
exec_task([fd = fds[0]] { logfile_writer(fd); });
|
long fd = fds[0];
|
||||||
|
new_daemon_thread(logfile_writer, (void *) fd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ void exec_task(function<void()> &&task) {
|
|||||||
pending_task.swap(task);
|
pending_task.swap(task);
|
||||||
if (available_threads == 0) {
|
if (available_threads == 0) {
|
||||||
++active_threads;
|
++active_threads;
|
||||||
long is_core_pool = active_threads > CORE_POOL_SIZE;
|
long is_core_pool = active_threads <= CORE_POOL_SIZE;
|
||||||
new_daemon_thread(thread_pool_loop, (void *) is_core_pool);
|
new_daemon_thread(thread_pool_loop, (void *) is_core_pool);
|
||||||
} else {
|
} else {
|
||||||
pthread_cond_signal(&send_task);
|
pthread_cond_signal(&send_task);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user