Comments (13)
Hello,
Connection
is self-referencing, so it can't be moved or the internal reference (which is actually a raw pointer) would become invalid. So we use Box
to get a more stable address on the heap. In theory we should use Pin<Box<...>>
but Pin
doesn't expose the APIs we need.
from quiche.
Ahh, thanks for the clarification. One more question: could this be hidden inside Connection‘s API?
This feels like a nitty gritty API internal to me that shouldn‘t be exposed to the user (at least from my limited understanding). Especially because the user might be tempted to move the connection out of the box, effectively breaking it. For example, Connection could be made into a newtype around the current Connection.
And if that‘s not possible, I think it should at least be documented that the boxing is intentional. :)
from quiche.
I'm not sure the indirection of wrapping Connection would be worth the effort, though I do agree that this should be documented. I'll reopen the issue to track that part.
from quiche.
I could file a PR to do this. I'd just need some guidance as to what to do with the documentation on Connection
s methods. Should they move to the newtype or be copied (so that they'd exist twice)? And also, would you be fine with moving the connection implementation from lib.rs
into a separate module, so that lib.rs
solely wraps Connection
into a newtype and exports the public API surface?
from quiche.
@NeoLegends it's not only about actually having to do the initial work to implement that, but the maintainance burden the change adds in the future (e.g. the public Connection APIs would need to be duplicated to handle the wrapped, which makes it somewhat harder to understand and add new APIs).
So for the moment I'd rather not do anything more than documenting the current situation. We can always reconsider in the future.
from quiche.
e.g. the public Connection APIs would need to be duplicated to handle the wrapped
I don't think this is true - you already accept it by reference, and it will be perfectly fine to pass pointer from Box
as if it was a pointer to unwrapped structure.
from quiche.
@RReverser if I understand correctly, the proposal here is to have something like pub struct ConnectionWrapper(Box<Connection>)
and make Connection
itself private, so you'd have to mirror the private Connection
API in ConnectionWrapper
.
from quiche.
@ghedo Correct. I think though, that the additional maintenance overhead will be minimal and that the safety gains outweigh this. When I made my first tests (and bumped into the questions I asked), the newtype added a mere 100 lines or so to lib.rs, not including some one-time churn like converting connect / accept to return the newtype and so on.
from quiche.
Connection is self-referencing, so it can't be moved or the internal reference (which is actually a raw pointer) would become invalid. So we use Box to get a more stable address on the heap. In theory we should use Pin<Box<...>> but Pin doesn't expose the APIs we need.
FWIW there's nothing stopping users from pulling the connection out of the box and putting it back in another one, triggering UB. What specific APIs do y'all need that Pin<Box<Connection>>
wouldn't allow?
from quiche.
@cramertj basically this rust-lang/rust#60245, though it could potentially be implemented in some other uglier way.
from quiche.
@ghedo i believe the required features will be stabilized as part of 1.39. rust-lang/rust#63985
from quiche.
Yep, I made that PR :)
from quiche.
Made #249 based on Rust 1.39.
from quiche.
Related Issues (20)
- Random out of range panic when enabling qlog HOT 4
- issues test
- Hello, I encountered some problems when configuring the quic service of NGINX. HOT 1
- Update ring HOT 1
- failed to quic shake hands with chrome using quiche HOT 2
- chrome does not trust custom certificates for quic HOT 1
- connection migration
- Connection::stream_send() reports Err::Done for finished streams HOT 3
- Connection migration HOT 1
- connection migration
- Async Implementation HOT 3
- Stream application error codes are not exposed to FFI HOT 4
- When should `h3::Connection.poll` be called? HOT 10
- failed to run custom build command for `quiche v0.20.0 (/root/quiche/quiche)` HOT 3
- Encoding payload with protobuf clashes with the protocol HOT 3
- CIDs > 20 bytes should be rejected HOT 1
- Is there any RESTful api framework built on top of quiche?
- Graceful shutdown: Await all data on the stream being consumed HOT 4
- nightly build seems to be failing. HOT 1
- Question about encryption HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from quiche.