From f9e869061e9a7085d199be3408cebfaa708f9386 Mon Sep 17 00:00:00 2001 From: Winni Neessen Date: Fri, 22 Nov 2024 14:58:41 +0100 Subject: [PATCH] Add mutex locks to DSN option setters Mutex locks are added to ensure thread safety when setting DSN mail return and recipient notify options. This prevents data races in concurrent environments, improving the client's robustness. --- smtp/smtp.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/smtp/smtp.go b/smtp/smtp.go index 8a278ee..24a079f 100644 --- a/smtp/smtp.go +++ b/smtp/smtp.go @@ -601,12 +601,16 @@ func (c *Client) SetLogAuthData() { // SetDSNMailReturnOption sets the DSN mail return option for the Mail method func (c *Client) SetDSNMailReturnOption(d string) { + c.mutex.Lock() c.dsnmrtype = d + c.mutex.Unlock() } // SetDSNRcptNotifyOption sets the DSN recipient notify option for the Mail method func (c *Client) SetDSNRcptNotifyOption(d string) { + c.mutex.Lock() c.dsnrntype = d + c.mutex.Unlock() } // HasConnection checks if the client has an active connection.