From d9973215da265703d38d89f96e6f6037018026eb Mon Sep 17 00:00:00 2001 From: crusader Date: Wed, 1 Nov 2017 18:01:23 +0900 Subject: [PATCH] ing --- client/client.go | 7 +++++-- client/constants.go | 7 ++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/client/client.go b/client/client.go index baebb3a..cb69dfd 100644 --- a/client/client.go +++ b/client/client.go @@ -4,6 +4,7 @@ import ( "fmt" "log" "net" + "reflect" "runtime" "sync" "sync/atomic" @@ -297,9 +298,11 @@ func (c *client) rpcReader(readerDone chan<- error) { func (c *client) responseHandle(codecResponse protocol.ClientCodecResponse) error { c.pendingRequestsLock.Lock() - cs, ok := c.pendingRequests[codecResponse.ID().(uint64)] + id := reflect.ValueOf(codecResponse.ID()).Convert(uint64Type).Uint() + + cs, ok := c.pendingRequests[id] if ok { - delete(c.pendingRequests, codecResponse.ID().(uint64)) + delete(c.pendingRequests, id) } c.pendingRequestsLock.Unlock() diff --git a/client/constants.go b/client/constants.go index a741697..0f266e5 100644 --- a/client/constants.go +++ b/client/constants.go @@ -1,6 +1,9 @@ package client -import "time" +import ( + "reflect" + "time" +) const ( // DefaultRequestTimeout is the default timeout for client request. @@ -10,3 +13,5 @@ const ( // handled by Client and Server. DefaultPendingMessages = 32 * 1024 ) + +var uint64Type = reflect.TypeOf(uint64(0))