From: Taylor R Campbell Date: Sat, 10 Aug 2013 21:11:17 +0000 (+0000) Subject: Remove logic to lock IMAIL's IMAP folder cache. X-Git-Tag: release-9.2.0~145 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=a4591d8884226d416cc785b9fd508f1264d2b36a;p=mit-scheme.git Remove logic to lock IMAIL's IMAP folder cache. Keep WITH-FOLDER-LOCKED as an empty stub so we might use it later to let the user control whether to use a cache at all. There are no invariants that need to be preserved, so locking only slows us down and reduces concurrency. Two clients fetching the same item may collide, but the collision is harmless -- unless the server is bogus, they will be writing the same data. Adding an entry to the cache is already atomic (unless the system fails before the blocks have hit the disk) through the use of a temporary directory. --- diff --git a/src/imail/imail-imap.scm b/src/imail/imail-imap.scm index 01afc12f9..b5a092f24 100644 --- a/src/imail/imail-imap.scm +++ b/src/imail/imail-imap.scm @@ -795,8 +795,6 @@ USA. (define-class () (connection define standard initial-value #f) - (cache-lock-state define standard - initial-value 'UNKNOWN) (read-only? define standard) (allowed-flags define standard) (permanent-flags define standard) @@ -2035,44 +2033,12 @@ USA. (delete-file-recursively (imap-message-cache-pathname message))))) (define (with-folder-locked folder if-locked #!optional if-not-locked) - (if (eq? 'LOCKED (imap-folder-cache-lock-state folder)) - (if-locked) - (let ((if-not-locked - (if (default-object? if-not-locked) #f if-not-locked)) - (pathname - (imap-folder-lock-pathname folder))) - (guarantee-init-file-directory pathname) - (dynamic-wind - (lambda () unspecific) - (lambda () - (let loop ((i 0)) - (without-interrupts - (lambda () - (if (allocate-temporary-file pathname) - (set-imap-folder-cache-lock-state! folder 'LOCKED)) - unspecific)) - (cond ((eq? 'LOCKED (imap-folder-cache-lock-state folder)) - (if (> i 0) - (imail-ui:clear-message)) - (if-locked)) - ((eq? 'FAILED (imap-folder-cache-lock-state folder)) - (if if-not-locked (if-not-locked))) - ((= i 2) - (imail-ui:clear-message) - (set-imap-folder-cache-lock-state! folder 'FAILED) - (if if-not-locked (if-not-locked))) - (else - (imail-ui:message "Waiting for folder lock..." i) - (imail-ui:sit-for 1000) - (loop (+ i 1)))))) - (lambda () - (if (eq? 'LOCKED (imap-folder-cache-lock-state folder)) - (begin - (deallocate-temporary-file pathname) - (set-imap-folder-cache-lock-state! folder 'UNLOCKED)))))))) + folder if-not-locked + (if-locked)) (define (clear-lock-state-on-folder-close folder) - (set-imap-folder-cache-lock-state! folder 'UNKNOWN)) + folder + unspecific) (define (message-item-pathname message keyword) (init-file-specifier->pathname