1
0
mirror of https://github.com/golang/go synced 2024-11-25 09:47:57 -07:00

net: fix build on old Linux kernels

Thanks to Mike Beller for identifying the problem.

Fixes #1442.

R=bradfitz, bradfitzgo
CC=golang-dev
https://golang.org/cl/4102042
This commit is contained in:
Russ Cox 2011-01-26 15:46:15 -05:00
parent 0e1d941e5c
commit f626696d21

View File

@ -25,7 +25,7 @@ func runEcho(fd io.ReadWriter, done chan<- int) {
for { for {
n, err := fd.Read(buf[0:]) n, err := fd.Read(buf[0:])
if err != nil || n == 0 { if err != nil || n == 0 || string(buf[:n]) == "END" {
break break
} }
fd.Write(buf[0:n]) fd.Write(buf[0:n])
@ -79,6 +79,13 @@ func connect(t *testing.T, network, addr string, isEmpty bool) {
if n != len(b) || err1 != nil { if n != len(b) || err1 != nil {
t.Fatalf("fd.Read() = %d, %v (want %d, nil)", n, err1, len(b)) t.Fatalf("fd.Read() = %d, %v (want %d, nil)", n, err1, len(b))
} }
// Send explicit ending for unixpacket.
// Older Linux kernels do stop reads on close.
if network == "unixpacket" {
fd.Write([]byte("END"))
}
fd.Close() fd.Close()
} }