瀏覽代碼

rafthttp: fix race in TestStreamWriterAttachOutgoingConn

Fixes #6230
Anthony Romano 9 年之前
父節點
當前提交
784c4446d9
共有 1 個文件被更改,包括 4 次插入5 次删除
  1. 4 5
      rafthttp/stream_test.go

+ 4 - 5
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 {