@@ -24,10 +24,7 @@ use crate::{
2424 frame:: { Close , Datagram , FrameStruct } ,
2525 packet:: { Header , LongType , Packet , PartialDecode , SpaceId } ,
2626 range_set:: ArrayRangeSet ,
27- shared:: {
28- ConnectionEvent , ConnectionEventInner , ConnectionId , EcnCodepoint , EndpointEvent ,
29- EndpointEventInner ,
30- } ,
27+ shared:: { ConnectionEvent , ConnectionEventInner , ConnectionId , EcnCodepoint } ,
3128 token:: ResetToken ,
3229 transport_parameters:: TransportParameters ,
3330 ConnectionHandle , Dir , Endpoint , EndpointConfig , Frame , Side , StreamId , Transmit ,
@@ -84,10 +81,10 @@ use timer::{Timer, TimerTable};
8481
8582/// Protocol state and logic for a single QUIC connection
8683///
87- /// Objects of this type receive [`ConnectionEvent`]s and emit [`EndpointEvent `]s and application
88- /// [`Event`]s to make progress. To handle timeouts, a `Connection` returns timer updates and
89- /// expects timeouts through various methods. A number of simple getter methods are exposed
90- /// to allow callers to inspect some of the connection state.
84+ /// Objects of this type receive [`ConnectionEvent`]s and emit application [`Event `]s to make
85+ /// progress. To handle timeouts, a `Connection` returns timer updates and expects timeouts through
86+ /// various methods. A number of simple getter methods are exposed to allow callers to inspect some
87+ /// of the connection state.
9188///
9289/// `Connection` has roughly 4 types of methods:
9390///
@@ -108,8 +105,7 @@ use timer::{Timer, TimerTable};
108105///
109106/// 1. [`poll_transmit`](Self::poll_transmit)
110107/// 2. [`poll_timeout`](Self::poll_timeout)
111- /// 3. [`poll_endpoint_events`](Self::poll_endpoint_events)
112- /// 4. [`poll`](Self::poll)
108+ /// 3. [`poll`](Self::poll)
113109///
114110/// Currently the only actual dependency is from (2) to (1), however additional
115111/// dependencies may be added in future, so the above order is recommended.
@@ -156,7 +152,6 @@ pub struct Connection {
156152 /// Total number of outgoing packets that have been deemed lost
157153 lost_packets : u64 ,
158154 events : VecDeque < Event > ,
159- endpoint_events : VecDeque < EndpointEventInner > ,
160155 /// Whether the spin bit is in use for this connection
161156 spin_enabled : bool ,
162157 /// Outgoing spin bit state
@@ -294,7 +289,6 @@ impl Connection {
294289 retry_src_cid : None ,
295290 lost_packets : 0 ,
296291 events : VecDeque :: new ( ) ,
297- endpoint_events : VecDeque :: new ( ) ,
298292 spin_enabled : config. allow_spin && rng. gen_ratio ( 7 , 8 ) ,
299293 spin : false ,
300294 spaces : [ initial_space, PacketSpace :: new ( now) , PacketSpace :: new ( now) ] ,
@@ -376,12 +370,6 @@ impl Connection {
376370 None
377371 }
378372
379- /// Return endpoint-facing events
380- #[ must_use]
381- pub fn poll_endpoint_events ( & mut self ) -> Option < EndpointEvent > {
382- self . endpoint_events . pop_front ( ) . map ( EndpointEvent )
383- }
384-
385373 /// Provide control over streams
386374 #[ must_use]
387375 pub fn streams ( & mut self ) -> Streams < ' _ > {
@@ -888,8 +876,8 @@ impl Connection {
888876 /// Process `ConnectionEvent`s generated by the associated `Endpoint`
889877 ///
890878 /// Will execute protocol logic upon receipt of a connection event, in turn preparing signals
891- /// (including application `Event`s, `EndpointEvent`s and outgoing datagrams) that should be
892- /// extracted through the relevant methods.
879+ /// (including application `Event`s and outgoing datagrams) that should be extracted through the
880+ /// relevant methods.
893881 pub fn handle_event ( & mut self , event : ConnectionEvent , endpoint : & Endpoint ) {
894882 use self :: ConnectionEventInner :: * ;
895883 match event. 0 {
@@ -956,9 +944,8 @@ impl Connection {
956944
957945 /// Process timer expirations
958946 ///
959- /// Executes protocol logic, potentially preparing signals (including application `Event`s,
960- /// `EndpointEvent`s and outgoing datagrams) that should be extracted through the relevant
961- /// methods.
947+ /// Executes protocol logic, potentially preparing signals (including application `Event`s, and
948+ /// outgoing datagrams) that should be extracted through the relevant methods.
962949 ///
963950 /// It is most efficient to call this immediately after the system clock reaches the latest
964951 /// `Instant` that was output by `poll_timeout`; however spurious extra calls will simply
@@ -973,10 +960,11 @@ impl Connection {
973960 match timer {
974961 Timer :: Close => {
975962 self . state = State :: Drained ;
976- self . endpoint_events . push_back ( EndpointEventInner :: Drained ) ;
963+ endpoint . handle_drained ( self . handle ) ;
977964 }
978965 Timer :: Idle => {
979966 self . kill ( ConnectionError :: TimedOut ) ;
967+ endpoint. handle_drained ( self . handle ) ;
980968 }
981969 Timer :: KeepAlive => {
982970 trace ! ( "sending keep-alive" ) ;
@@ -2123,7 +2111,7 @@ impl Connection {
21232111 }
21242112 }
21252113 if !was_drained && self . state . is_drained ( ) {
2126- self . endpoint_events . push_back ( EndpointEventInner :: Drained ) ;
2114+ endpoint . handle_drained ( self . handle ) ;
21272115 // Close timer may have been started previously, e.g. if we sent a close and got a
21282116 // stateless reset in response
21292117 self . timers . stop ( Timer :: Close ) ;
@@ -3276,7 +3264,6 @@ impl Connection {
32763264 self . close_common ( ) ;
32773265 self . error = Some ( reason) ;
32783266 self . state = State :: Drained ;
3279- self . endpoint_events . push_back ( EndpointEventInner :: Drained ) ;
32803267 }
32813268}
32823269
0 commit comments