Commit Graph

2296 Commits

Author SHA1 Message Date
Ian Jackson 0a1cda6886 tor-chanmgr::Error: impl HasKind 2022-02-04 14:42:37 +00:00
Ian Jackson 2a471ffd1a tor-chanmgr: Handle IO errora in the new style
Two ? in the tests become expects, which will do.  That avoids having
to construct a proper error with context here.
2022-02-04 14:42:37 +00:00
Ian Jackson 2101dd5e39 errors: Introduce error_detail feature
Right now we must always expose the `Error` type since we haven't
converted everything.
2022-02-04 14:42:37 +00:00
Ian Jackson 9a293a1f6f errors: Refer to err::Error in some bits of arti_client
We are going to make the top-level Error type conditionally hidden.
2022-02-04 14:42:37 +00:00
Ian Jackson 9e577f9a17 errors: Introduce TorError
Still much to do here.
2022-02-04 14:42:37 +00:00
Ian Jackson 14f67609f7 errors: Initial impl HasKind in arti-client, ErrorKind::TODO
This involves making a temporary ErrorKind::TODO.  That will continue
to exist until all errors (at least, the ones that make it out to
here) can be properly categorised.

Introducing this will let us work from the top and bottom towards the
middle.
2022-02-04 14:42:37 +00:00
Ian Jackson bdd58bb6b7 errors: impl HasKind for GuardMgrError 2022-02-04 14:42:37 +00:00
Ian Jackson a779c1f1dd spawn errors: tor-guardmgr: Use formulaic pattern
This makes this like all the others, and is marginally shorter
2022-02-04 14:42:37 +00:00
Ian Jackson 2f1d98403b spawn errors: Fix tor-dirmgr 2022-02-04 14:42:37 +00:00
Ian Jackson de17c64412 spawn errors: Fix arti-client, tor-chanmgr, tor-circmgr
Provide an enum variant to contain the SpawnError and a From impl.

We use `#[from]` here because it doesn't really make sense to attach
any context, as it's not likely to be very relevant.
2022-02-04 14:42:37 +00:00
Ian Jackson 68d0ec437f spawn errors: impl HasKind for futures::SpawnError
This needs two kinds.  We have decided to treat a non-shutdown
SpawnError as "unexplained" rather than as an InternalError.

There are many crates whose
  From<futures::task::SpawnError> for Error
erroneously treat it as an internal error.  We will fix them in a moment.
2022-02-04 14:42:37 +00:00
Ian Jackson a623982197 tor_persist::Error: impl HasKind and adjust comments
And change the comments to slightly reinterpret these errors, to
relate to the circumstances rather than error generation site.
2022-02-04 14:42:37 +00:00
Ian Jackson 6e1dc612cc tor-error: Add as a ddpendency to many crates
Doing this here makes it easier when I rebase/reorder things
2022-02-04 14:42:37 +00:00
Ian Jackson 89b0c108d7 tor-error: provide into_internal! 2022-02-04 14:42:37 +00:00
Ian Jackson 776270fee2 tor-error: Allow making an `InternalError` from some other error
This can be used in call sites where an error is thought not to be
possible.

The `source` will be used only for formatting messages.
2022-02-04 14:42:37 +00:00
Ian Jackson c963bd648b tor-error: Introduce InternalError as a type and a kind
This can contain a backtrace, which will be printed.
2022-02-04 14:42:37 +00:00
Ian Jackson 9e5b6fa820 tor-error: Skeleton for new crate
As per doc/Errors.md.

Currently there are no error kinds.  Some will be added as we go along.
2022-02-04 14:33:09 +00:00
Ian Jackson a4765717da tor-persist: Distinguish load vs. store json errors
Serialisation errors ought not to occur, since they would represent an
attempt to store malformed data, or something.  (We always convert to
a string, so the JSON error never contains IO errors or the like.)

