Browse Source

s/connection_handle_oos/connection_check_oos/g per code review

Andrea Shepard 7 years ago
parent
commit
dbdac1dc27
4 changed files with 28 additions and 28 deletions
  1. 1 1
      src/or/config.c
  2. 11 11
      src/or/connection.c
  3. 1 1
      src/or/connection.h
  4. 15 15
      src/test/test_oos.c

+ 1 - 1
src/or/config.c

@@ -1360,7 +1360,7 @@ options_act_reversible(const or_options_t *old_options, char **msg)
              options->ConnLimit_low_thresh);
 
     /* Give the OOS handler a chance with the new thresholds */
-    connection_handle_oos(get_n_open_sockets(), 0);
+    connection_check_oos(get_n_open_sockets(), 0);
   }
 
   goto done;

+ 11 - 11
src/or/connection.c

@@ -1359,7 +1359,7 @@ connection_listener_new(const struct sockaddr *listensockaddr,
    * Normal exit; call the OOS handler since connection count just changed;
    * the exhaustion flag will always be zero here though.
    */
-  connection_handle_oos(get_n_open_sockets(), 0);
+  connection_check_oos(get_n_open_sockets(), 0);
 
   return conn;
 
@@ -1370,7 +1370,7 @@ connection_listener_new(const struct sockaddr *listensockaddr,
     connection_free(conn);
 
   /* Call the OOS handler, indicate if we saw an exhaustion-related error */
-  connection_handle_oos(get_n_open_sockets(), exhaustion);
+  connection_check_oos(get_n_open_sockets(), exhaustion);
 
   return NULL;
 }
@@ -1467,12 +1467,12 @@ connection_handle_listener_read(connection_t *conn, int new_type)
        *
        * give the OOS handler a chance to run though
        */
-      connection_handle_oos(get_n_open_sockets(), 0);
+      connection_check_oos(get_n_open_sockets(), 0);
       return 0;
     } else if (ERRNO_IS_RESOURCE_LIMIT(e)) {
       warn_too_many_conns();
       /* Exhaustion; tell the OOS handler */
-      connection_handle_oos(get_n_open_sockets(), 1);
+      connection_check_oos(get_n_open_sockets(), 1);
       return 0;
     }
     /* else there was a real error. */
@@ -1480,7 +1480,7 @@ connection_handle_listener_read(connection_t *conn, int new_type)
              tor_socket_strerror(e));
     connection_mark_for_close(conn);
     /* Tell the OOS handler about this too */
-    connection_handle_oos(get_n_open_sockets(), 0);
+    connection_check_oos(get_n_open_sockets(), 0);
     return -1;
   }
   log_debug(LD_NET,
@@ -1488,7 +1488,7 @@ connection_handle_listener_read(connection_t *conn, int new_type)
             (int)news,(int)conn->s);
 
   /* We accepted a new conn; run OOS handler */
