Skip to content

Commit 3d24f9b

Browse files
committed
Fix copy direct
1 parent e84b7ae commit 3d24f9b

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

common/bufio/copy.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,19 @@ func CopyWithIncreateBuffer(destination io.Writer, source io.Reader, increaseBuf
5858
return CopyWithCounters(destination, source, originSource, readCounters, writeCounters, increaseBufferAfter, batchSize)
5959
}
6060

61+
type syscallReader interface {
62+
io.Reader
63+
syscall.Conn
64+
}
65+
66+
type syscallWriter interface {
67+
io.Writer
68+
syscall.Conn
69+
}
70+
6171
func CopyWithCounters(destination io.Writer, source io.Reader, originSource io.Reader, readCounters []N.CountFunc, writeCounters []N.CountFunc, increaseBufferAfter int64, batchSize int) (n int64, err error) {
62-
srcSyscallConn, srcIsSyscall := source.(syscall.Conn)
63-
dstSyscallConn, dstIsSyscall := destination.(syscall.Conn)
72+
srcSyscallConn, srcIsSyscall := N.CastReader[syscallReader](source)
73+
dstSyscallConn, dstIsSyscall := N.CastWriter[syscallWriter](destination)
6474
if srcIsSyscall && dstIsSyscall {
6575
var handled bool
6676
handled, n, err = copyDirect(srcSyscallConn, dstSyscallConn, readCounters, writeCounters)

0 commit comments

Comments
 (0)