Skip to content

Commit

Permalink
net/rpc: call client.Close() when test exit
Browse files Browse the repository at this point in the history
Fixes #5768.

R=golang-dev
CC=golang-dev
https://golang.org/cl/10503043
  • Loading branch information
chai2010 authored and robpike committed Jun 24, 2013
1 parent 6db28ee commit b78aaec
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/pkg/net/rpc/server_test.go
Expand Up @@ -125,6 +125,7 @@ func testRPC(t *testing.T, addr string) {
if err != nil {
t.Fatal("dialing", err)
}
defer client.Close()

// Synchronous calls
args := &Args{7, 8}
Expand Down Expand Up @@ -253,6 +254,7 @@ func testHTTPRPC(t *testing.T, path string) {
if err != nil {
t.Fatal("dialing", err)
}
defer client.Close()

// Synchronous calls
args := &Args{7, 8}
Expand Down Expand Up @@ -329,6 +331,7 @@ func TestServeRequest(t *testing.T) {

func testServeRequest(t *testing.T, server *Server) {
client := CodecEmulator{server: server}
defer client.Close()

args := &Args{7, 8}
reply := new(Reply)
Expand Down Expand Up @@ -411,6 +414,7 @@ func (WriteFailCodec) Close() error {

func TestSendDeadlock(t *testing.T) {
client := NewClientWithCodec(WriteFailCodec(0))
defer client.Close()

done := make(chan bool)
go func() {
Expand Down Expand Up @@ -449,6 +453,8 @@ func countMallocs(dial func() (*Client, error), t *testing.T) float64 {
if err != nil {
t.Fatal("error dialing", err)
}
defer client.Close()

args := &Args{7, 8}
reply := new(Reply)
return testing.AllocsPerRun(100, func() {
Expand Down Expand Up @@ -496,6 +502,8 @@ func (writeCrasher) Write(p []byte) (int, error) {
func TestClientWriteError(t *testing.T) {
w := &writeCrasher{done: make(chan bool)}
c := NewClient(w)
defer c.Close()

res := false
err := c.Call("foo", 1, &res)
if err == nil {
Expand Down Expand Up @@ -552,6 +560,7 @@ func benchmarkEndToEnd(dial func() (*Client, error), b *testing.B) {
if err != nil {
b.Fatal("error dialing:", err)
}
defer client.Close()

// Synchronous calls
args := &Args{7, 8}
Expand Down Expand Up @@ -587,6 +596,7 @@ func benchmarkEndToEndAsync(dial func() (*Client, error), b *testing.B) {
if err != nil {
b.Fatal("error dialing:", err)
}
defer client.Close()

// Asynchronous calls
args := &Args{7, 8}
Expand Down

0 comments on commit b78aaec

Please sign in to comment.