Lock mutex when setting the logger

Add mutex locking to ensure thread-safety when setting the logger in the `smtp` package. This prevents potential race conditions and ensures that the logger is updated consistently in concurrent operations.
This commit is contained in:
Winni Neessen 2024-11-11 17:47:59 +01:00
parent 59f2778a38
commit 9412f31874
Signed by: wneessen
GPG key ID: 385AC9889632126E

View file

@ -587,7 +587,9 @@ func (c *Client) SetLogger(l log.Logger) {
if l == nil {
return
}
c.mutex.Lock()
c.logger = l
c.mutex.Unlock()
}
// SetLogAuthData enables logging of authentication data in the Client.