Use net_is_completely_disabled() in connection.c

This fixes the XXXX case that we had before, and also enforces the
rule that we won't open connections when we're in hard hibernation.
This commit is contained in:
Nick Mathewson 2018-05-09 12:26:50 -04:00
parent 7595eae52a
commit fa7847e450

View File

@ -1762,13 +1762,13 @@ connection_connect_sockaddr,(connection_t *conn,
tor_assert(sa); tor_assert(sa);
tor_assert(socket_error); tor_assert(socket_error);
if (get_options()->DisableNetwork) { // XXXX change this -NM. if (net_is_completely_disabled()) {
/* We should never even try to connect anyplace if DisableNetwork is set. /* We should never even try to connect anyplace if the network is
* Warn if we do, and refuse to make the connection. * completely shut off.
* *
* We only check DisableNetwork here, not we_are_hibernating(), since * (We don't check net_is_disabled() here, since we still sometimes
* we'll still try to fulfill client requests sometimes in the latter case * want to open connections when we're in soft hibernation.)
* (if it is soft hibernation) */ */
static ratelim_t disablenet_violated = RATELIM_INIT(30*60); static ratelim_t disablenet_violated = RATELIM_INIT(30*60);
*socket_error = SOCK_ERRNO(ENETUNREACH); *socket_error = SOCK_ERRNO(ENETUNREACH);
log_fn_ratelim(&disablenet_violated, LOG_WARN, LD_BUG, log_fn_ratelim(&disablenet_violated, LOG_WARN, LD_BUG,