@@ -1622,7 +1622,7 @@ impl Future for IncomingFuture {
16221622 Poll :: Pending => Poll :: Pending ,
16231623 Poll :: Ready ( Err ( err) ) => Poll :: Ready ( Err ( err) ) ,
16241624 Poll :: Ready ( Ok ( inner) ) => {
1625- let conn = Connection { inner } ;
1625+ let conn = Connection :: new ( inner, None , & this . ep ) ;
16261626 try_send_rtt_msg ( & conn, this. ep , None ) ;
16271627 Poll :: Ready ( Ok ( conn) )
16281628 }
@@ -1710,11 +1710,12 @@ impl Connecting {
17101710 pub fn into_0rtt ( self ) -> Result < ( Connection , ZeroRttAccepted ) , Self > {
17111711 match self . inner . into_0rtt ( ) {
17121712 Ok ( ( inner, zrtt_accepted) ) => {
1713- let conn = Connection { inner } ;
1713+ let conn = Connection :: new ( inner, self . remote_node_id , & self . ep ) ;
17141714 let zrtt_accepted = ZeroRttAccepted {
17151715 inner : zrtt_accepted,
17161716 _discovery_drop_guard : self . _discovery_drop_guard ,
17171717 } ;
1718+
17181719 // This call is why `self.remote_node_id` was introduced.
17191720 // When we `Connecting::into_0rtt`, then we don't yet have `handshake_data`
17201721 // in our `Connection`, thus `try_send_rtt_msg` won't be able to pick up
@@ -1760,24 +1761,7 @@ impl Future for Connecting {
17601761 Poll :: Pending => Poll :: Pending ,
17611762 Poll :: Ready ( Err ( err) ) => Poll :: Ready ( Err ( err) ) ,
17621763 Poll :: Ready ( Ok ( inner) ) => {
1763- let conn = Connection { inner } ;
1764-
1765- // Grab the remote identity and register this connection
1766- if let Some ( remote) = * this. remote_node_id {
1767- let weak_handle = conn. inner . weak_handle ( ) ;
1768- let path_events = conn. inner . path_events ( ) ;
1769- this. ep
1770- . msock
1771- . register_connection ( remote, weak_handle, path_events) ;
1772- } else if let Ok ( remote) = conn. remote_node_id ( ) {
1773- let weak_handle = conn. inner . weak_handle ( ) ;
1774- let path_events = conn. inner . path_events ( ) ;
1775- this. ep
1776- . msock
1777- . register_connection ( remote, weak_handle, path_events) ;
1778- } else {
1779- warn ! ( "unable to determine node id for the remote" ) ;
1780- }
1764+ let conn = Connection :: new ( inner, * this. remote_node_id , & this. ep ) ;
17811765
17821766 try_send_rtt_msg ( & conn, this. ep , * this. remote_node_id ) ;
17831767 Poll :: Ready ( Ok ( conn) )
@@ -1837,6 +1821,27 @@ pub struct RemoteNodeIdError {
18371821}
18381822
18391823impl Connection {
1824+ fn new ( inner : quinn:: Connection , remote_id : Option < NodeId > , ep : & Endpoint ) -> Self {
1825+ let conn = Connection { inner } ;
1826+
1827+ // Grab the remote identity and register this connection
1828+ if let Some ( remote) = remote_id {
1829+ let weak_handle = conn. inner . weak_handle ( ) ;
1830+ let path_events = conn. inner . path_events ( ) ;
1831+ ep. msock
1832+ . register_connection ( remote, weak_handle, path_events) ;
1833+ } else if let Ok ( remote) = conn. remote_node_id ( ) {
1834+ let weak_handle = conn. inner . weak_handle ( ) ;
1835+ let path_events = conn. inner . path_events ( ) ;
1836+ ep. msock
1837+ . register_connection ( remote, weak_handle, path_events) ;
1838+ } else {
1839+ warn ! ( "unable to determine node id for the remote" ) ;
1840+ }
1841+
1842+ conn
1843+ }
1844+
18401845 /// Initiates a new outgoing unidirectional stream.
18411846 ///
18421847 /// Streams are cheap and instantaneous to open unless blocked by flow control. As a
0 commit comments