Commit Graph

3221 Commits

Author SHA1 Message Date
Nick Mathewson 52c7a0e26a Allow DirStatus objects to have different timeout floors
This will help when we give Guards a DirStatus as well.
2022-04-04 12:32:19 -04:00
Nick Mathewson 57608f9609 Add RetrySchedule::reset()
Previously the code would do stuff like

```
    schedule = RetrySchedule::new(INITIAL_DELAY);
```

which is needlessly verbose, since the schedule already keeps track
of its initial delay.
2022-04-04 12:32:18 -04:00
Nick Mathewson 75fd63a120 Rename fallback::status::Status to DirStatus.
It's about to be shared between fallbacks and guards.
2022-04-04 12:31:41 -04:00
Nick Mathewson 36440a957c Distinguish UsageMismatch cases by whether a race is possible
This lets us say that the UsageMismatch cases in some parts of the
code reflect a programming error (RetryTime::Never), whereas in
other case it reflects another circuit request getting to the
circuit first (RetryTime::Immediate).
2022-04-04 11:41:00 -04:00
Nick Mathewson 414763b6e2 RetryTime: Improve documentation.
For each case, describe its semantics (in addition to when you would
create it).

Explain the relationship between After and At.

Stop saying "Strategy": we renamed this type to "RetryTime".
2022-04-04 11:22:40 -04:00
Nick Mathewson 81ebbc8e74 RetryTime: make loose_cmp pub. 2022-04-04 11:15:18 -04:00
Nick Mathewson 160cb91669 RetryTime: use strum::EnumDiscriminants to simplify loose_cmp.
Also add tests for RetryTime comparison functions to make sure they
work as expected.
2022-04-04 11:15:18 -04:00
Nick Mathewson 6d8a6b42e7 circmgr: Improve retry-and-or-delay logic.
Use the new RetryTime type and its associates to decide how long to
wait (if at all) between attempts to build a circuit.

Closes #421.

Part of #329.
2022-04-04 11:15:18 -04:00
Nick Mathewson c3b2bcc91e circmgr: implement HasRetryTime. 2022-04-04 11:15:18 -04:00
Nick Mathewson 6872555302 guardmgr: implement HasRetryTime. 2022-04-04 11:15:18 -04:00
Nick Mathewson 936439858b chanmgr: implement HasRetryTime. 2022-04-04 11:15:18 -04:00
Nick Mathewson f7810d42eb circmgr: Improve reporting of error origins.
Previously we did not distinguish errors that came from pending
circuits from errors that came from the circuits we were
building.  We also reported errors as coming from "Left" or "Right",
instead of a more reasonable description.
2022-04-04 11:15:18 -04:00
Nick Mathewson 86c59dd1f3 circmgr: Avoid a race condition in circuit usage restriction
We were treating restrict_mut() failures as internal errors, and
using internal errors to represent them.  But in fact, these
failures are entirely possible based on timing.  Here's how it
happens:

* Two different circuit requests arrive at the same time, and both
  notice a pending circuit that they could use.
* The pending circuit completes; both pending requests are notified.
* The first request calls restrict_mut(), and restricts the request
  in such a way that the second couldn't use it.
* The second request calls restrict_mut(), and gets a failure.

Because of this issue, we treat these errors as transient failures
and just wait for another circuit.

Closes #427.

(This is not a breaking API change, since `AbstractSpec` is a
crate-private trait.)
2022-04-04 11:14:52 -04:00
Nick Mathewson 3676826d03 tor-error: Add a new RetryTime type and related trait. 2022-04-04 11:09:25 -04:00
Nick Mathewson a044d4bcfe Reformat tor-error/Cargo.toml 2022-04-04 11:09:25 -04:00
eta 314f5707b5 Merge branch 'coverage_20220402' into 'main'
Miscellaneous test coverage work

See merge request tpo/core/arti!446
2022-04-04 14:36:17 +00:00
Nick Mathewson 24b30c56db chanmgr: tests for ConnStatus::usable 2022-04-02 16:06:59 -04:00
Nick Mathewson f59f68d32d chanmgr: add a test for AbstractChannel::duration_unused 2022-04-02 16:05:00 -04:00
Nick Mathewson 8d823dd2e5 chanmgr: add tests for connect_one. 2022-04-02 15:50:56 -04:00
Nick Mathewson 58a1e89c8d rtmock: add the ability to make a connection time out. 2022-04-02 15:48:41 -04:00
Nick Mathewson 95c8b518a7 checkable: additional unit tests for more APIs. 2022-04-02 12:19:13 -04:00
Nick Mathewson 3103549cba socksproto: remove some unused accessors. 2022-04-02 12:01:20 -04:00
Nick Mathewson e6c6628adb Update rlimit to 0.8.1
This is necessary to fix build for M1 apples.
2022-04-02 08:10:18 -04:00
Nick Mathewson 52783f9ed1 Cargo.toml: Edit crate list to reflect dependencies 2022-04-01 11:19:32 -04:00
Nick Mathewson 4a3df6a26f Clean out semver_status.md 2022-04-01 11:18:35 -04:00
Nick Mathewson b03bf29259 Merge branch '020_versions' into 'main'
Bump versions in preparation for 0.2.0 release.

