Skip to content

Commit

Permalink
Merge pull request #439 from Darkren/fix/data_race_in_dmsg_test
Browse files Browse the repository at this point in the history
Fix data race
  • Loading branch information
志宇 authored Jun 26, 2019
2 parents e68e923 + 3cd7bd8 commit 2ca345d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0 h1:HyfiK1WMnHj5FXFXatD+Qs1A/xC2Run6RzeW1SyHxpc=
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
Expand Down
9 changes: 7 additions & 2 deletions pkg/dmsg/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -719,9 +719,11 @@ func TestServer_Serve(t *testing.T) {
}

// block on `Write`
var blockedWriteErr error
blockedWriteDone := make(chan struct{})
go func() {
_, err = aWrTransport.Write(msg)
require.Error(t, err)
_, blockedWriteErr = aWrTransport.Write(msg)
close(blockedWriteDone)
}()

// wait till it's definitely blocked
Expand Down Expand Up @@ -749,6 +751,9 @@ func TestServer_Serve(t *testing.T) {
err = aWrTransport.Close()
require.NoError(t, err)

<-blockedWriteDone
require.Error(t, blockedWriteErr)

err = bWrTransport.Close()
require.NoError(t, err)

Expand Down

0 comments on commit 2ca345d

Please sign in to comment.