From 947cb3e8eeb5583654ceac95e97762f20ff62035 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Vall=C3=A9e?= Date: Fri, 17 Jul 2015 15:30:59 -0400 Subject: [PATCH] Remove subproc events when ADB_HOST. The code which triggers these events (via the SHELL_EXIT_NOTIFY_FD) are only called from code which is already guarded by #if !ADB_HOST. Change-Id: I184414f5e090c1f08ee117e4c8c434cd4a8b5221 --- adb/adb.h | 2 ++ adb/fdevent.cpp | 41 +++++++++++++++++++++++------------------ 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/adb/adb.h b/adb/adb.h index 1be83d7ae..31fe3a5e0 100644 --- a/adb/adb.h +++ b/adb/adb.h @@ -365,7 +365,9 @@ ConnectionState connection_state(atransport *t); extern const char *adb_device_banner; extern int HOST; +#if !ADB_HOST extern int SHELL_EXIT_NOTIFY_FD; +#endif // !ADB_HOST #define CHUNK_SIZE (64*1024) diff --git a/adb/fdevent.cpp b/adb/fdevent.cpp index 0c43c5e9c..54976131b 100644 --- a/adb/fdevent.cpp +++ b/adb/fdevent.cpp @@ -42,7 +42,9 @@ // This socket is used when a subproc shell service exists. // It wakes up the fdevent_loop() and cause the correct handling // of the shell's pseudo-tty master. I.e. force close it. +#if !ADB_HOST int SHELL_EXIT_NOTIFY_FD = -1; +#endif // !ADB_HOST static void fatal(const char *fn, const char *fmt, ...) { @@ -81,7 +83,6 @@ static void dump_fde(fdevent *fde, const char *info) static void fdevent_plist_enqueue(fdevent *node); static void fdevent_plist_remove(fdevent *node); static fdevent *fdevent_plist_dequeue(void); -static void fdevent_subproc_event_func(int fd, unsigned events, void *userdata); static fdevent list_pending = { .next = &list_pending, @@ -510,6 +511,7 @@ static void fdevent_call_fdfunc(fdevent* fde) fde->func(fde->fd, events, fde->arg); } +#if !ADB_HOST static void fdevent_subproc_event_func(int fd, unsigned ev, void* /* userdata */) { @@ -569,6 +571,24 @@ static void fdevent_subproc_event_func(int fd, unsigned ev, } } +void fdevent_subproc_setup() +{ + int s[2]; + + if(adb_socketpair(s)) { + FATAL("cannot create shell-exit socket-pair\n"); + } + D("socketpair: (%d,%d)", s[0], s[1]); + + SHELL_EXIT_NOTIFY_FD = s[0]; + fdevent *fde; + fde = fdevent_create(s[1], fdevent_subproc_event_func, NULL); + if(!fde) + FATAL("cannot create fdevent for shell-exit handler\n"); + fdevent_add(fde, FDE_READ); +} +#endif // !ADB_HOST + fdevent *fdevent_create(int fd, fd_func func, void *arg) { fdevent *fde = (fdevent*) malloc(sizeof(fdevent)); @@ -661,27 +681,12 @@ void fdevent_del(fdevent *fde, unsigned events) fde, (fde->state & FDE_EVENTMASK) & (~(events & FDE_EVENTMASK))); } -void fdevent_subproc_setup() -{ - int s[2]; - - if(adb_socketpair(s)) { - FATAL("cannot create shell-exit socket-pair\n"); - } - D("socketpair: (%d,%d)", s[0], s[1]); - - SHELL_EXIT_NOTIFY_FD = s[0]; - fdevent *fde; - fde = fdevent_create(s[1], fdevent_subproc_event_func, NULL); - if(!fde) - FATAL("cannot create fdevent for shell-exit handler\n"); - fdevent_add(fde, FDE_READ); -} - void fdevent_loop() { fdevent *fde; +#if !ADB_HOST fdevent_subproc_setup(); +#endif // !ADB_HOST for(;;) { D("--- ---- waiting for events\n");