veyron/runtimes/google/ipc: Disallow multiple calls to Finish.
I had a bug where my code was calling Finish multiple times.
That resulted in an obscure error in the ipc implementation as
it tried to read the rpc results from the stream a second time.
Of course, there were no results to be read, but the error made
it look like the server had failed to send the results. This
change makes it clear that multiple calls to Finish are not
allowed.
Change-Id: I42c3aeac5f54c619c7de0102e90ef98fe2096c59
diff --git a/runtimes/google/ipc/full_test.go b/runtimes/google/ipc/full_test.go
index 2ac1be0..20252a6 100644
--- a/runtimes/google/ipc/full_test.go
+++ b/runtimes/google/ipc/full_test.go
@@ -599,6 +599,26 @@
}
}
+func TestMultipleFinish(t *testing.T) {
+ type v []interface{}
+ b := createBundle(t, clientID, serverID, &testServer{})
+ defer b.cleanup(t)
+ call, err := b.client.StartCall(testContext(), "mountpoint/server/suffix", "Echo", v{"foo"})
+ if err != nil {
+ t.Fatalf(`client.StartCall got error "%v"`, err)
+ }
+ var results string
+ err = call.Finish(&results)
+ if err != nil {
+ t.Fatalf(`call.Finish got error "%v"`, err)
+ }
+ // Calling Finish a second time should result in a useful error.
+ err = call.Finish(&results)
+ if got, want := err, verror.BadProtocolf("ipc: multiple calls to Finish not allowed"); got != want {
+ t.Fatalf(`call.Finish got error "%v", want "%v"`, got, want)
+ }
+}
+
// granter implements ipc.Granter, returning a fixed (security.PublicID, error) pair.
type granter struct {
ipc.CallOpt