Move mail content processing within the logical lock.

This commit is contained in:
alexhudson
2009-11-25 11:16:10 +00:00
parent fc505dbe05
commit 766ebf8a85
2 changed files with 9 additions and 7 deletions
+6 -5
View File
@@ -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);
+3 -2
View File
@@ -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");