-  connection_handle_oos(get_n_open_sockets(), 0);
+  connection_check_oos(get_n_open_sockets(), 0);
 
   if (make_socket_reuseable(news) < 0) {
     if (tor_socket_errno(news) == EINVAL) {
@@ -1701,11 +1701,11 @@ connection_connect_sockaddr,(connection_t *conn,
     *socket_error = tor_socket_errno(s);
     if (ERRNO_IS_RESOURCE_LIMIT(*socket_error)) {
       warn_too_many_conns();
-      connection_handle_oos(get_n_open_sockets(), 1);
+      connection_check_oos(get_n_open_sockets(), 1);
     } else {
       log_warn(LD_NET,"Error creating network socket: %s",
                tor_socket_strerror(*socket_error));
-      connection_handle_oos(get_n_open_sockets(), 0);
+      connection_check_oos(get_n_open_sockets(), 0);
     }
     return -1;
   }
@@ -1720,7 +1720,7 @@ connection_connect_sockaddr,(connection_t *conn,
    * against configuured maximum socket number, but tell it no exhaustion
    * failure.
    */
-  connection_handle_oos(get_n_open_sockets(), 0);
+  connection_check_oos(get_n_open_sockets(), 0);
 
   if (bindaddr && bind(s, bindaddr, bindaddr_len) < 0) {
     *socket_error = tor_socket_errno(s);
@@ -4664,7 +4664,7 @@ kill_conn_list_for_oos, (smartlist_t *conns))
  * circuit-killing heuristics as needed.
  */
 void
-connection_handle_oos(int n_socks, int failed)
+connection_check_oos(int n_socks, int failed)
 {
   int target_n_socks = 0, moribund_socks, socks_to_kill;
   smartlist_t *conns;
@@ -4716,7 +4716,7 @@ connection_handle_oos(int n_socks, int failed)
      * 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
-     * connection_handle_oos() gets called multiple times.
+     * connection_check_oos() gets called multiple times.
      */
     moribund_socks = connection_count_moribund();
 

+ 1 - 1
src/or/connection.h

@@ -247,7 +247,7 @@ void clock_skew_warning(const connection_t *conn, long apparent_skew,
                         int trusted, log_domain_mask_t domain,
                         const char *received, const char *source);
 
-void connection_handle_oos(int n_socks, int failed);
+void connection_check_oos(int n_socks, int failed);
 
 #ifdef CONNECTION_PRIVATE
 STATIC void connection_free_(connection_t *conn);

+ 15 - 15
src/test/test_oos.c

@@ -76,7 +76,7 @@ pick_oos_victims_mock(int n)
 
   if (!pick_oos_mock_fail) {
     /*
-     * connection_handle_oos() just passes the list onto
+     * connection_check_oos() just passes the list onto
      * kill_conn_list_for_oos(); we don't need to simulate
      * its content for this mock, just its existence, but
      * we do need to check the parameter.
@@ -93,14 +93,14 @@ pick_oos_victims_mock(int n)
   return l;
 }
 
-/** Unit test for the logic in connection_handle_oos(), which is concerned
+/** Unit test for the logic in connection_check_oos(), which is concerned
  * with comparing thresholds and connection counts to decide if an OOS has
  * occurred and if so, how many connections to try to kill, and then using
  * pick_oos_victims() and kill_conn_list_for_oos() to carry out its grim
  * duty.
  */
 static void
-test_oos_connection_handle_oos(void *arg)
+test_oos_connection_check_oos(void *arg)
 {
   (void)arg;
 
@@ -123,13 +123,13 @@ test_oos_connection_handle_oos(void *arg)
   MOCK(pick_oos_victims, pick_oos_victims_mock);
 
   /* No OOS case */
-  connection_handle_oos(50, 0);
+  connection_check_oos(50, 0);
   tt_int_op(moribund_calls, OP_EQ, 0);
   tt_int_op(pick_oos_mock_calls, OP_EQ, 0);
   tt_int_op(kill_conn_list_calls, OP_EQ, 0);
 
   /* OOS from socket count, nothing moribund */
-  connection_handle_oos(62, 0);
+  connection_check_oos(62, 0);
   tt_int_op(moribund_calls, OP_EQ, 1);
   tt_int_op(pick_oos_mock_calls, OP_EQ, 1);
   /* 12 == 62 - ConnLimit_low_thresh */
@@ -140,7 +140,7 @@ test_oos_connection_handle_oos(void *arg)
   /* OOS from socket count, some are moribund */
   kill_conn_list_killed = 0;
   moribund_conns = 5;
-  connection_handle_oos(62, 0);
+  connection_check_oos(62, 0);
   tt_int_op(moribund_calls, OP_EQ, 2);
   tt_int_op(pick_oos_mock_calls, OP_EQ, 2);
   /* 7 == 62 - ConnLimit_low_thresh - moribund_conns */
@@ -152,7 +152,7 @@ test_oos_connection_handle_oos(void *arg)
   kill_conn_list_killed = 0;
   moribund_conns = 0;
   pick_oos_mock_fail = 1;
-  connection_handle_oos(62, 0);
+  connection_check_oos(62, 0);
   tt_int_op(moribund_calls, OP_EQ, 3);
   tt_int_op(pick_oos_mock_calls, OP_EQ, 3);
   tt_int_op(kill_conn_list_calls, OP_EQ, 2);
@@ -165,7 +165,7 @@ test_oos_connection_handle_oos(void *arg)
    */
   kill_conn_list_killed = 0;
   moribund_conns = 15;
-  connection_handle_oos(62, 0);
+  connection_check_oos(62, 0);
   tt_int_op(moribund_calls, OP_EQ, 4);
   tt_int_op(pick_oos_mock_calls, OP_EQ, 3);
   tt_int_op(kill_conn_list_calls, OP_EQ, 2);
@@ -176,7 +176,7 @@ test_oos_connection_handle_oos(void *arg)
    */
   kill_conn_list_killed = 0;
   moribund_conns = 0;
-  connection_handle_oos(50, 1);
+  connection_check_oos(50, 1);
   tt_int_op(moribund_calls, OP_EQ, 5);
   tt_int_op(pick_oos_mock_calls, OP_EQ, 4);
   tt_int_op(kill_conn_list_calls, OP_EQ, 3);
@@ -185,7 +185,7 @@ test_oos_connection_handle_oos(void *arg)
   /* OOS from socket exhaustion with moribund conns */
   kill_conn_list_killed = 0;
   moribund_conns = 2;
-  connection_handle_oos(50, 1);
+  connection_check_oos(50, 1);
   tt_int_op(moribund_calls, OP_EQ, 6);
   tt_int_op(pick_oos_mock_calls, OP_EQ, 5);
   tt_int_op(kill_conn_list_calls, OP_EQ, 4);
@@ -194,7 +194,7 @@ test_oos_connection_handle_oos(void *arg)
   /* OOS from socket exhaustion with many moribund conns */
   kill_conn_list_killed = 0;
   moribund_conns = 7;
-  connection_handle_oos(50, 1);
+  connection_check_oos(50, 1);
   tt_int_op(moribund_calls, OP_EQ, 7);
   tt_int_op(pick_oos_mock_calls, OP_EQ, 5);
   tt_int_op(kill_conn_list_calls, OP_EQ, 4);
@@ -202,7 +202,7 @@ test_oos_connection_handle_oos(void *arg)
   /* OOS with both socket exhaustion and above-threshold */
   kill_conn_list_killed = 0;
   moribund_conns = 0;
-  connection_handle_oos(62, 1);
+  connection_check_oos(62, 1);
   tt_int_op(moribund_calls, OP_EQ, 8);
   tt_int_op(pick_oos_mock_calls, OP_EQ, 6);
   tt_int_op(kill_conn_list_calls, OP_EQ, 5);
@@ -214,7 +214,7 @@ test_oos_connection_handle_oos(void *arg)
    */
   kill_conn_list_killed = 0;
   moribund_conns = 5;
-  connection_handle_oos(62, 1);
+  connection_check_oos(62, 1);
   tt_int_op(moribund_calls, OP_EQ, 9);
   tt_int_op(pick_oos_mock_calls, OP_EQ, 7);
   tt_int_op(kill_conn_list_calls, OP_EQ, 6);
@@ -226,7 +226,7 @@ test_oos_connection_handle_oos(void *arg)
    */
   kill_conn_list_killed = 0;
   moribund_conns = 15;
-  connection_handle_oos(62, 1);
+  connection_check_oos(62, 1);
   tt_int_op(moribund_calls, OP_EQ, 10);
   tt_int_op(pick_oos_mock_calls, OP_EQ, 7);
   tt_int_op(kill_conn_list_calls, OP_EQ, 6);
@@ -445,7 +445,7 @@ test_oos_pick_oos_victims(void *arg)
 }
 
 struct testcase_t oos_tests[] = {
-  { "connection_handle_oos", test_oos_connection_handle_oos,
+  { "connection_check_oos", test_oos_connection_check_oos,
     TT_FORK, NULL, NULL },
   { "kill_conn_list", test_oos_kill_conn_list, TT_FORK, NULL, NULL },
   { "pick_oos_victims", test_oos_pick_oos_victims, TT_FORK, NULL, NULL },