cbdatasource fix send on closed channel
cbdatasource fix send on closed channel

The worker() func in cbdatasource drives a single DCP connection, and
it has 3 related goroutines:

- A sender goroutine:
    for msg := range sendCh { ... transmit msg on conn ... }

- A receiver goroutine:
    for { ... receive req from conn ... }

- A mgmt goroutine:
    for { ... receive control/mgmt orders & events ... }

The receiver goroutine and mgmt goroutine can both write to the sendCh
to get messages transmitted.

The race was that the mgmt goroutine would want to shutdown and invoke
its cleanup() func.  The cleanup() func would then close(sendCh), but
incorrectly did not ensure that the receiver goroutine was done
already.

So, there could have been send on an already closed sendCh by the
receiver goroutine...

    goroutine 2497 [running]:
    go-couchbase/cbdatasource.(bucketDataSource).sendStreamReq(...)
        go-couchbase/cbdatasource/cbdatasource.go:1314 +0x74e
    go-couchbase/cbdatasource.(bucketDataSource).handleRecv(...)
        go-couchbase/cbdatasource/cbdatasource.go:1073 +0xe46
    go-couchbase/cbdatasource.func·007()
        go-couchbase/cbdatasource/cbdatasource.go:904 +0x57a
    created by go-couchbase/cbdatasource.(*bucketDataSource).worker
        go-couchbase/cbdatasource/cbdatasource.go:926 +0x10c2

This fix waits for the receiver goroutine to be done before cleanup()
can close the sendCh.

Change-Id: If8809b5f2d50570ae704a74d3aed48b430cfd753
Reviewed-on: http://review.couchbase.org/50459
Reviewed-by: Marty Schoch <ba9951d7d66412e2a57aea395f01176a793cf5eb@gmail.com>
Tested-by: Steve Yen <ef850f73f7832052d3c6d9b5ddd3a1716d9a57f1@gmail.com>

couchbase/go-couchbase,nimishzynga/go-couchbase