Commit 841a6272 authored by Steven Allen's avatar Steven Allen
Browse files

fix a data-race in the mock net

This was causing https://github.com/ipfs/go-ipfs/pull/5637#issuecomment-432792969
No related merge requests found
Showing with 5 additions and 0 deletions
+5 -0
......@@ -56,6 +56,11 @@ func (s *stream) Write(p []byte) (n int, err error) {
l := s.conn.link
delay := l.GetLatency() + l.RateLimit(len(p))
t := time.Now().Add(delay)
// Copy it.
cpy := make([]byte, len(p))
copy(cpy, p)
select {
case <-s.closed: // bail out if we're closing.
return 0, s.writeErr
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment