commit 68d78ec5e93c2b48a3d95e9b50c0498580a1d97a Author: Zack Weinberg zackw@cmu.edu Date: Wed Jun 20 14:41:38 2012 -0700
Attempt to prevent event callbacks from firing on partially torn down circuits/connections. --- src/protocol/chop.cc | 18 ++++++++++++++++-- src/protocol/null.cc | 15 +++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/src/protocol/chop.cc b/src/protocol/chop.cc index 0d914d8..cde40b2 100644 --- a/src/protocol/chop.cc +++ b/src/protocol/chop.cc @@ -579,6 +579,15 @@ chop_circuit_t::chop_circuit_t()
chop_circuit_t::~chop_circuit_t() { + // Attempt to prevent events from firing on partially or completely + // torn down circuits. (This shouldn't happen, but it seems to.) + if (this->up_buffer) + bufferevent_disable(this->up_buffer, EV_READ|EV_WRITE); + if (this->flush_timer) + event_del(this->flush_timer); + if (this->axe_timer) + event_del(this->axe_timer); + if (!sent_fin || !received_fin || !upstream_eof) { log_warn(this, "destroying active circuit: fin%c%c eof%c ds=%lu", sent_fin ? '+' : '-', received_fin ? '+' : '-', @@ -1115,12 +1124,17 @@ chop_conn_t::chop_conn_t()
chop_conn_t::~chop_conn_t() { + // Attempt to prevent events from firing on partially or completely + // torn down connections. (This shouldn't happen, but it seems to.) + if (this->buffer) + bufferevent_disable(this->buffer, EV_READ|EV_WRITE); + + if (this->must_send_timer) + event_free(this->must_send_timer); if (upstream) upstream->drop_downstream(this); if (steg) delete steg; - if (must_send_timer) - event_free(must_send_timer); evbuffer_free(recv_pending); }
diff --git a/src/protocol/null.cc b/src/protocol/null.cc index 7467de1..e195cc9 100644 --- a/src/protocol/null.cc +++ b/src/protocol/null.cc @@ -8,6 +8,7 @@ #include "protocol.h"
#include <event2/buffer.h> +#include <event2/event.h>
namespace { struct null_config_t : config_t @@ -134,6 +135,15 @@ null_circuit_t::null_circuit_t()
null_circuit_t::~null_circuit_t() { + // Attempt to prevent events from firing on partially or completely + // torn down circuits. (This shouldn't happen, but it seems to.) + if (this->up_buffer) + bufferevent_disable(this->up_buffer, EV_READ|EV_WRITE); + if (this->flush_timer) + event_del(this->flush_timer); + if (this->axe_timer) + event_del(this->axe_timer); + if (downstream) { /* break the circular reference before deallocating the downstream connection */ @@ -232,6 +242,11 @@ null_conn_t::null_conn_t()
null_conn_t::~null_conn_t() { + // Attempt to prevent events from firing on partially or completely + // torn down connections. (This shouldn't happen, but it seems to.) + if (this->buffer) + bufferevent_disable(this->buffer, EV_READ|EV_WRITE); + if (this->upstream) this->upstream->drop_downstream(this); }
tor-commits@lists.torproject.org