veyron/runtimes/google/ipc: Fix race between concurrent calls to ipc.ClientCall.CloseSend and ipc.ClientCall.Finish

Have Send/CloseSend be called in a goroutine separate from the one calling
Finish is a reasonable pattern, so this commit fixes races in that pattern.

While at it, also:
- Repeated calls to CloseSend will not return an error if a previous one succeeded
- (unrelated) using a WaitGroup instead of a channel for vc_test.go, it's simpler in this
  use case.

This fixes some races detected by the continuous build, such as in:
go test -race veyron2/vdl/test_arith

==================
WARNING: DATA RACE
Read by goroutine 117:
  veyron/runtimes/google/ipc.(*flowClient).closeSend()
      /Users/ashankar/veyron/veyron/go/src/veyron/runtimes/google/ipc/client.go:297 +0x60
  veyron/runtimes/google/ipc.(*flowClient).finish()
      /Users/ashankar/veyron/veyron/go/src/veyron/runtimes/google/ipc/client.go:327 +0x5d
  veyron/runtimes/google/ipc.(*flowClient).Finish()
      /Users/ashankar/veyron/veyron/go/src/veyron/runtimes/google/ipc/client.go:308 +0x64
  veyron2/vdl/test_arith.(*implArithStreamingAddStream).Finish()
      /Users/ashankar/veyron/veyron/go/src/veyron2/vdl/test_arith/arith.vdl.go:221 +0x184
  veyron2/vdl/test_arith.TestArith()
      /Users/ashankar/veyron/veyron/go/src/veyron2/vdl/test_arith/arith_test.go:443 +0x1d4c
  testing.tRunner()
      /Users/ashankar/veyron/environment/go/src/pkg/testing/testing.go:422 +0x10f

Previous write by goroutine 236:
  veyron/runtimes/google/ipc.(*flowClient).closeSend()
      /Users/ashankar/veyron/veyron/go/src/veyron/runtimes/google/ipc/client.go:303 +0x237
  veyron/runtimes/google/ipc.(*flowClient).CloseSend()
      /Users/ashankar/veyron/veyron/go/src/veyron/runtimes/google/ipc/client.go:292 +0x46
  veyron2/vdl/test_arith.(*implArithStreamingAddStream).CloseSend()
      /Users/ashankar/veyron/veyron/go/src/veyron2/vdl/test_arith/arith.vdl.go:212 +0x62
  veyron2/vdl/test_arith.funcĀ·001()
      /Users/ashankar/veyron/veyron/go/src/veyron2/vdl/test_arith/arith_test.go:423 +0x1a4

Change-Id: I87df897a2c8accfb49c1b80e6f27f8cce3749565
2 files changed
tree: e3645122bac94e75374128af7ac718963b2464c2
  1. examples/
  2. lib/
  3. runtimes/
  4. security/
  5. services/
  6. tools/