diff options
author | Nick Mathewson <nickm@torproject.org> | 2009-07-31 11:39:31 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2010-09-27 12:28:43 -0400 |
commit | 200921dc313c7077c5d36aeda4b885e18c29fa70 (patch) | |
tree | 6888b68bdcf6872d2e75aa8d44fa88503b0707da /src/or/connection.h | |
parent | 57e7b54b7b4102de0c5776a1268367c18090033b (diff) | |
download | tor-200921dc313c7077c5d36aeda4b885e18c29fa70.tar.gz tor-200921dc313c7077c5d36aeda4b885e18c29fa70.zip |
Refactor users of buf_datalen to bufferevent-friendly version.
Diffstat (limited to 'src/or/connection.h')
-rw-r--r-- | src/or/connection.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/or/connection.h b/src/or/connection.h index f38927e788..563b48cd86 100644 --- a/src/or/connection.h +++ b/src/or/connection.h @@ -12,6 +12,11 @@ #ifndef _TOR_CONNECTION_H #define _TOR_CONNECTION_H +#ifndef USE_BUFFEREVENTS +/* XXXX For buf_datalen in inline function */ +#include "buffers.h" +#endif + const char *conn_type_to_string(int type); const char *conn_state_to_string(int type, int state); @@ -73,6 +78,29 @@ connection_write_to_buf_zlib(const char *string, size_t len, _connection_write_to_buf_impl(string, len, TO_CONN(conn), done ? -1 : 1); } +static size_t connection_get_inbuf_len(connection_t *conn); +static size_t connection_get_outbuf_len(connection_t *conn); + +static INLINE size_t +connection_get_inbuf_len(connection_t *conn) +{ + IF_HAS_BUFFEREVENT(conn, { + return evbuffer_get_length(bufferevent_get_input(conn->bufev)); + }) ELSE_IF_NO_BUFFEREVENT { + return buf_datalen(conn->inbuf); + } +} + +static INLINE size_t +connection_get_outbuf_len(connection_t *conn) +{ + IF_HAS_BUFFEREVENT(conn, { + return evbuffer_get_length(bufferevent_get_output(conn->bufev)); + }) ELSE_IF_NO_BUFFEREVENT { + return buf_datalen(conn->outbuf); + } +} + connection_t *connection_get_by_global_id(uint64_t id); connection_t *connection_get_by_type(int type); |