Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 947cb3e8 authored by Alex Vallée's avatar Alex Vallée
Browse files

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
parent 683790ae
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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)

+23 −18
Original line number Diff line number Diff line
@@ -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");