// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build !race
-
package ioutil
-var blackHoleBuf = make([]byte, 8192)
+var blackHoleBuf = make(chan []byte, 1)
func blackHole() []byte {
- return blackHoleBuf
+ select {
+ case b := <-blackHoleBuf:
+ return b
+ default:
+ }
+ return make([]byte, 8192)
+}
+
+func blackHolePut(p []byte) {
+ select {
+ case blackHoleBuf <- p:
+ default:
+ }
}
+++ /dev/null
-// Copyright 2012 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build race
-
-package ioutil
-
-// Replaces the normal fast implementation with slower but formally correct one.
-
-func blackHole() []byte {
- return make([]byte, 8192)
-}
func (devNull) ReadFrom(r io.Reader) (n int64, err error) {
buf := blackHole()
+ defer blackHolePut(buf)
readSize := 0
for {
readSize, err = r.Read(buf)