@@ -92,8 +92,6 @@ struct StreamOpsInner {
9292struct StreamOpsStorage {
9393 ops : Slab < Option < Operation > > ,
9494 streams : Slab < StreamItem > ,
95- lw : usize ,
96- hw : usize ,
9795}
9896
9997impl StreamOps {
@@ -125,8 +123,6 @@ impl StreamOps {
125123 storage : Cell :: new ( Some ( Box :: new ( StreamOpsStorage {
126124 ops,
127125 streams : Slab :: new ( ) ,
128- lw : 1024 ,
129- hw : 1024 * 16 ,
130126 } ) ) ) ,
131127 } ) ;
132128 inner = Some ( ops. clone ( ) ) ;
@@ -145,10 +141,10 @@ impl StreamOps {
145141 ) -> ( StreamCtl , WeakStreamCtl ) {
146142 let item = StreamItem {
147143 io,
144+ ctx,
148145 rd_op : None ,
149146 wr_op : None ,
150147 flags : if zc { self . 0 . default_flags } else { Flags :: NO_ZC } ,
151- ctx : ctx. clone ( ) ,
152148 } ;
153149
154150 let id = self . 0 . with ( move |st| {
@@ -232,6 +228,7 @@ impl Handler for StreamOpsHandler {
232228 } else {
233229 let mut total = 0 ;
234230 let res = Poll :: Ready ( res. map ( |size| {
231+ // SAFETY: kernel tells us how many bytes it read
235232 unsafe { buf. advance_mut ( size) } ;
236233 total = size;
237234 } ) . map_err ( Some ) ) ;
@@ -355,9 +352,8 @@ impl StreamOpsStorage {
355352
356353 fn recv_more ( & mut self , id : usize , mut buf : BytesVec , api : & DriverApi ) {
357354 if let Some ( item) = self . streams . get_mut ( id) {
358- if buf. remaining_mut ( ) < self . lw {
359- buf. reserve ( self . hw ) ;
360- }
355+ item. ctx . resize_read_buf ( & mut buf) ;
356+
361357 let slice = buf. chunk_mut ( ) ;
362358 let buf_ptr = slice. as_mut_ptr ( ) ;
363359 let buf_len = slice. len ( ) as u32 ;
@@ -528,7 +524,6 @@ impl StreamCtl {
528524
529525impl Drop for StreamCtl {
530526 fn drop ( & mut self ) {
531- println ! ( "DROP CTL {:?}" , self . id) ;
532527 self . inner . drop_stream ( self . id ) ;
533528 }
534529}
0 commit comments