summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/pkg/reflect/all_test.go2
-rw-r--r--src/pkg/rpc/client.go12
2 files changed, 9 insertions, 5 deletions
diff --git a/src/pkg/reflect/all_test.go b/src/pkg/reflect/all_test.go
index 45a76259a..f2e2f92bc 100644
--- a/src/pkg/reflect/all_test.go
+++ b/src/pkg/reflect/all_test.go
@@ -349,7 +349,7 @@ func TestPtrPointTo(t *testing.T) {
}
}
-func TestAll(t *testing.T) { // TODO(r): wrap up better
+func TestAll(t *testing.T) {
testType(t, 1, Typeof((int8)(0)), "int8");
testType(t, 2, Typeof((*int8)(nil)).(*PtrType).Elem(), "int8");
diff --git a/src/pkg/rpc/client.go b/src/pkg/rpc/client.go
index 01dcec7db..e1b6a14ec 100644
--- a/src/pkg/rpc/client.go
+++ b/src/pkg/rpc/client.go
@@ -96,7 +96,7 @@ func (client *Client) input() {
_ = call.Done <- call; // do not block
}
client.mutex.Unlock();
- log.Stderr("client protocol error:", err);
+ log.Stderr("rpc: client protocol error:", err);
}
// NewClient returns a new Client to handle requests to the
@@ -144,18 +144,22 @@ func Dial(network, address string) (*Client, os.Error) {
// Go invokes the function asynchronously. It returns the Call structure representing
// the invocation. The done channel will signal when the call is complete by returning
// the same Call object. If done is nil, Go will allocate a new channel.
+// If non-nil, done must be buffered or Go will deliberately crash.
func (client *Client) Go(serviceMethod string, args interface{}, reply interface{}, done chan *Call) *Call {
c := new(Call);
c.ServiceMethod = serviceMethod;
c.Args = args;
c.Reply = reply;
if done == nil {
- done = make(chan *Call, 1); // buffered.
+ done = make(chan *Call, 10); // buffered.
} else {
- // TODO(r): check cap > 0
// If caller passes done != nil, it must arrange that
// done has enough buffer for the number of simultaneous
- // RPCs that will be using that channel.
+ // RPCs that will be using that channel. If the channel
+ // is totally unbuffered, it's best not to run at all.
+ if cap(done) == 0 {
+ log.Crash("rpc: done channel is unbuffered");
+ }
}
c.Done = done;
if client.shutdown != nil {