]> Cypherpunks repositories - gostls13.git/commitdiff
internal/poll: improve the padding calculation inside struct splicePipe
authorAndy Pan <panjf2000@gmail.com>
Tue, 26 Oct 2021 01:15:17 +0000 (09:15 +0800)
committerTobias Klauser <tobias.klauser@gmail.com>
Wed, 27 Oct 2021 08:50:27 +0000 (08:50 +0000)
Updates #48968 and CL 358114

Change-Id: Ic68b4c5420c1c32f78b56874b53d717fa9af1f74
Reviewed-on: https://go-review.googlesource.com/c/go/+/358734
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Tobias Klauser <tobias.klauser@gmail.com>

src/internal/poll/splice_linux.go

index 6869a40b243c0beeba0b597b9e2b74893c94aca7..2d87c3d023b14eb381e8a811f452f2f2632c091a 100644 (file)
@@ -154,14 +154,18 @@ 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 - 3*unsafe.Sizeof(int(0))]byte
+       _ [24 - unsafe.Sizeof(splicePipeFields{})%24]byte
 }
 
 // splicePipePool caches pipes to avoid high-frequency construction and destruction of pipe buffers.
@@ -222,7 +226,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)