[tor-commits] [tor/master] Stub out pick_oos_victims() and kill_conn_list_for_oos()

nickm at torproject.org nickm at torproject.org
Thu Aug 25 18:32:16 UTC 2016


commit c76d45bdecb0ac5f11b578919e491957bee41d8f
Author: Andrea Shepard <andrea at torproject.org>
Date:   Thu Jun 30 13:57:27 2016 +0000

    Stub out pick_oos_victims() and kill_conn_list_for_oos()
---
 src/or/connection.c | 39 +++++++++++++++++++++++++++++++++++----
 1 file changed, 35 insertions(+), 4 deletions(-)

diff --git a/src/or/connection.c b/src/or/connection.c
index 6ef20b2..fce63ad 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 "





More information about the tor-commits mailing list