Skip to content

Commit b5f8520

Browse files
JianyuWang0623xiaoxiang781216
authored andcommitted
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 <[email protected]>
1 parent ef95bd8 commit b5f8520

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

system/adb/logcat_service.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
#include <errno.h>
2626
#include <stdlib.h>
27+
#include <sys/ioctl.h>
2728

2829
#include <nuttx/syslog/ramlog.h>
2930
#include <unistd.h>
@@ -175,7 +176,9 @@ static void logcat_on_data_available(uv_poll_t * handle,
175176

176177
adb_service_t * logcat_service(adb_client_t *client, const char *params)
177178
{
179+
int fd;
178180
int ret;
181+
179182
logcat_service_t *service =
180183
(logcat_service_t *)malloc(sizeof(logcat_service_t));
181184

@@ -189,17 +192,25 @@ adb_service_t * logcat_service(adb_client_t *client, const char *params)
189192

190193
/* TODO parse params string to extract logcat parameters */
191194

192-
ret = open(CONFIG_SYSLOG_DEVPATH, O_RDONLY | O_CLOEXEC);
195+
fd = open(CONFIG_SYSLOG_DEVPATH, O_RDONLY | O_CLOEXEC);
196+
if (fd < 0)
197+
{
198+
adb_err("failed to open %s (%d)\n", CONFIG_SYSLOG_DEVPATH, errno);
199+
free(service);
200+
return NULL;
201+
}
193202

203+
ret = ioctl(fd, PIPEIOC_POLLINTHRD, 1);
194204
if (ret < 0)
195205
{
196-
adb_err("failed to open %s (%d)\n", CONFIG_SYSLOG_DEVPATH, errno);
206+
adb_err("failed to control %s (%d)\n", CONFIG_SYSLOG_DEVPATH, errno);
207+
close(fd);
197208
free(service);
198209
return NULL;
199210
}
200211

201212
uv_handle_t *handle = adb_uv_get_client_handle(client);
202-
ret = uv_poll_init(handle->loop, &service->poll, ret);
213+
ret = uv_poll_init(handle->loop, &service->poll, fd);
203214
assert(ret == 0);
204215

205216
service->poll.data = client;

0 commit comments

Comments
 (0)