This commit is contained in:
crusader 2018-04-26 21:22:39 +09:00
parent 19bd7a7b85
commit fe3407551c

View File

@ -252,7 +252,7 @@ LOOP:
if 0 < rs.id { if 0 < rs.id {
c.pendingRequests.Store(rs.id, rs) c.pendingRequests.Store(rs.id, rs)
} }
case <-c.stopChan: case <-stopChan:
return return
} }
} }
@ -289,11 +289,9 @@ LOOP:
continue LOOP continue LOOP
} }
c.stopWg.Add(1)
go c.handleNotification(notiCodec) go c.handleNotification(notiCodec)
} else { } else {
// response // response
c.stopWg.Add(1)
go c.handleResponse(resCodec) go c.handleResponse(resCodec)
} }
case <-stopChan: case <-stopChan:
@ -304,9 +302,6 @@ LOOP:
} }
func (c *Client) handleResponse(resCodec protocol.ClientResponseCodec) { func (c *Client) handleResponse(resCodec protocol.ClientResponseCodec) {
defer func() {
c.stopWg.Done()
}()
id := reflect.ValueOf(resCodec.ID()).Convert(uint64Type).Uint() id := reflect.ValueOf(resCodec.ID()).Convert(uint64Type).Uint()
_rs, ok := c.pendingRequests.Load(id) _rs, ok := c.pendingRequests.Load(id)
if !ok { if !ok {
@ -324,10 +319,6 @@ func (c *Client) handleResponse(resCodec protocol.ClientResponseCodec) {
} }
func (c *Client) handleNotification(notiCodec protocol.ClientNotificationCodec) { func (c *Client) handleNotification(notiCodec protocol.ClientNotificationCodec) {
defer func() {
c.stopWg.Done()
}()
if nil == c.RPCInvoker { if nil == c.RPCInvoker {
logging.Logger().Warnf("%s received notification method[%s] but RPC Invoker is not exist", c.logHeader(), notiCodec.Method()) logging.Logger().Warnf("%s received notification method[%s] but RPC Invoker is not exist", c.logHeader(), notiCodec.Method())
return return