aboutsummaryrefslogtreecommitdiff
path: root/src/or/connection.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-06-15 11:05:56 -0400
committerNick Mathewson <nickm@torproject.org>2018-06-15 11:05:56 -0400
commitbba998af65c9a414c56824f5779d2c47cf5a6b44 (patch)
treee6fae8b65f5484e442e531f0a8f648805f96cb19 /src/or/connection.c
parentbcc283bcc90ed5ef6f8da22b63df01aea1794b2a (diff)
downloadtor-bba998af65c9a414c56824f5779d2c47cf5a6b44.tar.gz
tor-bba998af65c9a414c56824f5779d2c47cf5a6b44.zip
Extract connection_t into its own header.
Now the entire connection_t hierarchy is extracted from or.h
Diffstat (limited to 'src/or/connection.c')
-rw-r--r--src/or/connection.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/or/connection.c b/src/or/connection.c
index 3c53301547..867c4d72db 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -183,6 +183,18 @@ TO_LISTENER_CONN(connection_t *c)
return DOWNCAST(listener_connection_t, c);
}
+size_t
+connection_get_inbuf_len(connection_t *conn)
+{
+ return conn->inbuf ? buf_datalen(conn->inbuf) : 0;
+}
+
+size_t
+connection_get_outbuf_len(connection_t *conn)
+{
+ return conn->outbuf ? buf_datalen(conn->outbuf) : 0;
+}
+
/**
* Return the human-readable name for the connection type <b>type</b>
*/
@@ -4835,6 +4847,20 @@ kill_conn_list_for_oos, (smartlist_t *conns))
smartlist_len(conns));
}
+/** Check if a connection is on the way out so the OOS handler doesn't try
+ * to kill more than it needs. */
+int
+connection_is_moribund(connection_t *conn)
+{
+ if (conn != NULL &&
+ (conn->conn_array_index < 0 ||
+ conn->marked_for_close)) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
/** Out-of-Sockets handler; n_socks is the current number of open
* sockets, and failed is non-zero if a socket exhaustion related
* error immediately preceded this call. This is where to do