aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/crypto.c13
-rw-r--r--src/or/circuituse.c6
-rw-r--r--src/test/test_scheduler.c28
3 files changed, 41 insertions, 6 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c
index 80137b0d88..380f038f42 100644
--- a/src/common/crypto.c
+++ b/src/common/crypto.c
@@ -2875,8 +2875,17 @@ crypto_strongest_rand_syscall(uint8_t *out, size_t out_len)
tor_assert(errno != EAGAIN);
tor_assert(errno != EINTR);
- /* Probably ENOSYS. */
- log_warn(LD_CRYPTO, "Can't get entropy from getrandom().");
+ /* Useful log message for errno. */
+ if (errno == ENOSYS) {
+ log_warn(LD_CRYPTO, "Can't get entropy from getrandom(). "
+ " You are running a version of Tor built to support"
+ " getrandom(), but the kernel doesn't implement this"
+ " implement this function--probably because it is too old?");
+ } else {
+ log_warn(LD_CRYPTO, "Can't get entropy from getrandom(): %s.",
+ strerror(errno));
+ }
+
getrandom_works = 0; /* Don't bother trying again. */
return -1;
/* LCOV_EXCL_STOP */
diff --git a/src/or/circuituse.c b/src/or/circuituse.c
index aa0df95652..ebaa46e301 100644
--- a/src/or/circuituse.c
+++ b/src/or/circuituse.c
@@ -1001,7 +1001,7 @@ circuit_remove_handled_ports(smartlist_t *needed_ports)
tor_assert(*port);
if (circuit_stream_is_being_handled(NULL, *port,
MIN_CIRCUITS_HANDLING_STREAM)) {
-// log_debug(LD_CIRC,"Port %d is already being handled; removing.", port);
+ log_debug(LD_CIRC,"Port %d is already being handled; removing.", *port);
smartlist_del(needed_ports, i--);
tor_free(port);
} else {
@@ -1038,6 +1038,10 @@ circuit_stream_is_being_handled(entry_connection_t *conn,
continue;
if (origin_circ->unusable_for_new_conns)
continue;
+ if (origin_circ->isolation_values_set &&
+ (conn == NULL ||
+ !connection_edge_compatible_with_circuit(conn, origin_circ)))
+ continue;
exitnode = build_state_get_exit_node(build_state);
if (exitnode && (!need_uptime || build_state->need_uptime)) {
diff --git a/src/test/test_scheduler.c b/src/test/test_scheduler.c
index d679d7cfe1..63add2f382 100644
--- a/src/test/test_scheduler.c
+++ b/src/test/test_scheduler.c
@@ -807,6 +807,7 @@ test_scheduler_loop_kist(void *arg)
#endif
channel_t *ch1 = new_fake_channel(), *ch2 = new_fake_channel();
+ channel_t *ch3 = new_fake_channel();
/* setup options so we're sure about what sched we are running */
MOCK(get_options, mock_get_options);
@@ -857,14 +858,35 @@ test_scheduler_loop_kist(void *arg)
the_scheduler->run();
channel_flush_some_cells_mock_free_all();
- tt_int_op(1,==,1);
+
+ /* We'll try to run this closed channel threw the scheduler loop and make
+ * sure it ends up in the right state. */
+ tt_assert(ch3);
+ ch3->magic = TLS_CHAN_MAGIC;
+ ch3->state = CHANNEL_STATE_OPEN;
+ ch3->cmux = circuitmux_alloc();
+ channel_register(ch3);
+ tt_assert(ch3->registered);
+
+ ch3->scheduler_state = SCHED_CHAN_WAITING_FOR_CELLS;
+ scheduler_channel_has_waiting_cells(ch3);
+ /* Should be in the pending list now waiting to be handled. */
+ tt_int_op(ch3->scheduler_state, OP_EQ, SCHED_CHAN_PENDING);
+ tt_int_op(smartlist_len(get_channels_pending()), OP_EQ, 1);
+ /* By running the scheduler on a closed channel, it should end up in the
+ * IDLE state and not in the pending channel list. */
+ ch3->state = CHANNEL_STATE_CLOSED;
+ the_scheduler->run();
+ tt_int_op(ch3->scheduler_state, OP_EQ, SCHED_CHAN_IDLE);
+ tt_int_op(smartlist_len(get_channels_pending()), OP_EQ, 0);
done:
/* Prep the channel so the free() function doesn't explode. */
- ch1->state = ch2->state = CHANNEL_STATE_CLOSED;
- ch1->registered = ch2->registered = 0;
+ ch1->state = ch2->state = ch3->state = CHANNEL_STATE_CLOSED;
+ ch1->registered = ch2->registered = ch3->registered = 0;
channel_free(ch1);
channel_free(ch2);
+ channel_free(ch3);
UNMOCK(update_socket_info_impl);
UNMOCK(channel_should_write_to_kernel);
UNMOCK(channel_write_to_kernel);