aboutsummaryrefslogtreecommitdiffstats
path: root/walrss
diff options
context:
space:
mode:
authorAKP <tom@tdpain.net>2023-04-08 16:53:45 +0100
committerAKP <tom@tdpain.net>2023-04-08 16:53:45 +0100
commit2f3caba65e79900f93e3f0039949df5ef4d2e1d4 (patch)
tree503685e1cb1844344ed74e659b57b8ffca9105b4 /walrss
parent78233315228adb1cb2a8b666d0ca684f57ac0e13 (diff)
Fix potential race condition
Due to a use of `RLock` in place of `Lock` in test email status reporting code, a race condition could arise when more than one user is running a test email. Signed-off-by: AKP <tom@tdpain.net>
Diffstat (limited to 'walrss')
-rw-r--r--walrss/internal/http/testEmail.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/walrss/internal/http/testEmail.go b/walrss/internal/http/testEmail.go
index 5070cbf..86c3e60 100644
--- a/walrss/internal/http/testEmail.go
+++ b/walrss/internal/http/testEmail.go
@@ -66,11 +66,14 @@ func (s *Server) testEmailStatus(ctx *fiber.Ctx) error {
testEmailStatesLock.RLock()
var content string
if end {
+ testEmailStatesLock.RUnlock()
+ testEmailStatesLock.Lock()
delete(testEmailStates, currentUserID)
+ testEmailStatesLock.Unlock()
} else {
content = testEmailStates[currentUserID]
+ testEmailStatesLock.RUnlock()
}
- defer testEmailStatesLock.RUnlock()
if end {
ctx.Set("HX-Refresh", "true")