Skip to content

Commit 04ba27e

Browse files
Mike Smellienmathewson
Mike Smellie
authored andcommitted
Use current event set rather than current pending change when deciding whether to no-op a del
This alters event_changelist_del to quash deletion of events that didn't exist in the first place. As far as I can see, the add,delete, dispatch case described in the original comment will never happen. The recorded change is a single operation, not a queue. This seems to leave actions to delete events that never existed as the real targets for no-oping
1 parent 2570ae5 commit 04ba27e

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

evmap.c

+7-12
Original file line numberDiff line numberDiff line change
@@ -685,14 +685,11 @@ event_changelist_del(struct event_base *base, evutil_socket_t fd, short old, sho
685685
if (!change)
686686
return -1;
687687

688-
/* A delete removes any previous add, rather than replacing it:
689-
on those platforms where "add, delete, dispatch" is not the same
690-
as "no-op, dispatch", we want the no-op behavior.
691-
692-
As well as checking the current operation we should also check
693-
the original set of events to make sure were not ignoring
694-
the case where the add operation is present on an event that
695-
was already set.
688+
/* A delete on an event set that doesn't contain the event to be
689+
deleted produces a no-op. This effectively emoves any previous
690+
uncommitted add, rather than replacing it: on those platforms where
691+
"add, delete, dispatch" is not the same as "no-op, dispatch", we
692+
want the no-op behavior.
696693
697694
If we have a no-op item, we could remove it it from the list
698695
entirely, but really there's not much point: skipping the no-op
@@ -704,15 +701,13 @@ event_changelist_del(struct event_base *base, evutil_socket_t fd, short old, sho
704701
*/
705702

706703
if (events & (EV_READ|EV_SIGNAL)) {
707-
if (!(change->old_events & (EV_READ | EV_SIGNAL)) &&
708-
(change->read_change & EV_CHANGE_ADD))
704+
if (!(change->old_events & (EV_READ | EV_SIGNAL)))
709705
change->read_change = 0;
710706
else
711707
change->read_change = EV_CHANGE_DEL;
712708
}
713709
if (events & EV_WRITE) {
714-
if (!(change->old_events & EV_WRITE) &&
715-
(change->write_change & EV_CHANGE_ADD))
710+
if (!(change->old_events & EV_WRITE))
716711
change->write_change = 0;
717712
else
718713
change->write_change = EV_CHANGE_DEL;

0 commit comments

Comments
 (0)