Skip to content

Commit b37faa0

Browse files
committedMar 23, 2025··
After queueing a message in the web api's, prevent context cancelation from completing message changes
Adding to the queue is done in a transaction, the queue db file is mox-global. Appending the message to the Sent folder, removing it from Drafts, marking the original message as answered/forwarded, is done in a separate database transaction that gets the ctx passed in. If the ctx was canceled in between, the queueing was finished, but the rest wasn't completed. Reported by mteege, thanks!
1 parent b0e4dcd commit b37faa0

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed
 

‎webapisrv/server.go

+3
Original file line numberDiff line numberDiff line change
@@ -1048,6 +1048,9 @@ func (s server) Send(ctx context.Context, req webapi.SendRequest) (resp webapi.S
10481048
xcheckf(err, "adding messages to the delivery queue")
10491049
metricSubmission.WithLabelValues("ok").Inc()
10501050

1051+
// Message has been added to the queue. Ensure we finish the work.
1052+
ctx = context.WithoutCancel(ctx)
1053+
10511054
if req.SaveSent {
10521055
// Append message to Sent mailbox and mark original messages as answered/forwarded.
10531056
acc.WithRLock(func() {

‎webmail/api.go

+4
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,10 @@ func (w Webmail) MessageSubmit(ctx context.Context, m SubmitMessage) {
10051005

10061006
var modseq store.ModSeq // Only set if needed.
10071007

1008+
// We have committed to sending the message. We want to follow through
1009+
// with appending to Sent and removing the draft message.
1010+
ctx = context.WithoutCancel(ctx)
1011+
10081012
// Append message to Sent mailbox, mark original messages as answered/forwarded,
10091013
// remove any draft message.
10101014
acc.WithWLock(func() {

0 commit comments

Comments
 (0)
Please sign in to comment.