[client] Avoid panic when there is no conn client (#2541)

This commit is contained in:
Maycon Santos 2024-09-05 15:09:46 +02:00 committed by GitHub
parent f2b5b2e9b5
commit bdbd1db843
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -297,6 +297,9 @@ func (c *ConnectClient) run(
} }
func (c *ConnectClient) Engine() *Engine { func (c *ConnectClient) Engine() *Engine {
if c == nil {
return nil
}
var e *Engine var e *Engine
c.engineMutex.Lock() c.engineMutex.Lock()
e = c.engine e = c.engine
@ -305,8 +308,15 @@ func (c *ConnectClient) Engine() *Engine {
} }
func (c *ConnectClient) Stop() error { func (c *ConnectClient) Stop() error {
if c == nil {
return nil
}
c.engineMutex.Lock() c.engineMutex.Lock()
defer c.engineMutex.Unlock() defer c.engineMutex.Unlock()
if c.engine == nil {
return nil
}
return c.engine.Stop() return c.engine.Stop()
} }