Deserialisation errors mean the persistent state is corrupt.
2022-02-04 14:33:09 +00:00
Ian Jackson 235cd254ca docs/Errors.md: Say where error type is printed 2022-02-04 14:33:09 +00:00
Ian Jackson 06ce4bba1e docs/Errors.md: Say put context in caller's error (not calllee's) 2022-02-04 14:33:09 +00:00
Ian Jackson a7e6caa731 tor-circmgr: impl Display for TargetPort
This will be used for error handling, and perhaps other things.
2022-02-04 14:33:09 +00:00
Ian Jackson 5edd031b97 tor-linkspec: impl Display for OwnedChanTarget and OwnedCircTarget 2022-02-04 14:33:09 +00:00
Ian Jackson eaa449d373 tor-circmgr: Turn a type annotation comment into code
The type annotation may not be necessary for inference, but as a
comment it risks becoming false.  So it should be uncommented, or
deleted.

Error types round here are not entirely trivial so uncomment it.
2022-02-04 14:33:09 +00:00
eta 4413645c1b Merge branch 'eta/arti-bench-ci' into 'main'
arti-bench: run the benchmarks in CI, and keep the results

See merge request tpo/core/arti!283
2022-02-03 20:35:27 +00:00
eta 05046626f3 arti-bench: run the benchmarks in CI, and keep the results
This adds `arti-bench` to the `integration` job in the CI pipelines, and
keeps around the JSON benchmark output for later comparison.
2022-02-03 18:31:32 +00:00
Ian Jackson bb78e87dc8 Merge branch 'add-better-shellcheck' into 'main'
Remove file ending of shellcheck_all and downgrade_dependencies script

See merge request tpo/core/arti!278
2022-02-03 18:14:58 +00:00
Daniel Schischkin 4509f8b9d4 Remove file ending of shellcheck_all and downgrade_dependencies script 2022-02-03 18:14:57 +00:00
Nick Mathewson e332aa2716 Merge branch 'ticket270' into 'main'
Watch configuration files and reload them when they change

Closes #270

See merge request tpo/core/arti!280
2022-02-03 16:56:37 +00:00
eta e9087e1fed Merge branch 'eta/reactor-2.5' into 'main'
Fix severe reactor ordering problems

See merge request tpo/core/arti!282
2022-02-03 16:27:57 +00:00
Nick Mathewson 49431f5442 Document that `notify` behavior is strange with symlinks
(More specifically, `notify` behaves differently on different
platforms.  On some, it can watch specific directory objects on the
filesystem, and so it only notices when _those_ directories change.
If you change a symlink so that the canonical configuration file
location is now in some other directory, `notify` won't notice.  But
on other platforms, notify just does "stat()" in a loop. On those,
it _will_ notice if the configuration file changes.)
2022-02-03 11:11:21 -05:00
Nick Mathewson 73bb6f342e Merge branch 'add-final-newline-force' into 'main'
Add editorconfig to force some rules (Final Newline)

See merge request tpo/core/arti!289
2022-02-03 15:27:13 +00:00
Daniel Schischkin 3a7412f4cf Add editorconfig to force some rules (Final Newline) 2022-02-03 15:27:13 +00:00
Nick Mathewson 03755a5c7b Merge branch 'dirclient-testing' into 'main'
dir-client: bug fix and more tests

See merge request tpo/core/arti!271
2022-02-03 15:09:06 +00:00
eta 24d12163f2 Fix severe reactor ordering problems
A number of severe problems with the circuit reactor were fixed which
could cause reordering of cells (which causes relays to terminate the
circuit with a protocol violation, as they become unable to decrypt
them). These mostly revolve around improper usage of queues:

- The code assumed that a failure to place cells onto the channel would
  persist for the duration of a reactor cycle run. However, under high
  contention, this wouldn't always be the case.
  - This leads to some cells getting enqueued while others go straight
    through, before the enqueued cells.
  - To fix this, we block sending cells out of the channel while there
    are still some enqueued.
