aboutsummaryrefslogtreecommitdiff
path: root/src/or/connection.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/connection.c
parent4f253d4c676caba979ddf4bc2668273700f279ae (diff)
downloadtor-2bc19171ef6d3d569b3116ce49e93b20bd9b7449.tar.gz
tor-2bc19171ef6d3d569b3116ce49e93b20bd9b7449.zip
Implement connection_count_moribund() for OOS handler
Diffstat (limited to 'src/or/connection.c')
-rw-r--r--src/or/connection.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/or/connection.c b/src/or/connection.c
index 77ad56775c..6ef20b2371 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -4508,7 +4508,7 @@ connection_reached_eof(connection_t *conn)
void
connection_handle_oos(int n_socks, int failed)
{
- int target_n_socks = 0;
+ int target_n_socks = 0, moribund_socks, socks_to_kill;
/* Sanity-check args */
tor_assert(n_socks >= 0);
@@ -4554,13 +4554,25 @@ connection_handle_oos(int n_socks, int failed)
/*
* It's an OOS!
*
- * TODO count moribund sockets; it'll be important that anything we decide
+ * Count moribund sockets; it's be important that anything we decide
* to get rid of here but don't immediately close get counted as moribund
* on subsequent invocations so we don't try to kill too many things if
- * this gets called multiple times.
+ * connection_handle_oos() gets called multiple times.
*/
-
- /* TODO pick what to try to close */
+ moribund_socks = connection_count_moribund();
+
+ if (moribund_socks < n_socks - target_n_socks) {
+ socks_to_kill = n_socks - target_n_socks - moribund_socks;
+ /* TODO actually kill them */
+ log_notice(LD_NET,
+ "OOS handler wants to kill %d sockets",
+ socks_to_kill);
+ } else {
+ log_notice(LD_NET,
+ "Not killing any sockets for OOS because there are %d "
+ "already moribund, and we only want to eliminate %d",
+ moribund_socks, n_socks - target_n_socks);
+ }
}
}