summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrea Shepard <andrea@torproject.org>2016-06-30 10:26:13 +0000
committerAndrea Shepard <andrea@torproject.org>2016-08-20 01:42:30 +0000
commit1c0c0022d8199a9b998a0c4e13a85a382abf7fb0 (patch)
treece1b551959dee91a707b6dd647e9deef9328f4e4 /src
parent5e571900b341b52a3176edaecfb6cbab8829efd1 (diff)
downloadtor-1c0c0022d8199a9b998a0c4e13a85a382abf7fb0.tar.gz
tor-1c0c0022d8199a9b998a0c4e13a85a382abf7fb0.zip
Compute thresholds for OOS from ConnLimit_ when setting options
Diffstat (limited to 'src')
-rw-r--r--src/or/config.c26
-rw-r--r--src/or/or.h4
2 files changed, 30 insertions, 0 deletions
diff --git a/src/or/config.c b/src/or/config.c
index 3fab3b3ec8..33c80e52b0 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -1334,6 +1334,32 @@ options_act_reversible(const or_options_t *old_options, char **msg)
connection_mark_for_close(conn);
}
});
+
+ if (set_conn_limit) {
+ /*
+ * If we adjusted the conn limit, recompute the OOS threshold too
+ *
+ * How many possible sockets to keep in reserve? If we have lots of
+ * possible sockets, keep this below a limit and set ConnLimit_high_thresh
+ * very close to ConnLimit_, but if ConnLimit_ is low, shrink it in
+ * proportion.
+ *
+ * Somewhat arbitrarily, set socks_in_reserve to 5% of ConnLimit_, but
+ * cap it at 64.
+ */
+ int socks_in_reserve = options->ConnLimit_ / 20;
+ if (socks_in_reserve > 64) socks_in_reserve = 64;
+
+ options->ConnLimit_high_thresh = options->ConnLimit_ - socks_in_reserve;
+ options->ConnLimit_low_thresh = (options->ConnLimit_ / 4) * 3;
+ log_info(LD_GENERAL,
+ "Recomputed OOS thresholds: ConnLimit %d, ConnLimit_ %d, "
+ "ConnLimit_high_thresh %d, ConnLimit_low_thresh %d",
+ options->ConnLimit, options->ConnLimit_,
+ options->ConnLimit_high_thresh,
+ options->ConnLimit_low_thresh);
+ }
+
goto done;
rollback:
diff --git a/src/or/or.h b/src/or/or.h
index 1bac43c20a..262085ea62 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -3699,6 +3699,10 @@ typedef struct {
int ConnLimit; /**< Demanded minimum number of simultaneous connections. */
int ConnLimit_; /**< Maximum allowed number of simultaneous connections. */
+ int ConnLimit_high_thresh; /**< start trying to lower socket usage if we
+ * have this many. */
+ int ConnLimit_low_thresh; /**< try to get down to here after socket
+ * exhaustion. */
int RunAsDaemon; /**< If true, run in the background. (Unix only) */
int FascistFirewall; /**< Whether to prefer ORs reachable on open ports. */
smartlist_t *FirewallPorts; /**< Which ports our firewall allows