- The hop-specific queues queued after encryption, not before. This was
  very brittle, and led to frequent mis-ordering.
  - This was fixed by making them not do that.

This is arti!264 / 5bce9db562 without the
refactor part.
2022-02-03 15:04:28 +00:00
Nick Mathewson 656ad08d65 Avoid a potential infinite loop in configuration-watching
Since the user can put their logfiles and configuration files in the
same directory, writing to the log can trigger an event from
`notify`.  If we log every non-interesting event from `notify`, then
we'll trigger the logs every time we log, and fill up the disk.

This commit removes the offending log and adds a comment about why.
If we someday decide we do need to log here, maybe we can rate-limit
the messages or something.
2022-02-03 09:38:58 -05:00
Nick Mathewson d90bc353ba Treat rescan events as meaning "reload configuration". 2022-02-03 09:36:12 -05:00
Nick Mathewson 7b8ad0ca2c Explain a testing oddity in tor-dirclient. 2022-02-03 09:17:34 -05:00
Nick Mathewson c302c6a8bd Fix a stale comment in tor-dirclient. 2022-02-03 09:17:10 -05:00
eta cc37c8f5b5 Merge branch 'typos' into 'main'
Fix typos

See merge request tpo/core/arti!285
2022-02-03 13:12:38 +00:00
Nick Mathewson a7e6ef3cd3 Merge branch 'clippy-workaround' into 'main'
Temporarily disable some clippy lints on nightly

See merge request tpo/core/arti!287
2022-02-02 21:57:31 +00:00
Ian Jackson 7be3bf6339 Temporarily disable some clippy lints on nightly 2022-02-02 21:57:30 +00:00
Nick Mathewson 3350b5e8d0 Merge branch 'clippy-fixes' into 'main'
Minor improvements prompted by current nightly clippy

See merge request tpo/core/arti!286
2022-02-02 21:32:36 +00:00
Nick Mathewson ea6458c9bd Add a couple of TODOs about configuration-watching. 2022-02-02 15:43:42 -05:00
Nick Mathewson 42ce00091f Before reloading configuration, drain all pending file changes
This way, if there are a bunch of changes at once, we only reload
one time.
2022-02-02 15:43:42 -05:00
Nick Mathewson fd53c9ddb5 Refactor file-watching code to watch parent directories.
Due to limitations in notify and the OS APIs it uses, it isn't
actually so useful to watch a single file.  Instead, we have to
watch the directories that contain the files, and filter out any
events that aren't about the specific files we care about.

I've put the logic here into a new type, but I've left the type
un-exported: its API is pretty ugly, inasmuch as the caller needs to
jump through hoops to only get the events that they want.  That's
not too bad so long as the API is private, but we'd want better if
we were exposing this.
2022-02-02 15:43:39 -05:00
Ian Jackson 5bfe94eb0e Untangle two needless Ok(r?) into just r
Prompted by clippy::needless_question_mark.  Sometimes Ok(r?) is
needed to do automatic error conversion.  I assume the lint checks for
that.  Anyway, in these cases it's not needed.
2022-02-02 18:35:28 +00:00
Ian Jackson b7fec1c8a4 Remove many needless borrows and slices
Found via clippy::needless_borrow.  In some cases I removed needless
`[..]` too.  See also:
  needless_borrow suggestion doesn't go far enough
  https://github.com/rust-lang/rust-clippy/issues/8389
2022-02-02 18:34:26 +00:00
Ian Jackson b695ebd039 clippy: Pass simply &output to fs::write
clippy::needless_borrow quibbles here, IMO correctly.  Its suggestion
didn't go far enough: output is a String and a &String can be passed
to write as-is for identical effect.
2022-02-02 18:33:23 +00:00
Dimitris Apostolou 6526321851
Fix typos 2022-02-02 20:18:22 +02:00
Nick Mathewson fc33ab273f arti: Limit mut-ness of cfg_sources to one block. 2022-02-02 13:09:54 -05:00