fixed leak dispatching alerts

Fixed potential leak when disconnecting from the GUI, and at the same
time dispatching an alert/message to the GUI.
This commit is contained in:
Gustavo Iñiguez Goia 2023-12-31 20:12:44 +01:00
parent 68c2c8ae1a
commit 050e3c51b0
Failed to generate hash of commit

View file

@ -116,7 +116,10 @@ func (c *Client) alertsDispatcher() {
}
func (c *Client) dispatchAlert(pbAlert protocol.Alert) {
if c.client == nil {
c.RLock()
isDisconnected := c.client == nil
c.RUnlock()
if isDisconnected {
return
}
ctx, cancel := context.WithTimeout(context.Background(), time.Second)