Merge pull request #240 from Leon2012/master

fix bug #239
This commit is contained in:
Asim Aslam 2018-03-21 18:54:52 +00:00 committed by GitHub
commit edaa0a0719
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -13,12 +13,14 @@ import (
"github.com/micro/go-micro/metadata"
"github.com/micro/go-micro/selector"
"github.com/micro/go-micro/transport"
"sync/atomic"
)
type rpcClient struct {
once sync.Once
opts Options
pool *pool
seq uint64
}
func newRpcClient(opt ...Option) Client {
@ -28,6 +30,7 @@ func newRpcClient(opt ...Option) Client {
once: sync.Once{},
opts: opts,
pool: newPool(opts.PoolSize, opts.PoolTTL),
seq: 0,
}
c := Client(rc)
@ -84,11 +87,15 @@ func (r *rpcClient) call(ctx context.Context, address string, req Request, resp
r.pool.release(address, c, grr)
}()
seq := r.seq
atomic.AddUint64(&r.seq, 1)
stream := &rpcStream{
context: ctx,
request: req,
closed: make(chan bool),
codec: newRpcPlusCodec(msg, c, cf),
seq: seq,
}
defer stream.Close()

View File

@ -44,7 +44,6 @@ func (r *rpcStream) Send(msg interface{}) error {
}
seq := r.seq
r.seq++
req := request{
Service: r.request.Service(),