This commit is contained in:
crusader 2017-11-01 18:01:23 +09:00
parent a8acaab5b8
commit d9973215da
2 changed files with 11 additions and 3 deletions

View File

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"log" "log"
"net" "net"
"reflect"
"runtime" "runtime"
"sync" "sync"
"sync/atomic" "sync/atomic"
@ -297,9 +298,11 @@ func (c *client) rpcReader(readerDone chan<- error) {
func (c *client) responseHandle(codecResponse protocol.ClientCodecResponse) error { func (c *client) responseHandle(codecResponse protocol.ClientCodecResponse) error {
c.pendingRequestsLock.Lock() 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 { if ok {
delete(c.pendingRequests, codecResponse.ID().(uint64)) delete(c.pendingRequests, id)
} }
c.pendingRequestsLock.Unlock() c.pendingRequestsLock.Unlock()

View File

@ -1,6 +1,9 @@
package client package client
import "time" import (
"reflect"
"time"
)
const ( const (
// DefaultRequestTimeout is the default timeout for client request. // DefaultRequestTimeout is the default timeout for client request.
@ -10,3 +13,5 @@ const (
// handled by Client and Server. // handled by Client and Server.
DefaultPendingMessages = 32 * 1024 DefaultPendingMessages = 32 * 1024
) )
var uint64Type = reflect.TypeOf(uint64(0))