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

Commit 888a748b authored by Spencer Low's avatar Spencer Low
Browse files

adb: fdevent fixes



* fdevent_{set,add,del}()

  * CHECK() that the fdevent is FDE_ACTIVE, otherwise the caller would
    be waiting for events that will never arrive.

  * Remove ~ from "fde->events &= ~events" to keep desired bits instead
    of turning off desired bits.

* fdevent_call_fdfunc()

  * CHECK(FDE_PENDING) since it should always be true if the fdevent was
    on the pending list, or if fdevent_subproc_event_func() is faking
    things. The goal is to try to avoid losing events.

Change-Id: I979c2fffa0b3d6b635488cde11dc544691193018
Signed-off-by: default avatarSpencer Low <CompareAndSwap@gmail.com>
parent dc91dafa
Loading
Loading
Loading
Loading
+10 −11
Original line number Diff line number Diff line
@@ -174,20 +174,19 @@ void fdevent_set(fdevent* fde, unsigned events) {
    if ((fde->state & FDE_EVENTMASK) == events) {
        return;
    }
    if (fde->state & FDE_ACTIVE) {
    CHECK(fde->state & FDE_ACTIVE);
    fdevent_update(fde, events);
    D("fdevent_set: %s, events = %u", dump_fde(fde).c_str(), events);

    if (fde->state & FDE_PENDING) {
        // If we are pending, make sure we don't signal an event that is no longer wanted.
            fde->events &= ~events;
        fde->events &= events;
        if (fde->events == 0) {
            g_pending_list.remove(fde);
            fde->state &= ~FDE_PENDING;
        }
    }
}
}

void fdevent_add(fdevent* fde, unsigned events) {
    fdevent_set(fde, (fde->state & FDE_EVENTMASK) | events);
@@ -262,7 +261,7 @@ static void fdevent_call_fdfunc(fdevent* fde)
{
    unsigned events = fde->events;
    fde->events = 0;
    if(!(fde->state & FDE_PENDING)) return;
    CHECK(fde->state & FDE_PENDING);
    fde->state &= (~FDE_PENDING);
    D("fdevent_call_fdfunc %s", dump_fde(fde).c_str());
    fde->func(fde->fd, events, fde->arg);