Index: src/pkg/rpc/client.go |
=================================================================== |
--- a/src/pkg/rpc/client.go |
+++ b/src/pkg/rpc/client.go |
@@ -58,7 +58,7 @@ |
if client.shutdown != nil { |
c.Error = client.shutdown |
client.mutex.Unlock() |
- _ = c.Done <- c // do not block |
+ c.done() |
return |
} |
c.seq = client.seq |
@@ -102,16 +102,14 @@ |
// Empty strings should turn into nil os.Errors |
c.Error = nil |
} |
- // We don't want to block here. It is the caller's responsibility to make |
- // sure the channel has enough buffer space. See comment in Go(). |
- _ = c.Done <- c // do not block |
+ c.done() |
} |
// Terminate pending calls. |
client.mutex.Lock() |
client.shutdown = err |
for _, call := range client.pending { |
call.Error = err |
- _ = call.Done <- call // do not block |
+ call.done() |
} |
client.mutex.Unlock() |
if err != os.EOF || !client.closing { |
@@ -119,6 +117,16 @@ |
} |
} |
+func (call *Call) done() { |
+ select { |
+ case call.Done <- call: |
+ // ok |
+ default: |
+ // We don't want to block here. It is the caller's responsibility to make |
+ // sure the channel has enough buffer space. See comment in Go(). |
+ } |
+} |
+ |
// NewClient returns a new Client to handle requests to the |
// set of services at the other end of the connection. |
func NewClient(conn io.ReadWriteCloser) *Client { |
@@ -233,7 +241,7 @@ |
c.Done = done |
if client.shutdown != nil { |
c.Error = client.shutdown |
- _ = c.Done <- c // do not block |
+ c.done() |
return c |
} |
client.send(c) |