Skip to content

Commit 5cfca57

Browse files
author
Bryan C. Mills
committed
ipv6: retry ENOBUFS errors in TestPacketConnConcurrentReadWriteUnicast
This change is sheer speculation based on the failures observed in golang/go#37319. (A deadlock in the test prevented us from seeing the actual failure mode of golang/go#50455 up until CL 376094, and it isn't obvious to me that we should wait for another failure before trying a likely — and otherwise harmless — fix.) Fixes golang/go#50455. (Maybe.) Change-Id: I7483eb2243832d07cb1f815da196b3978a50c6b3 Reviewed-on: https://go-review.googlesource.com/c/net/+/376095 Trust: Bryan Mills <[email protected]> Run-TryBot: Bryan Mills <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 8b8fc08 commit 5cfca57

File tree

1 file changed

+36
-15
lines changed

1 file changed

+36
-15
lines changed

ipv6/readwrite_test.go

+36-15
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"strings"
1313
"sync"
1414
"testing"
15+
"time"
1516

1617
"golang.org/x/net/internal/iana"
1718
"golang.org/x/net/ipv6"
@@ -440,12 +441,22 @@ func testPacketConnConcurrentReadWriteUnicast(t *testing.T, p *ipv6.PacketConn,
440441
if err := p.SetControlMessage(cf, toggle); err != nil {
441442
fatalf("%v", err)
442443
}
443-
n, err := p.WriteTo(data, &cm, dst)
444-
if err != nil {
445-
fatalf("%v", err)
446-
}
447-
if n != len(data) {
448-
fatalf("got %d; want %d", n, len(data))
444+
445+
backoff := time.Millisecond
446+
for {
447+
n, err := p.WriteTo(data, &cm, dst)
448+
if err != nil {
449+
if n == 0 && isENOBUFS(err) {
450+
time.Sleep(backoff)
451+
backoff *= 2
452+
continue
453+
}
454+
fatalf("%v", err)
455+
}
456+
if n != len(data) {
457+
fatalf("got %d; want %d", n, len(data))
458+
}
459+
break
449460
}
450461
}
451462
batchWriter := func(toggle bool) {
@@ -468,15 +479,25 @@ func testPacketConnConcurrentReadWriteUnicast(t *testing.T, p *ipv6.PacketConn,
468479
Addr: dst,
469480
},
470481
}
471-
n, err := p.WriteBatch(ms, 0)
472-
if err != nil {
473-
fatalf("%v", err)
474-
}
475-
if n != len(ms) {
476-
fatalf("got %d; want %d", n, len(ms))
477-
}
478-
if ms[0].N != len(data) {
479-
fatalf("got %d; want %d", ms[0].N, len(data))
482+
483+
backoff := time.Millisecond
484+
for {
485+
n, err := p.WriteBatch(ms, 0)
486+
if err != nil {
487+
if n == 0 && isENOBUFS(err) {
488+
time.Sleep(backoff)
489+
backoff *= 2
490+
continue
491+
}
492+
fatalf("%v", err)
493+
}
494+
if n != len(ms) {
495+
fatalf("got %d; want %d", n, len(ms))
496+
}
497+
if ms[0].N != len(data) {
498+
fatalf("got %d; want %d", ms[0].N, len(data))
499+
}
500+
break
480501
}
481502
}
482503

0 commit comments

Comments
 (0)