summaryrefslogtreecommitdiff
path: root/src/or/connection.c
diff options
context:
space:
mode:
authorAndrea Shepard <andrea@torproject.org>2016-06-30 13:57:27 +0000
committerAndrea Shepard <andrea@torproject.org>2016-08-20 01:43:50 +0000
commitc76d45bdecb0ac5f11b578919e491957bee41d8f (patch)
treebf034b5c0cbc3fd185d6f590a11911796b26292c /src/or/connection.c
parent2bc19171ef6d3d569b3116ce49e93b20bd9b7449 (diff)
downloadtor-c76d45bdecb0ac5f11b578919e491957bee41d8f.tar.gz
tor-c76d45bdecb0ac5f11b578919e491957bee41d8f.zip
Stub out pick_oos_victims() and kill_conn_list_for_oos()
Diffstat (limited to 'src/or/connection.c')
-rw-r--r--src/or/connection.c39
1 files changed, 35 insertions, 4 deletions
diff --git a/src/or/connection.c b/src/or/connection.c
index 6ef20b2371..fce63adcbe 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -4500,6 +4500,30 @@ connection_reached_eof(connection_t *conn)
}
}
+/** Pick n victim connections for the OOS handler and return them in a
+ * smartlist.
+ */
+static smartlist_t *
+pick_oos_victims(int n)
+{
+ smartlist_t *conns = NULL;
+
+ (void)n;
+
+ /* TODO */
+
+ return conns;
+}
+
+/** Kill a list of connections for the OOS handler. */
+static void
+kill_conn_list_for_oos(smartlist_t *conns)
+{
+ (void)conns;
+
+ /* TODO */
+}
+
/** 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
@@ -4509,6 +4533,7 @@ void
connection_handle_oos(int n_socks, int failed)
{
int target_n_socks = 0, moribund_socks, socks_to_kill;
+ smartlist_t *conns;
/* Sanity-check args */
tor_assert(n_socks >= 0);
@@ -4563,10 +4588,16 @@ connection_handle_oos(int n_socks, int failed)
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);
+
+ conns = pick_oos_victims(socks_to_kill);
+ if (conns) {
+ kill_conn_list_for_oos(conns);
+ log_notice(LD_NET,
+ "OOS handler killed %d conns", smartlist_len(conns));
+ smartlist_free(conns);
+ } else {
+ log_notice(LD_NET, "OOS handler failed to pick any victim conns");
+ }
} else {
log_notice(LD_NET,
"Not killing any sockets for OOS because there are %d "