FAQ
Reviewers: golang-dev_googlegroups.com,

Message:
Hello golang-dev@googlegroups.com (cc: bradfitz@golang.org,
dave@cheney.net),

I'd like you to review this change to
https://go.googlecode.com/hg/


Description:
net: add deadline prolongation test
Currently the test exposes data races on deadline vars.

Please review this at http://codereview.appspot.com/6845091/

Affected files:
M src/pkg/net/timeout_test.go


Index: src/pkg/net/timeout_test.go
===================================================================
--- a/src/pkg/net/timeout_test.go
+++ b/src/pkg/net/timeout_test.go
@@ -576,3 +576,48 @@
t.Errorf("Write error = %v; want timeout", res.err)
}
}
+
+func TestProlongTimeout(t *testing.T) {
+ switch runtime.GOOS {
+ case "plan9":
+ t.Logf("skipping test on %q", runtime.GOOS)
+ return
+ }
+
+ ln := newLocalListener(t)
+ defer ln.Close()
+ c, err := DialTCP("tcp", nil, ln.Addr().(*TCPAddr))
+ if err != nil {
+ t.Fatalf("DialTCP: %v", err)
+ }
+ defer c.Close()
+ s, err := ln.Accept()
+ if err != nil {
+ t.Fatalf("ln.Accept: %v", err)
+ }
+ defer s.Close()
+ s.SetDeadline(time.Now().Add(time.Hour))
+ go func() {
+ buf := [4096]byte{}
+ for {
+ _, err := s.Write(buf[:])
+ if err != nil {
+ break
+ }
+ }
+ }()
+ go func() {
+ buf := make([]byte, 1)
+ for {
+ _, err := s.Read(buf)
+ if err != nil {
+ break
+ }
+ s.SetDeadline(time.Now().Add(time.Hour))
+ }
+ }()
+ for i := 0; i < 1024; i++ {
+ buf := [1]byte{}
+ c.Write(buf[:])
+ }
+}

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-dev @
categoriesgo
postedNov 25, '12 at 10:59a
activeNov 26, '12 at 7:09p
posts14
users4
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase