Merge "Remove subproc events when ADB_HOST."
This commit is contained in:
commit
05418442ff
2 changed files with 25 additions and 18 deletions
|
|
@ -365,7 +365,9 @@ ConnectionState connection_state(atransport *t);
|
||||||
|
|
||||||
extern const char *adb_device_banner;
|
extern const char *adb_device_banner;
|
||||||
extern int HOST;
|
extern int HOST;
|
||||||
|
#if !ADB_HOST
|
||||||
extern int SHELL_EXIT_NOTIFY_FD;
|
extern int SHELL_EXIT_NOTIFY_FD;
|
||||||
|
#endif // !ADB_HOST
|
||||||
|
|
||||||
#define CHUNK_SIZE (64*1024)
|
#define CHUNK_SIZE (64*1024)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,9 @@
|
||||||
// This socket is used when a subproc shell service exists.
|
// This socket is used when a subproc shell service exists.
|
||||||
// It wakes up the fdevent_loop() and cause the correct handling
|
// It wakes up the fdevent_loop() and cause the correct handling
|
||||||
// of the shell's pseudo-tty master. I.e. force close it.
|
// of the shell's pseudo-tty master. I.e. force close it.
|
||||||
|
#if !ADB_HOST
|
||||||
int SHELL_EXIT_NOTIFY_FD = -1;
|
int SHELL_EXIT_NOTIFY_FD = -1;
|
||||||
|
#endif // !ADB_HOST
|
||||||
|
|
||||||
static void fatal(const char *fn, const char *fmt, ...)
|
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_enqueue(fdevent *node);
|
||||||
static void fdevent_plist_remove(fdevent *node);
|
static void fdevent_plist_remove(fdevent *node);
|
||||||
static fdevent *fdevent_plist_dequeue(void);
|
static fdevent *fdevent_plist_dequeue(void);
|
||||||
static void fdevent_subproc_event_func(int fd, unsigned events, void *userdata);
|
|
||||||
|
|
||||||
static fdevent list_pending = {
|
static fdevent list_pending = {
|
||||||
.next = &list_pending,
|
.next = &list_pending,
|
||||||
|
|
@ -510,6 +511,7 @@ static void fdevent_call_fdfunc(fdevent* fde)
|
||||||
fde->func(fde->fd, events, fde->arg);
|
fde->func(fde->fd, events, fde->arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !ADB_HOST
|
||||||
static void fdevent_subproc_event_func(int fd, unsigned ev,
|
static void fdevent_subproc_event_func(int fd, unsigned ev,
|
||||||
void* /* userdata */)
|
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 *fdevent_create(int fd, fd_func func, void *arg)
|
||||||
{
|
{
|
||||||
fdevent *fde = (fdevent*) malloc(sizeof(fdevent));
|
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)));
|
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()
|
void fdevent_loop()
|
||||||
{
|
{
|
||||||
fdevent *fde;
|
fdevent *fde;
|
||||||
|
#if !ADB_HOST
|
||||||
fdevent_subproc_setup();
|
fdevent_subproc_setup();
|
||||||
|
#endif // !ADB_HOST
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
D("--- ---- waiting for events\n");
|
D("--- ---- waiting for events\n");
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue