Skip to content

Commit

Permalink
Lock sendMutex to ensure thread safety in Send
Browse files Browse the repository at this point in the history
Added a mutex lock and unlock around the Send function to prevent concurrent access issues and ensure thread safety. This change helps avoid race conditions when multiple goroutines attempt to send messages simultaneously.
  • Loading branch information
wneessen committed Nov 22, 2024
1 parent be4201b commit 3e504e6
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions client_120.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import (
// Returns:
// - An error that aggregates any SendErrors encountered during the sending process; otherwise, returns nil.
func (c *Client) Send(messages ...*Msg) (returnErr error) {
c.sendMutex.Lock()
defer c.sendMutex.Unlock()
return c.SendWithSMTPClient(c.smtpClient, messages...)
}

Expand Down

0 comments on commit 3e504e6

Please sign in to comment.