See merge request tpo/core/arti!445
2022-04-01 14:34:49 +00:00
Nick Mathewson 5b2fc118df Bump all arti*, tor* crates to 0.2.0
Not all of these strictly need to be bumped to 0.2.0; many could go
to 0.1.1 instead.  But since everything at the tor-rtcompat and
higher layers has had breaking API changes, it seems not so useful
to distinguish.  (It seems unlikely that anybody at this stage is
depending on e.g. tor-protover but not arti-client.)
2022-04-01 09:15:18 -04:00
Nick Mathewson aae242af22 Bump caret, retry-error to 0.1.1
Unlike the rest of the crates, these don't have a "tor-" or "arti-"
prefix, and are potentially used by code outside arti.  With that in
mind, it's probably for the best not to bump them to 0.2.0 along
with the rest of our crates.

They have had no changes since 0.1.0 other than refactoring and
changing of clippy lints.  Therefore, I'm not bumping the
dependencies from other crates onto these: it's fine whether our
other crates use caret/retry-error 0.1.0 or 0.1.1.
2022-04-01 09:14:46 -04:00
Nick Mathewson a7cf65ca0d Update Cargo.lock based on build. 2022-04-01 09:03:25 -04:00
Nick Mathewson 392a176b00 CHANGELOG: Fix another sentence 2022-04-01 09:02:35 -04:00
Nick Mathewson 91982fa123 CHANGELOG: rephrase a sentence. 2022-04-01 08:58:18 -04:00
Nick Mathewson ae387f5eeb Merge branch 'upgrade_pre_020' into 'main'
Run cargo upgrade/update in preparation for 0.2.0

See merge request tpo/core/arti!444
2022-04-01 12:48:50 +00:00
Nick Mathewson 6a1dc1d053 CHANGELOG: spelling fixes 2022-04-01 08:47:21 -04:00
Nick Mathewson 7ce92230eb First attempt at a changelog for 0.2.0 2022-04-01 08:36:59 -04:00
Nick Mathewson 95237e63ce Upgrade async-broadcast => 0.4.0 2022-04-01 08:10:38 -04:00
Nick Mathewson 8393a341e7 Final "cargo update" before 0.2.0 2022-04-01 08:05:38 -04:00
Nick Mathewson 9190dfea77 Upgrade rlimit -> 0.8.0 2022-04-01 08:03:30 -04:00
Nick Mathewson 259622bc3a Merge branch 'dir-munger-v2' into 'main'
Implement a directory munger to simulate pathological cases in arti-testing (v2)

Closes #397

See merge request tpo/core/arti!442
2022-03-31 15:43:28 +00:00
Nick Mathewson 0725e388a5 Re-order attributes so that we can build with Rust 1.53. 2022-03-31 11:11:02 -04:00
Ian Jackson 68b614ade1 Typo fix. 2022-03-31 14:34:11 +00:00
Nick Mathewson e98aa50e72 Directory filtering in arti-testing.
This feature allows us to detect different failing cases for
arti#329 that would otherwise be hard to induce.  It works by
filtering consensus directory objects and/or microdescriptor objects
before introducing them to the directory manager.

Closes #397.
2022-03-31 09:27:27 -04:00
Nick Mathewson b1b7ef00a0 tor-netdoc: Conditionally expose document fields.
This commit uses the `visibility` and `visible` crates to
conditionally make certain structs and their fields public
(respectively).  This is incredibly dangerous to use for anything
besides testing, and I've tried to write the documentation for the
feature accordingly.
2022-03-31 09:27:27 -04:00
Nick Mathewson a461ddc916 Merge branch 'retry_tuning_1' into 'main'
Minor retry tuning to improve behavior under failing conditions.

See merge request tpo/core/arti!439
2022-03-31 12:37:33 +00:00
Nick Mathewson 8a7833dc7e tor-checkable: add experimental api for exposing wrapped objects. 2022-03-31 08:33:27 -04:00
Nick Mathewson 63e366cc8f Reformat tor-checkable/Cargo.toml 2022-03-31 08:33:18 -04:00
Nick Mathewson c5e5fc1553 dirmgr: Use a different idiom in retry loop
Replace the next delay field immediately rather than taking it and
_then_ setting it.  This way, it's never in an incorrect state.
2022-03-31 08:07:50 -04:00
Ian Jackson e6cfbf582e Merge branch 'typos' into 'main'
Fix typo

See merge request tpo/core/arti!441
2022-03-31 10:02:27 +00:00
Dimitris Apostolou ff53886b61
Fix typo 2022-03-30 22:47:33 +03:00
Nick Mathewson 432bb5ce62 Use a lower default for max_retries.
The older default seems (experimentally) to be ridiculously high.
Generally, if we can't build a circuit within a handful attempts,
that circuit has already timed out... unless there is a fast-failure
condition, in which case we're just hammering the network (or our
view of it.)

Found with `arti-testing` for #329.
2022-03-30 14:22:28 -04:00
Nick Mathewson bd798764a4 circmgr: limit circuit attempts when launch_parallelism > 1.
Previously, if we had launch_parallelism > 1, and we were willing to
retry building a circuit max_retries times, then we'd launch up to
max_retries * launch_parallelism circuits before giving up.  Ouch!

With this patch, we try to keep the total number of circuits
planned and attempted to the actual max_retries limit.

Part of #329; found with arti-testing.
2022-03-30 14:14:52 -04:00