From b5f8520d36f0e6104ddcf40a7a53583670a03ef8 Mon Sep 17 00:00:00 2001 From: wangjianyu3 Date: Thu, 29 Feb 2024 19:42:08 +0800 Subject: [PATCH] system/adb: Set threashold of syslog device to "1" for polling Boards may set default(CONFIG_RAMLOG_POLLTHRESHOLD) to a very large value, causes logcat "can not" get poll notify. Signed-off-by: wangjianyu3 --- system/adb/logcat_service.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/system/adb/logcat_service.c b/system/adb/logcat_service.c index 37405c2eb08..15e9a3bff69 100644 --- a/system/adb/logcat_service.c +++ b/system/adb/logcat_service.c @@ -24,6 +24,7 @@ #include #include +#include #include #include @@ -175,7 +176,9 @@ static void logcat_on_data_available(uv_poll_t * handle, adb_service_t * logcat_service(adb_client_t *client, const char *params) { + int fd; int ret; + logcat_service_t *service = (logcat_service_t *)malloc(sizeof(logcat_service_t)); @@ -189,17 +192,25 @@ adb_service_t * logcat_service(adb_client_t *client, const char *params) /* TODO parse params string to extract logcat parameters */ - ret = open(CONFIG_SYSLOG_DEVPATH, O_RDONLY | O_CLOEXEC); + fd = open(CONFIG_SYSLOG_DEVPATH, O_RDONLY | O_CLOEXEC); + if (fd < 0) + { + adb_err("failed to open %s (%d)\n", CONFIG_SYSLOG_DEVPATH, errno); + free(service); + return NULL; + } + ret = ioctl(fd, PIPEIOC_POLLINTHRD, 1); if (ret < 0) { - adb_err("failed to open %s (%d)\n", CONFIG_SYSLOG_DEVPATH, errno); + adb_err("failed to control %s (%d)\n", CONFIG_SYSLOG_DEVPATH, errno); + close(fd); free(service); return NULL; } uv_handle_t *handle = adb_uv_get_client_handle(client); - ret = uv_poll_init(handle->loop, &service->poll, ret); + ret = uv_poll_init(handle->loop, &service->poll, fd); assert(ret == 0); service->poll.data = client;