Re-enable EV_READ if disabled and outbuf empty

The event buffer write handler failes to re-enable the corresponding
read event of the opposite connection if the buffer is not only down to
less than half the limit, but completely emptied.  In that case, the
read event would never be re-enabled and the connection would stall and
time out.

Issue:		#109
Patch by:	Eun Soo Park
pull/13/head
Daniel Roethlisberger 9 years ago
parent 02ab680b34
commit 2bcfaf4b44

@ -14,6 +14,7 @@ patches or pull requests, in chronological order of their first contribution:
- Adam Jacob Muller ([AdamJacobMuller](https://github.com/AdamJacobMuller))
- Richard Poole ([RichardPoole42](https://github.com/RichardPoole42))
- Maciej Kotowicz ([mak](https://github.com/mak))
- Eun Soo Park ([eunsoopark](https://github.com/eunsoopark))
Many more individuals have contributed by reporting bugs or feature requests.
See [issue tracker on Github][1], `NEWS.md` and `git log` for details.

@ -1,6 +1,8 @@
### SSLsplit develop
- Fix EV_READ event re-enable bug that could lead to stalled connections
after throttling one direction (issue #109).
- Add contributed -L log parsing scripts to extra/, including conversion to
PCAP using emulated IP and TCP headers (contributed by @mak, issue #27).
- Only initialize DNS subsystems when DNS lookups are actually needed by the

@ -1664,15 +1664,17 @@ pxy_bev_writecb(struct bufferevent *bev, void *arg)
}
#endif /* DEBUG_PROXY */
struct evbuffer *outbuf = bufferevent_get_output(bev);
if (evbuffer_get_length(outbuf) > 0) {
if (!(bufferevent_get_enabled(other->bev) & EV_READ)) {
/* data source temporarily disabled;
* re-enable and reset watermark to 0. */
bufferevent_setwatermark(bev, EV_WRITE, 0, 0);
if (!other->closed) {
bufferevent_enable(other->bev, EV_READ);
}
} else if (other->closed) {
}
struct evbuffer *outbuf = bufferevent_get_output(bev);
if (evbuffer_get_length(outbuf) == 0 && other->closed) {
/* finished writing and other end is closed;
* close this end too and clean up memory */
bufferevent_free_and_close_fd(bev, ctx);

Loading…
Cancel
Save