diff options
author | Nick Mathewson <nickm@torproject.org> | 2009-08-09 10:53:06 -0700 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2010-09-27 12:31:13 -0400 |
commit | 5279036148ca158f7c60f793f401604060b1c1ba (patch) | |
tree | de22b4ed42cef2179ffcf17d68f7f870ed3a302f /src/or/main.c | |
parent | 9f8027abfd70c364edbdddb90faa0adfa5547409 (diff) | |
download | tor-5279036148ca158f7c60f793f401604060b1c1ba.tar tor-5279036148ca158f7c60f793f401604060b1c1ba.tar.gz |
Be a little more abstract about which connection type use bufferevents
Diffstat (limited to 'src/or/main.c')
-rw-r--r-- | src/or/main.c | 14 |
1 files changed, 12 insertions, 2 deletions
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 |