From 5279036148ca158f7c60f793f401604060b1c1ba Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Sun, 9 Aug 2009 10:53:06 -0700 Subject: Be a little more abstract about which connection type use bufferevents --- src/or/main.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/or/main.c') diff --git a/src/or/main.c b/src/or/main.c index 85c99fffc..18473c3b5 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -173,12 +173,22 @@ connection_add(connection_t *conn) smartlist_add(connection_array, conn); #ifdef USE_BUFFEREVENTS - if (conn->type == CONN_TYPE_AP && conn->s >= 0 && !conn->linked) { + if (connection_type_uses_bufferevent(conn) && + conn->s >= 0 && !conn->linked) { conn->bufev = bufferevent_socket_new( tor_libevent_get_base(), conn->s, BEV_OPT_DEFER_CALLBACKS); - + if (conn->inbuf) { + /* XXX Instead we should assert that there is no inbuf, once we + * have linked connections using bufferevents. */ + tor_assert(conn->outbuf); + tor_assert(buf_datalen(conn->inbuf) == 0); + tor_assert(buf_datalen(conn->outbuf) == 0); + buf_free(conn->inbuf); + buf_free(conn->outbuf); + conn->inbuf = conn->outbuf = NULL; + } connection_configure_bufferevent_callbacks(conn); } #endif -- cgit v1.2.3