summaryrefslogtreecommitdiff
path: root/evmap.c
diff options
context:
space:
mode:
authorMike Smellie <mike.j.smellie@gmail.com>2010-07-19 14:18:31 +1200
committerNick Mathewson <nickm@torproject.org>2010-12-16 13:21:25 -0500
commit04ba27ebf252746a3fdb79422cccd36f1af4be82 (patch)
treea5534c26aaf49d82c6a67cadf24765f1a8349acd /evmap.c
parent2570ae50d3ecd6c9ba5304c20b8f204627162243 (diff)
downloadlibevent-04ba27ebf252746a3fdb79422cccd36f1af4be82.tar.gz
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
Diffstat (limited to 'evmap.c')
-rw-r--r--evmap.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/evmap.c b/evmap.c
index 5521626c..3bcad117 100644
--- a/evmap.c
+++ b/evmap.c
@@ -685,14 +685,11 @@ event_changelist_del(struct event_base *base, evutil_socket_t fd, short old, sho
if (!change)
return -1;
- /* A delete removes any previous add, rather than replacing it:
- on those platforms where "add, delete, dispatch" is not the same
- as "no-op, dispatch", we want the no-op behavior.
-
- As well as checking the current operation we should also check
- the original set of events to make sure were not ignoring
- the case where the add operation is present on an event that
- was already set.
+ /* A delete on an event set that doesn't contain the event to be
+ deleted produces a no-op. This effectively emoves any previous
+ uncommitted add, rather than replacing it: on those platforms where
+ "add, delete, dispatch" is not the same as "no-op, dispatch", we
+ want the no-op behavior.
If we have a no-op item, we could remove it it from the list
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
*/
if (events & (EV_READ|EV_SIGNAL)) {
- if (!(change->old_events & (EV_READ | EV_SIGNAL)) &&
- (change->read_change & EV_CHANGE_ADD))
+ if (!(change->old_events & (EV_READ | EV_SIGNAL)))
change->read_change = 0;
else
change->read_change = EV_CHANGE_DEL;
}
if (events & EV_WRITE) {
- if (!(change->old_events & EV_WRITE) &&
- (change->write_change & EV_CHANGE_ADD))
+ if (!(change->old_events & EV_WRITE))
change->write_change = 0;
else
change->write_change = EV_CHANGE_DEL;