diff options
author | Nick Mathewson <nickm@torproject.org> | 2010-02-20 18:44:35 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2010-02-23 15:20:33 -0500 |
commit | d3288293fdc6aef510cc217b171187aac19c444b (patch) | |
tree | b45eac524f5738d98f35b8e4bedc4a11a1bb20ec /bufferevent_filter.c | |
parent | 38ec0a773b73375410cbb5a4eaeece3d0ab1caa0 (diff) | |
download | libevent-d3288293fdc6aef510cc217b171187aac19c444b.tar.gz |
Provide consistent, tested semantics for bufferevent timeouts
The different bufferevent implementations had different behavior for
their timeouts. Some of them kept re-triggering the timeouts
indefinitely; some disabled the event immediately the first time a
timeout triggered. Some of them made the timeouts only count when
the bufferevent was actively trying to read or write; some did not.
The new behavior is modeled after old socket bufferevents, since
they were here first and their behavior is relatively sane.
Basically, each timeout disables the bufferevent's corresponding
read or write operation when it fires. Timeouts are stopped
whenever we suspend writing or reading, and reset whenever we
unsuspend writing or reading. Calling bufferevent_enable resets a
timeout, as does changing the timeout value.
Diffstat (limited to 'bufferevent_filter.c')
-rw-r--r-- | bufferevent_filter.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/bufferevent_filter.c b/bufferevent_filter.c index 16f17b5a..80d2a1bf 100644 --- a/bufferevent_filter.c +++ b/bufferevent_filter.c @@ -222,7 +222,10 @@ static int be_filter_enable(struct bufferevent *bev, short event) { struct bufferevent_filtered *bevf = upcast(bev); - _bufferevent_generic_adj_timeouts(bev); + if (event & EV_READ) + BEV_RESET_GENERIC_READ_TIMEOUT(bev); + if (event & EV_WRITE) + BEV_RESET_GENERIC_WRITE_TIMEOUT(bev); return bufferevent_enable(bevf->underlying, event); } @@ -230,7 +233,10 @@ static int be_filter_disable(struct bufferevent *bev, short event) { struct bufferevent_filtered *bevf = upcast(bev); - _bufferevent_generic_adj_timeouts(bev); + if (event & EV_READ) + BEV_DEL_GENERIC_READ_TIMEOUT(bev); + if (event & EV_WRITE) + BEV_DEL_GENERIC_WRITE_TIMEOUT(bev); return bufferevent_disable(bevf->underlying, event); } |