From 784c4446d96035094e87340a56a2e0c4b6711824 Mon Sep 17 00:00:00 2001 From: Anthony Romano Date: Fri, 19 Aug 2016 19:12:59 -0700 Subject: [PATCH] rafthttp: fix race in TestStreamWriterAttachOutgoingConn Fixes #6230 --- rafthttp/stream_test.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/rafthttp/stream_test.go b/rafthttp/stream_test.go index 0d6848eb1..f48714e7c 100644 --- a/rafthttp/stream_test.go +++ b/rafthttp/stream_test.go @@ -59,11 +59,10 @@ func TestStreamWriterAttachOutgoingConn(t *testing.T) { } } - // msgc has been swapped with a new one now that prevwfc is closed - msgc, ok := sw.writec() - if !ok { - t.Errorf("#%d: working status = %v, want true", i, ok) - } + // if prevwfc != nil, the new msgc is ready since prevwfc has closed + // if prevwfc == nil, the first connection may be pending, but the first + // msgc is already available since it's set on calling startStreamwriter + msgc, _ := sw.writec() msgc <- raftpb.Message{} select {