summaryrefslogtreecommitdiff
path: root/src/pkg/rpc/client.go
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2011-02-14 13:23:51 +0100
committerOndřej Surý <ondrej@sury.org>2011-02-14 13:23:51 +0100
commit758ff64c69e34965f8af5b2d6ffd65e8d7ab2150 (patch)
tree6d6b34f8c678862fe9b56c945a7b63f68502c245 /src/pkg/rpc/client.go
parent3e45412327a2654a77944249962b3652e6142299 (diff)
downloadgolang-upstream/2011-02-01.1.tar.gz
Imported Upstream version 2011-02-01.1upstream/2011-02-01.1
Diffstat (limited to 'src/pkg/rpc/client.go')
-rw-r--r--src/pkg/rpc/client.go20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/pkg/rpc/client.go b/src/pkg/rpc/client.go
index 601c49715..6f028c10d 100644
--- a/src/pkg/rpc/client.go
+++ b/src/pkg/rpc/client.go
@@ -58,7 +58,7 @@ func (client *Client) send(c *Call) {
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 @@ func (client *Client) input() {
// 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 (client *Client) input() {
}
}
+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 @@ func (client *Client) Go(serviceMethod string, args interface{}, reply interface
c.Done = done
if client.shutdown != nil {
c.Error = client.shutdown
- _ = c.Done <- c // do not block
+ c.done()
return c
}
client.send(c)