summaryrefslogtreecommitdiff
path: root/src/or/main.c
diff options
context:
space:
mode:
authorAndrea Shepard <andrea@torproject.org>2016-06-30 13:27:35 +0000
committerAndrea Shepard <andrea@torproject.org>2016-08-20 01:43:50 +0000
commit2bc19171ef6d3d569b3116ce49e93b20bd9b7449 (patch)
tree2cf3699d7468fdbfd7340a7dfc791d7982931d36 /src/or/main.c
parent4f253d4c676caba979ddf4bc2668273700f279ae (diff)
downloadtor-2bc19171ef6d3d569b3116ce49e93b20bd9b7449.tar.gz
tor-2bc19171ef6d3d569b3116ce49e93b20bd9b7449.zip
Implement connection_count_moribund() for OOS handler
Diffstat (limited to 'src/or/main.c')
-rw-r--r--src/or/main.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/or/main.c b/src/or/main.c
index 261118a81e..30041c5e2b 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -651,6 +651,28 @@ close_closeable_connections(void)
}
}
+/** Count moribund connections for the OOS handler */
+int
+connection_count_moribund(void)
+{
+ int i, moribund = 0;
+ connection_t *conn;
+
+ /*
+ * Count things we'll try to kill when close_closeable_connections()
+ * runs next.
+ */
+ for (i = 0; i < smartlist_len(closeable_connection_lst); ++i) {
+ conn = smartlist_get(closeable_connection_lst, i);
+ if (conn->conn_array_index < 0 ||
+ conn->marked_for_close) {
+ ++moribund;
+ }
+ }
+
+ return moribund;
+}
+
/** Libevent callback: this gets invoked when (connection_t*)<b>conn</b> has
* some data to read. */
static void