David Goulet [Fri, 29 Sep 2017 18:07:55 +0000 (14:07 -0400)]
sched: Always initialize scheduler_last_run to now
Because our monotonic time interface doesn't play well with value set to 0,
always initialize to now() the scheduler_last_run at init() of the KIST
scheduler.
Fixes #23696
Signed-off-by: David Goulet <dgoulet@torproject.org>
Matt Traudt [Wed, 27 Sep 2017 20:11:05 +0000 (16:11 -0400)]
sched: Don't get KIST stuck in an infinite loop
When a channel is scheduled and flush cells returns 0 that is no cells to
flush, we flag it back in waiting for cells so it doesn't get stuck in a
possible infinite loop.
It has been observed on moria1 where a closed channel end up in the scheduler
where the flush process returned 0 cells but it was ultimately kept in the
scheduling loop forever. We suspect that this is due to a more deeper problem
in tor where the channel_more_to_flush() is actually looking at the wrong
queue and was returning 1 for an empty channel thus putting the channel in the
"Case 4" of the scheduler which is to go back in pending state thus
re-considered at the next iteration.
This is a fix that allows the KIST scheduler to recover properly from a not
entirelly diagnosed problem in tor.
Fixes #23676
Signed-off-by: David Goulet <dgoulet@torproject.org>
Nick Mathewson [Fri, 29 Sep 2017 14:00:14 +0000 (10:00 -0400)]
Clear outbuf_flushlen when we clear a connection's outbuf
When we added single_conn_free_bytes(), we cleared the outbuf on a
connection without setting outbuf_flushlen() to 0. This could cause
an assertion failure later on in flush_buf().
Nick Mathewson [Fri, 29 Sep 2017 13:26:16 +0000 (09:26 -0400)]
Don't package cells onto marked circuits.
This caused a BUG log when we noticed that the circuit had no
channel. The likeliest culprit for exposing that behavior is d769cab3e5097980, where we made circuit_mark_for_close() NULL out
the n_chan and p_chan fields of the circuit.
Alexander Færøy [Thu, 28 Sep 2017 14:46:10 +0000 (16:46 +0200)]
Better error handling when trying to compress/decompress into empty buffer.
This patch ensures that we return TOR_COMPRESS_BUFFER_FULL in case we
have a input bytes left to process, but are out of output buffer or in
case we need to finish where the compression implementation might need
to write an epilogue.
Alexander Færøy [Thu, 28 Sep 2017 14:46:10 +0000 (16:46 +0200)]
Better error handling when trying to compress/decompress into empty buffer.
This patch ensures that we return TOR_COMPRESS_BUFFER_FULL in case we
have a input bytes left to process, but are out of output buffer or in
case we need to finish where the compression implementation might need
to write an epilogue.
Nick Mathewson [Mon, 25 Sep 2017 15:51:15 +0000 (11:51 -0400)]
Correct two state-file variable types.
These should have been int, but we had listed them as unsigned.
That's an easy mistake to make, since "int" corresponds with either
INT or UINT in the configuration file.
This bug cannot have actually caused a problem in practice, since we
check those fields' values on load, and ensure that they are in
range 0..INT32_MAX.
Nick Mathewson [Mon, 25 Sep 2017 15:08:11 +0000 (11:08 -0400)]
Add test to make sure all confparse variables are well-typed
New approach, suggested by Taylor: During testing builds, we
initialize a union member of an appropriate pointer type with the
address of the member field we're trying to test, so we can make
sure that the compiler doesn't warn.
David Goulet [Mon, 25 Sep 2017 20:31:43 +0000 (16:31 -0400)]
hs: Improve logging
Also demote a log message that can occur under natural causes
(if the circuit subsystem is missing descriptors/consensus etc.).
The HS subsystem will naturally retry to connect to intro points,
so no need to make that log user-facing.
David Goulet [Mon, 25 Sep 2017 20:08:11 +0000 (16:08 -0400)]
circuit: Log circuit identifiers when cannibalizing
This removes the "nickname" of the cannibalized circuit last hop as it is
useless. It now logs the n_circ_id and global identifier so we can match it
with other logging statement.
Signed-off-by: David Goulet <dgoulet@torproject.org>
Nick Mathewson [Wed, 6 Sep 2017 18:39:40 +0000 (14:39 -0400)]
Remove or_circuit_t.is_first_hop; use channel_is_client() instead
The is_first_hop field should have been called used_create_fast,
but everywhere that we wanted to check it, we should have been
checking channel_is_client() instead.
Nick Mathewson [Tue, 19 Sep 2017 14:10:38 +0000 (10:10 -0400)]
Make check-spaces part of the standard "make check" process
To do this, we had to make sure it passes when the changes directory
is empty. I also tried to improve the quality of the output, and
fix some false-positive cases. Let's see how this goes!