File tree Expand file tree Collapse file tree 1 file changed +3
-1
lines changed
Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,8 @@ pub(super) fn write_fast_using_splice<R: FdReadable, S: AsRawFd + AsFd>(
2323 handle : & InputHandle < R > ,
2424 write_fd : & S ,
2525) -> CatResult < bool > {
26+ use std:: { fs:: File , sync:: OnceLock } ;
27+ static BROKER : OnceLock < Option < ( File , File ) > > = OnceLock :: new ( ) ;
2628 if splice ( & handle. reader , & write_fd, MAX_ROOTLESS_PIPE_SIZE ) . is_ok ( ) {
2729 // fcntl improves throughput
2830 // todo: avoid fcntl overhead for small input, but don't fcntl inside of the loop
@@ -34,7 +36,7 @@ pub(super) fn write_fast_using_splice<R: FdReadable, S: AsRawFd + AsFd>(
3436 Err ( _) => return Ok ( true ) ,
3537 }
3638 }
37- } else if let Ok ( ( pipe_rd, pipe_wr) ) = pipe ( ) {
39+ } else if let Some ( ( pipe_rd, pipe_wr) ) = BROKER . get_or_init ( || pipe ( ) . ok ( ) ) . as_ref ( ) {
3840 // both of in/output are not pipe. needs broker to use splice() with additional costs
3941 loop {
4042 match splice ( & handle. reader , & pipe_wr, MAX_ROOTLESS_PIPE_SIZE ) {
You can’t perform that action at this time.
0 commit comments