@@ -30,7 +30,7 @@ use crate::{
3030 fs:: {
3131 StatFs ,
3232 fd:: {
33- Events , FdFlags , FileDescriptorTable , KernelWriteBuf , OffsetBuf , ReadBuf ,
33+ Events , FdFlags , FileDescriptorTable , KernelPageWriteBuf , OffsetBuf , ReadBuf ,
3434 StrongFileDescriptor , UnixLock , UnixLockOwner , UnixLockType , UserBuf , VectoredUserBuf ,
3535 WriteBuf , do_io, do_write_io,
3636 epoll:: Epoll ,
@@ -1327,23 +1327,16 @@ async fn sendfile(
13271327 let stat = r#in. stat ( ) ?;
13281328 let count = cmp:: min ( count, ( stat. size as usize ) . saturating_sub ( offset_value) ) ;
13291329
1330- let mut buffer = [ 0 ; 0x1000 ] ;
13311330 let mut total_len = 0 ;
13321331 while total_len < count {
13331332 let page_offset = offset_value / 0x1000 ;
13341333 let offset_in_page = offset_value % 0x1000 ;
13351334 let chunk_len = cmp:: min ( 0x1000 - offset_in_page, count - total_len) ;
13361335
1337- let buffer = & mut buffer[ offset_in_page..] ;
1338- let buffer = & mut buffer[ ..chunk_len] ;
1339-
13401336 let page = r#in. get_page ( page_offset, false ) ?;
1341- page . read ( offset_in_page, buffer ) ;
1337+ let buf = KernelPageWriteBuf :: new ( & page , offset_in_page, chunk_len ) ;
13421338
1343- let res = do_write_io ( & * * r#in, buffer. len ( ) , || {
1344- out. write ( & KernelWriteBuf :: new ( buffer) )
1345- } )
1346- . await ;
1339+ let res = do_write_io ( & * * r#in, chunk_len, || out. write ( & buf) ) . await ;
13471340 match res {
13481341 Ok ( 0 ) => break ,
13491342 Ok ( n) => {
0 commit comments