]> Cypherpunks repositories - gostls13.git/commitdiff
internal/poll: remove detection of buggy splice on old Linux versions
authorTobias Klauser <tklauser@distanz.ch>
Wed, 17 Aug 2022 20:21:23 +0000 (22:21 +0200)
committerGopher Robot <gobot@golang.org>
Thu, 18 Aug 2022 05:32:36 +0000 (05:32 +0000)
The splice syscall is buggy prior to Linux 2.6.29. CL 113999 added a
workaround to detect buggy versions and disable use of splice for these.
As of Go 1.18 the minumum Linux version is 2.6.32. Thus, a non-buggy
implementation of the splice syscall can be assumed.

For #45964
Fixes #54505

Change-Id: Ied3a3334da7a3f7fa1280b7c5b1dfb9030219336
Reviewed-on: https://go-review.googlesource.com/c/go/+/422979
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
src/internal/poll/splice_linux.go

index 43eec04a71485b85dabc81bf7e68f413b29a9958..6e1a71fa5b6b951c79b5b94123337508e96ea3a0 100644 (file)
@@ -5,10 +5,8 @@
 package poll
 
 import (
-       "internal/syscall/unix"
        "runtime"
        "sync"
-       "sync/atomic"
        "syscall"
        "unsafe"
 )
@@ -207,40 +205,13 @@ func putPipe(p *splicePipe) {
        splicePipePool.Put(p)
 }
 
-var disableSplice unsafe.Pointer
-
 // newPipe sets up a pipe for a splice operation.
-func newPipe() (sp *splicePipe) {
-       p := (*bool)(atomic.LoadPointer(&disableSplice))
-       if p != nil && *p {
-               return nil
-       }
-
+func newPipe() *splicePipe {
        var fds [2]int
-       // pipe2 was added in 2.6.27 and our minimum requirement is 2.6.23, so it
-       // might not be implemented. Falling back to pipe is possible, but prior to
-       // 2.6.29 splice returns -EAGAIN instead of 0 when the connection is
-       // closed.
-       const flags = syscall.O_CLOEXEC | syscall.O_NONBLOCK
-       if err := syscall.Pipe2(fds[:], flags); err != nil {
+       if err := syscall.Pipe2(fds[:], syscall.O_CLOEXEC|syscall.O_NONBLOCK); err != nil {
                return nil
        }
-
-       sp = &splicePipe{splicePipeFields: splicePipeFields{rfd: fds[0], wfd: fds[1]}}
-
-       if p == nil {
-               p = new(bool)
-               defer atomic.StorePointer(&disableSplice, unsafe.Pointer(p))
-
-               // F_GETPIPE_SZ was added in 2.6.35, which does not have the -EAGAIN bug.
-               if _, _, errno := syscall.Syscall(unix.FcntlSyscall, uintptr(fds[0]), syscall.F_GETPIPE_SZ, 0); errno != 0 {
-                       *p = true
-                       destroyPipe(sp)
-                       return nil
-               }
-       }
-
-       return
+       return &splicePipe{splicePipeFields: splicePipeFields{rfd: fds[0], wfd: fds[1]}}
 }
 
 // destroyPipe destroys a pipe.