From 766ebf8a8537fb48a85d3299469bc25a12e86680 Mon Sep 17 00:00:00 2001 From: alexhudson Date: Wed, 25 Nov 2009 11:16:10 +0000 Subject: [PATCH] Move mail content processing within the logical lock. --- src/agents/store/command.c | 11 ++++++----- src/agents/store/store.c | 5 +++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/agents/store/command.c b/src/agents/store/command.c index 1e45a4c..a33d97c 100644 --- a/src/agents/store/command.c +++ b/src/agents/store/command.c @@ -3116,17 +3116,18 @@ StoreCommandWRITE(StoreClient *client, if (filename) strncpy(newdocument.filename, filename, MAX_FILE_NAME); StoreObjectFixUpFilename(collection, &newdocument); - StoreObjectUpdateImapUID(client, &newdocument); - if (no_process == 0) { - // update metadata if we haven't been asked not to - StoreProcessDocument(client, &newdocument, tmppath); - } if (! LogicalLockGain(client, collection, LLOCK_READWRITE)) { unlink(tmppath); return ConnWriteStr(client->conn, MSG4120BOXLOCKED); } + StoreObjectUpdateImapUID(client, &newdocument); + if (no_process == 0) { + // update metadata if we haven't been asked not to + StoreProcessDocument(client, &newdocument, tmppath); + } + // put content in place FindPathToDocument(client, collection->guid, newdocument.guid, path, sizeof(path)); link(tmppath, path); diff --git a/src/agents/store/store.c b/src/agents/store/store.c index 59c032d..c7944bc 100644 --- a/src/agents/store/store.c +++ b/src/agents/store/store.c @@ -316,14 +316,15 @@ DeliverMessageToMailbox(StoreClient *client, newmail.flags = flags; newmail.time_created = newmail.time_modified = (uint64_t) time(NULL); - StoreProcessDocument(client, &newmail, tmppath); - // need to acquire lock from this point if (! LogicalLockGain(client, &collection, LLOCK_READWRITE)) { StoreObjectRemove(client, &newmail); goto ioerror; } + // possibly need more locking involved in this function + StoreProcessDocument(client, &newmail, tmppath); + // now we have guid etc., move the mail into the right place if (MaildirDeliverTempDocument(client, collection.guid, tmppath, newmail.guid)) { printf("Can't put temporary mail into the store\n");