Lock mutex before checking connection in Send method

Added mutex locking in the `Send` method for both `client_120.go` and `client_119.go`. This ensures thread-safe access to the connection checks and prevents potential race conditions.
This commit is contained in:
Winni Neessen 2024-09-27 10:33:28 +02:00
parent 371b950bc7
commit 23c71d608f
Signed by: wneessen
GPG key ID: 385AC9889632126E
2 changed files with 4 additions and 0 deletions

View file

@ -11,6 +11,9 @@ import "errors"
// Send sends out the mail message
func (c *Client) Send(messages ...*Msg) error {
c.mutex.Lock()
defer c.mutex.Unlock()
if err := c.checkConn(); err != nil {
return &SendError{Reason: ErrConnCheck, errlist: []error{err}, isTemp: isTempError(err)}
}

View file

@ -15,6 +15,7 @@ import (
func (c *Client) Send(messages ...*Msg) (returnErr error) {
c.mutex.Lock()
defer c.mutex.Unlock()
if err := c.checkConn(); err != nil {
returnErr = &SendError{Reason: ErrConnCheck, errlist: []error{err}, isTemp: isTempError(err)}
return