@@ -351,7 +351,7 @@ impl AssociationInternal {
351
351
) -> Vec < Bytes > {
352
352
// Pop unsent data chunks from the pending queue to send as much as
353
353
// cwnd and rwnd allow.
354
- let ( chunks, sis_to_reset) = self . pop_pending_data_chunks_to_send ( ) . await ;
354
+ let ( chunks, sis_to_reset) = self . pop_pending_data_chunks_to_send ( ) ;
355
355
if !chunks. is_empty ( ) {
356
356
// Start timer. (noop if already started)
357
357
log:: trace!( "[{}] T3-rtx timer start (pt1)" , self . name) ;
@@ -1771,7 +1771,7 @@ impl AssociationInternal {
1771
1771
self . handle_peer_last_tsn_and_acknowledgement ( false )
1772
1772
}
1773
1773
1774
- async fn send_reset_request ( & mut self , stream_identifier : u16 ) -> Result < ( ) > {
1774
+ fn send_reset_request ( & mut self , stream_identifier : u16 ) -> Result < ( ) > {
1775
1775
let state = self . get_state ( ) ;
1776
1776
if state != AssociationState :: Established {
1777
1777
return Err ( Error :: ErrResetPacketInStateNotExist ) ;
@@ -1787,7 +1787,7 @@ impl AssociationInternal {
1787
1787
..Default :: default ( )
1788
1788
} ;
1789
1789
1790
- self . pending_queue . push ( c) . await ;
1790
+ self . pending_queue . push ( c) ;
1791
1791
self . awake_write_loop ( ) ;
1792
1792
1793
1793
Ok ( ( ) )
@@ -1852,12 +1852,12 @@ impl AssociationInternal {
1852
1852
}
1853
1853
1854
1854
/// Move the chunk peeked with self.pending_queue.peek() to the inflight_queue.
1855
- async fn move_pending_data_chunk_to_inflight_queue (
1855
+ fn move_pending_data_chunk_to_inflight_queue (
1856
1856
& mut self ,
1857
1857
beginning_fragment : bool ,
1858
1858
unordered : bool ,
1859
1859
) -> Option < ChunkPayloadData > {
1860
- if let Some ( mut c) = self . pending_queue . pop ( beginning_fragment, unordered) . await {
1860
+ if let Some ( mut c) = self . pending_queue . pop ( beginning_fragment, unordered) {
1861
1861
// Mark all fragements are in-flight now
1862
1862
if c. ending_fragment {
1863
1863
c. set_all_inflight ( ) ;
@@ -1894,70 +1894,68 @@ impl AssociationInternal {
1894
1894
1895
1895
/// pop_pending_data_chunks_to_send pops chunks from the pending queues as many as
1896
1896
/// the cwnd and rwnd allows to send.
1897
- async fn pop_pending_data_chunks_to_send ( & mut self ) -> ( Vec < ChunkPayloadData > , Vec < u16 > ) {
1897
+ fn pop_pending_data_chunks_to_send ( & mut self ) -> ( Vec < ChunkPayloadData > , Vec < u16 > ) {
1898
1898
let mut chunks = vec ! [ ] ;
1899
1899
let mut sis_to_reset = vec ! [ ] ; // stream identifiers to reset
1900
- let is_empty = self . pending_queue . len ( ) == 0 ;
1901
- if !is_empty {
1902
- // RFC 4960 sec 6.1. Transmission of DATA Chunks
1903
- // A) At any given time, the data sender MUST NOT transmit new data to
1904
- // any destination transport address if its peer's rwnd indicates
1905
- // that the peer has no buffer space (i.e., rwnd is 0; see Section
1906
- // 6.2.1). However, regardless of the value of rwnd (including if it
1907
- // is 0), the data sender can always have one DATA chunk in flight to
1908
- // the receiver if allowed by cwnd (see rule B, below).
1909
-
1910
- while let Some ( c) = self . pending_queue . peek ( ) . await {
1911
- let ( beginning_fragment, unordered, data_len, stream_identifier) = (
1912
- c. beginning_fragment ,
1913
- c. unordered ,
1914
- c. user_data . len ( ) ,
1915
- c. stream_identifier ,
1916
- ) ;
1917
1900
1918
- if data_len == 0 {
1919
- sis_to_reset. push ( stream_identifier) ;
1920
- if self
1921
- . pending_queue
1922
- . pop ( beginning_fragment, unordered)
1923
- . await
1924
- . is_none ( )
1925
- {
1926
- log:: error!( "failed to pop from pending queue" ) ;
1927
- }
1928
- continue ;
1929
- }
1901
+ if self . pending_queue . len ( ) == 0 {
1902
+ return ( chunks, sis_to_reset) ;
1903
+ }
1930
1904
1931
- if self . inflight_queue . get_num_bytes ( ) + data_len > self . cwnd as usize {
1932
- break ; // would exceeds cwnd
1933
- }
1905
+ // RFC 4960 sec 6.1. Transmission of DATA Chunks
1906
+ // A) At any given time, the data sender MUST NOT transmit new data to
1907
+ // any destination transport address if its peer's rwnd indicates
1908
+ // that the peer has no buffer space (i.e., rwnd is 0; see Section
1909
+ // 6.2.1). However, regardless of the value of rwnd (including if it
1910
+ // is 0), the data sender can always have one DATA chunk in flight to
1911
+ // the receiver if allowed by cwnd (see rule B, below).
1912
+ while let Some ( c) = self . pending_queue . peek ( ) {
1913
+ let ( beginning_fragment, unordered, data_len, stream_identifier) = (
1914
+ c. beginning_fragment ,
1915
+ c. unordered ,
1916
+ c. user_data . len ( ) ,
1917
+ c. stream_identifier ,
1918
+ ) ;
1934
1919
1935
- if data_len > self . rwnd as usize {
1936
- break ; // no more rwnd
1920
+ if data_len == 0 {
1921
+ sis_to_reset. push ( stream_identifier) ;
1922
+ if self
1923
+ . pending_queue
1924
+ . pop ( beginning_fragment, unordered)
1925
+ . is_none ( )
1926
+ {
1927
+ log:: error!( "failed to pop from pending queue" ) ;
1937
1928
}
1929
+ continue ;
1930
+ }
1938
1931
1939
- self . rwnd -= data_len as u32 ;
1932
+ if self . inflight_queue . get_num_bytes ( ) + data_len > self . cwnd as usize {
1933
+ break ; // would exceed cwnd
1934
+ }
1940
1935
1941
- if let Some ( chunk) = self
1942
- . move_pending_data_chunk_to_inflight_queue ( beginning_fragment, unordered)
1943
- . await
1944
- {
1945
- chunks. push ( chunk) ;
1946
- }
1936
+ if data_len > self . rwnd as usize {
1937
+ break ; // no more rwnd
1947
1938
}
1948
1939
1949
- // the data sender can always have one DATA chunk in flight to the receiver
1950
- if chunks. is_empty ( ) && self . inflight_queue . is_empty ( ) {
1951
- // Send zero window probe
1952
- if let Some ( c) = self . pending_queue . peek ( ) . await {
1953
- let ( beginning_fragment, unordered) = ( c. beginning_fragment , c. unordered ) ;
1940
+ self . rwnd -= data_len as u32 ;
1954
1941
1955
- if let Some ( chunk) = self
1956
- . move_pending_data_chunk_to_inflight_queue ( beginning_fragment, unordered)
1957
- . await
1958
- {
1959
- chunks. push ( chunk) ;
1960
- }
1942
+ if let Some ( chunk) =
1943
+ self . move_pending_data_chunk_to_inflight_queue ( beginning_fragment, unordered)
1944
+ {
1945
+ chunks. push ( chunk) ;
1946
+ }
1947
+ }
1948
+
1949
+ // the data sender can always have one DATA chunk in flight to the receiver
1950
+ if chunks. is_empty ( ) && self . inflight_queue . is_empty ( ) {
1951
+ // Send zero window probe
1952
+ if let Some ( c) = self . pending_queue . peek ( ) {
1953
+ let ( beginning_fragment, unordered) = ( c. beginning_fragment , c. unordered ) ;
1954
+
1955
+ if let Some ( chunk) =
1956
+ self . move_pending_data_chunk_to_inflight_queue ( beginning_fragment, unordered)
1957
+ {
1958
+ chunks. push ( chunk) ;
1961
1959
}
1962
1960
}
1963
1961
}
0 commit comments