diff options
author | Nick Mathewson <nickm@torproject.org> | 2009-07-31 11:59:39 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2010-09-27 12:28:43 -0400 |
commit | 076025476ae7facae4c4fcc6211f1faaa615589f (patch) | |
tree | d87ddb175799944306b301b1f430ea1157f0b8c8 /src/or/connection.c | |
parent | 200921dc313c7077c5d36aeda4b885e18c29fa70 (diff) | |
download | tor-076025476ae7facae4c4fcc6211f1faaa615589f.tar tor-076025476ae7facae4c4fcc6211f1faaa615589f.tar.gz |
Add bufferevent versions of connection_write/fetch_to/from_buf.
Diffstat (limited to 'src/or/connection.c')
-rw-r--r-- | src/or/connection.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/or/connection.c b/src/or/connection.c index cf3e9f3c5..861e0c623 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -2609,7 +2609,11 @@ connection_read_to_buf(connection_t *conn, int *max_to_read, int *socket_error) int connection_fetch_from_buf(char *string, size_t len, connection_t *conn) { - return fetch_from_buf(string, len, conn->inbuf); + IF_HAS_BUFFEREVENT(conn, { + return bufferevent_read(conn->bufev, string, len); + }) ELSE_IF_NO_BUFFEREVENT { + return fetch_from_buf(string, len, conn->inbuf); + } } /** Return conn-\>outbuf_flushlen: how many bytes conn wants to flush @@ -2858,6 +2862,14 @@ _connection_write_to_buf_impl(const char *string, size_t len, if (conn->marked_for_close && !conn->hold_open_until_flushed) return; + IF_HAS_BUFFEREVENT(conn, { + if (bufferevent_write(conn->bufev, string, len)<0) { + /* XXXX mark for close? */ + log_warn(LD_NET, "bufferevent_write failed! That shouldn't happen."); + } + return; + }); + old_datalen = buf_datalen(conn->outbuf); if (zlib) { dir_connection_t *dir_conn = TO_DIR_CONN(conn); |