mirror of
https://github.com/mjl-/mox.git
synced 2025-06-28 11:38:16 +03:00
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!
This commit is contained in:
parent
b0e4dcdb61
commit
b37faa06bd
@ -1048,6 +1048,9 @@ func (s server) Send(ctx context.Context, req webapi.SendRequest) (resp webapi.S
|
|||||||
xcheckf(err, "adding messages to the delivery queue")
|
xcheckf(err, "adding messages to the delivery queue")
|
||||||
metricSubmission.WithLabelValues("ok").Inc()
|
metricSubmission.WithLabelValues("ok").Inc()
|
||||||
|
|
||||||
|
// Message has been added to the queue. Ensure we finish the work.
|
||||||
|
ctx = context.WithoutCancel(ctx)
|
||||||
|
|
||||||
if req.SaveSent {
|
if req.SaveSent {
|
||||||
// Append message to Sent mailbox and mark original messages as answered/forwarded.
|
// Append message to Sent mailbox and mark original messages as answered/forwarded.
|
||||||
acc.WithRLock(func() {
|
acc.WithRLock(func() {
|
||||||
|
@ -1005,6 +1005,10 @@ func (w Webmail) MessageSubmit(ctx context.Context, m SubmitMessage) {
|
|||||||
|
|
||||||
var modseq store.ModSeq // Only set if needed.
|
var modseq store.ModSeq // Only set if needed.
|
||||||
|
|
||||||
|
// We have committed to sending the message. We want to follow through
|
||||||
|
// with appending to Sent and removing the draft message.
|
||||||
|
ctx = context.WithoutCancel(ctx)
|
||||||
|
|
||||||
// Append message to Sent mailbox, mark original messages as answered/forwarded,
|
// Append message to Sent mailbox, mark original messages as answered/forwarded,
|
||||||
// remove any draft message.
|
// remove any draft message.
|
||||||
acc.WithWLock(func() {
|
acc.WithWLock(func() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user