MCPcopy
hub / github.com/aceld/zinx / Stop

Method Stop

znet/client.go:276–297  ·  view source on GitHub ↗

保证重复调用Stop不会导致panic

()

Source from the content-addressed store, hash-verified

274
275// 保证重复调用Stop不会导致panic
276func (c *Client) Stop() {
277 c.Lock()
278 defer c.Unlock()
279 if !c.started {
280 return
281 }
282 c.started = false
283
284 con := c.Conn()
285 if con != nil {
286 zlog.Ins().InfoF("[STOP] Zinx Client LocalAddr: %s, RemoteAddr: %s\n", con.LocalAddr(), con.RemoteAddr())
287 con.Stop()
288 }
289
290 // c.exitChan <- struct{}{}
291 // close(c.exitChan)
292 // close(c.ErrChan)
293 if c.cancel != nil {
294 c.cancel()
295 }
296 c.Wait()
297}
298
299func (c *Client) AddRouter(msgID uint32, router ziface.IRouter) {
300 c.msgHandler.AddRouter(msgID, router)

Callers 8

RestartMethod · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95

Calls 6

ConnMethod · 0.95
InsFunction · 0.92
InfoFMethod · 0.65
LocalAddrMethod · 0.65
RemoteAddrMethod · 0.65
StopMethod · 0.65

Tested by

no test coverage detected