Skip to content

Commit a2c2f06

Browse files
tklausergopherbot
authored andcommitted
internal/poll: remove detection of buggy splice on old Linux versions
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 <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Auto-Submit: Tobias Klauser <[email protected]> Run-TryBot: Tobias Klauser <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]>
1 parent b15c399 commit a2c2f06

File tree

1 file changed

+3
-32
lines changed

1 file changed

+3
-32
lines changed

src/internal/poll/splice_linux.go

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
package poll
66

77
import (
8-
"internal/syscall/unix"
98
"runtime"
109
"sync"
11-
"sync/atomic"
1210
"syscall"
1311
"unsafe"
1412
)
@@ -207,40 +205,13 @@ func putPipe(p *splicePipe) {
207205
splicePipePool.Put(p)
208206
}
209207

210-
var disableSplice unsafe.Pointer
211-
212208
// newPipe sets up a pipe for a splice operation.
213-
func newPipe() (sp *splicePipe) {
214-
p := (*bool)(atomic.LoadPointer(&disableSplice))
215-
if p != nil && *p {
216-
return nil
217-
}
218-
209+
func newPipe() *splicePipe {
219210
var fds [2]int
220-
// pipe2 was added in 2.6.27 and our minimum requirement is 2.6.23, so it
221-
// might not be implemented. Falling back to pipe is possible, but prior to
222-
// 2.6.29 splice returns -EAGAIN instead of 0 when the connection is
223-
// closed.
224-
const flags = syscall.O_CLOEXEC | syscall.O_NONBLOCK
225-
if err := syscall.Pipe2(fds[:], flags); err != nil {
211+
if err := syscall.Pipe2(fds[:], syscall.O_CLOEXEC|syscall.O_NONBLOCK); err != nil {
226212
return nil
227213
}
228-
229-
sp = &splicePipe{splicePipeFields: splicePipeFields{rfd: fds[0], wfd: fds[1]}}
230-
231-
if p == nil {
232-
p = new(bool)
233-
defer atomic.StorePointer(&disableSplice, unsafe.Pointer(p))
234-
235-
// F_GETPIPE_SZ was added in 2.6.35, which does not have the -EAGAIN bug.
236-
if _, _, errno := syscall.Syscall(unix.FcntlSyscall, uintptr(fds[0]), syscall.F_GETPIPE_SZ, 0); errno != 0 {
237-
*p = true
238-
destroyPipe(sp)
239-
return nil
240-
}
241-
}
242-
243-
return
214+
return &splicePipe{splicePipeFields: splicePipeFields{rfd: fds[0], wfd: fds[1]}}
244215
}
245216

246217
// destroyPipe destroys a pipe.

0 commit comments

Comments
 (0)