FAQ
Reviewers: golang-dev_googlegroups.com,

Message:
Hello golang-dev@googlegroups.com,

I'd like you to review this change to
https://code.google.com/p/go


Description:
log/syslog: fix flakey test on slow hosts

Fixes issue 4467.

The syslog tests can fail if the timeout fires before the data arrives
at the mock server. Moving the timeout onto the goroutine that is
calling ReadFrom() and always processing the data returned before
handling the error should improve the reliability of the test.

Please review this at https://codereview.appspot.com/6920047/

Affected files:
M src/pkg/log/syslog/syslog_test.go


Index: src/pkg/log/syslog/syslog_test.go
===================================================================
--- a/src/pkg/log/syslog/syslog_test.go
+++ b/src/pkg/log/syslog/syslog_test.go
@@ -22,11 +22,12 @@
var buf [4096]byte
var rcvd string = ""
for {
- n, _, err := c.ReadFrom(buf[0:])
- if err != nil || n == 0 {
+ c.SetReadDeadline(time.Now().Add(100 * time.Millisecond))
+ n, _, err := c.ReadFrom(buf[:])
+ rcvd += string(buf[:n])
+ if err != nil {
break
}
- rcvd += string(buf[0:n])
}
done <- rcvd
}
@@ -37,7 +38,6 @@
log.Fatalf("net.ListenPacket failed udp :0 %v", e)
}
serverAddr = c.LocalAddr().String()
- c.SetReadDeadline(time.Now().Add(100 * time.Millisecond))
go runSyslog(c, done)
}

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-dev @
categoriesgo
postedDec 12, '12 at 2:47a
activeDec 12, '12 at 8:02p
posts2
users2
websitegolang.org

2 users in discussion

Dave: 1 post Bradfitz: 1 post

People

Translate

site design / logo © 2022 Grokbase