diff options
Diffstat (limited to 'libgo/go/internal/poll/splice_linux.go')
-rw-r--r-- | libgo/go/internal/poll/splice_linux.go | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/libgo/go/internal/poll/splice_linux.go b/libgo/go/internal/poll/splice_linux.go index c7114f2..7e520a0 100644 --- a/libgo/go/internal/poll/splice_linux.go +++ b/libgo/go/internal/poll/splice_linux.go @@ -153,18 +153,26 @@ func splice(out int, in int, max int, flags int) (int, error) { return int(n), err } -type splicePipe struct { +type splicePipeFields struct { rfd int wfd int data int } +type splicePipe struct { + splicePipeFields + + // We want to use a finalizer, so ensure that the size is + // large enough to not use the tiny allocator. + _ [24 - unsafe.Sizeof(splicePipeFields{})%24]byte +} + // splicePipePool caches pipes to avoid high-frequency construction and destruction of pipe buffers. // The garbage collector will free all pipes in the sync.Pool periodically, thus we need to set up // a finalizer for each pipe to close its file descriptors before the actual GC. var splicePipePool = sync.Pool{New: newPoolPipe} -func newPoolPipe() interface{} { +func newPoolPipe() any { // Discard the error which occurred during the creation of pipe buffer, // redirecting the data transmission to the conventional way utilizing read() + write() as a fallback. p := newPipe() @@ -217,7 +225,7 @@ func newPipe() (sp *splicePipe) { return nil } - sp = &splicePipe{rfd: fds[0], wfd: fds[1]} + sp = &splicePipe{splicePipeFields: splicePipeFields{rfd: fds[0], wfd: fds[1]}} if p == nil { p = new(bool) |