| Commit message (Collapse) | Author | Age | Files | Lines |
| | |
|
| |\
| |
| |
| |
| | |
Disable clippy::clone_on_ref_ptr
See merge request tpo/core/arti!352
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This lint is IMO inherently ill-conceived.
I have looked for the reasons why this might be thought to be a good
idea and there were basically two (and they are sort of contradictory):
I. "Calling ‘.clone()` on an Rc, Arc, or Weak can obscure the fact
that only the pointer is being cloned, not the underlying data."
This is the wording from
https://rust-lang.github.io/rust-clippy/v0.0.212/#clone_on_ref_ptr
It is a bit terse; we are left to infer why it is a bad idea to
obscure this fact. It seems to me that if it is bad to obscure some
fact, that must be because the fact is a hazard. But why would it be
a hazard to not copy the underlying data ?
In other languages, faliing to copy the underlying data is a serious
correctness hazard. There is a whose class of bugs where things were
not copied, and then mutated and/or reused in multiple places in ways
that were not what the programmer intended. In my experience, this is
a very common bug when writing Python and Javascript. I'm told it's
common in golang too.
But in Rust this bug is much much harder to write. The data inside an
Arc is immutable. To have this bug you'd have use interior mutability
- ie mess around with Mutex or RefCell. That provides a good barrier
to these kind of accidents.
II. "The reason for writing Rc::clone and Arc::clone [is] to make it
clear that only the pointer is being cloned, as opposed to the
underlying data. The former is always fast, while the latter can
be very expensive depending on what is being cloned."
This is the reasoning found here
https://github.com/rust-lang/rust-clippy/issues/2048
This is saying that *not* using Arc::clone is hazardous.
Specifically, that a deep clone is a performance hazard.
But for this argument, the lint is precisely backwards. It's linting
the "good" case and asking for it to be written in a more explicit
way; while the supposedly bad case can be written conveniently.
Also, many objects (in our codebase, and in all the libraries we use)
that are Clone are in fact simply handles. They contain Arc(s) (or
similar) and are cheap to clone. Indeed, that is the usual case.
It does not make sense to distinguish in the syntax we use to clone
such a handle, whether the handle is a transparent Arc, or an opaque
struct containing one or more other handles.
Forcing Arc::clone to be written as such makes for code churn when a
type is changed from Arc<Something> to Something: Clone, or vice
versa.
|
| | |
| |
| |
| | |
it's making rust-nightly job fail
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Previously coarsetime and the traffic-timestamp feature were
enabled, since they were only required for a small corner of the
guardmgr algorithm.
But in 1.0 and beyond we'll be adding a bunch of other features (eg,
netflow padding, DoS prevention) that will need coarsetime all over
the place.
And since we're going to be doing coarsetime all over the place, the
previous justification for making traffic-timestamping optional (the
tiny performance hit) is no longer relevant.
|
| | |
| |
| |
| |
| | |
As per
https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/353#note_2781632
|
| |\ \
| | |
| | |
| | |
| | | |
tor-proto datastream: Do not dump packet data in DataWriterImpl
See merge request tpo/core/arti!353
|
| | | | |
|
| | | | |
|
| | | | |
|
| |\ \ \
| |/ /
|/| |
| | |
| | |
| | |
| | | |
tor-proto: Split up a couple of handshake-based errors
Closes #359 and #358
See merge request tpo/core/arti!344
|
| | | |
| | |
| | |
| | |
| | | |
Remove default conversion; instead use a specific conversion in each
of the two modules that need to do it.
|
| | | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
This helps the user distinguish between protocol violations that
happen when connecting to the tor network from those that happen
while connected.
Closes #358.
|
| | | |
| | |
| | |
| | | |
(We'll have a BadChanHandshake soon.)
|
| | |/
| |
| |
| |
| |
| |
| | |
We want to distinguish handshake failures from errors later on in
the channel's lifetime.
Closes #359.
|
| |\ \
| | |
| | |
| | |
| | |
| | |
| | | |
Give specific error kinds to different END reasons
Closes #360
See merge request tpo/core/arti!343
|
| | |/
| |
| |
| | |
Closes #360.
|
| |\ \
| |/
|/|
| |
| | |
impl Debug for DataStream (and its components)
See merge request tpo/core/arti!351
|
| | |
| |
| |
| |
| |
| |
| |
| |
| | |
My proximate motivation is that tls-api wants its inner streams to be
Debug. But in general, I agree with the Rust API Guidelines notion
that almost everything should be Debug.
I have gone for the "dump all the things" approach. A more nuanced
approach would be possible too.
|
| |\ \ |
|
| | | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
There was only one use of this, and it was in as-yet-unused relay-only
code.
Removing this type required refactoring the relay onion handshake code
to use its own error type, which is probably clever anyway.
|
| | | | |
|
| | | |
| | |
| | |
| | |
| | | |
This is a bit ugly but we need it to work around the problem where
exits aren't always clear about _why_ a hostname lookup failed.
|
| | | |
| | |
| | |
| | | |
Also document that it's a lower-level error kind.
|
| | | | |
|
| | |/ |
|
| |/
|
|
|
| |
This exception is no longer necessary now that the underlying CI bug
is fixed.
|
| | |
|
| | |
|
| | |
|
| | |
|
| |
|
|
|
|
| |
This took some refactoring, and gave an opportunity to notice
a few error variants that weren't being used, or didn't mean
what they said on the tin.
|
| | |
|
| |
|
|
|
|
|
|
|
| |
Additionally, refactor the IoError out of tor_cell::Error:
nothing in TorCell created this; it was only used by tor_proto.
This required refactoring in tor_proto to use a new error type. Here I
decided to use a new CodecError for now, though we may refactor that
away soon too.
|
| |\
| |
| |
| |
| |
| |
| | |
Change deny(clippy::all) to warn(clippy::all).
Closes #338
See merge request tpo/core/arti!306
|
| | |
| |
| |
| | |
Closes #338.
|
| |/
|
|
|
|
|
| |
This fixes a tiny race condition in the previous code, where we
checked whether an OptTimestamp is None a bit before we set it.
Since std::atomic gives us compare_exchange, we might as well use
it.
|
| | |
|
| | |
|
| |\
| |
| |
| |
| | |
Fix severe reactor ordering problems
See merge request tpo/core/arti!282
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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 / 5bce9db5628126be2b736f228211174fe4132918 without the
refactor part.
|
| |\ \
| | |
| | |
| | |
| | | |
Fix typos
See merge request tpo/core/arti!285
|
| | |/ |
|
| | | |
|
| |/
|
|
|
|
|
| |
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
|
| | |
|
| |
|
|
|
|
| |
As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/249#note_2771025
It doens't really handle it.
|
| |
|
|
|
|
|
|
|
| |
read_exact has a loop in it, which we need.
This means we end up separating the two sites that generate the "not a
relay" error, so we need to fish out the error construction.
As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/249#note_2771023
|
| | |
|
| |
|
|
| |
Discovered by clippy
|