Remove logic to lock IMAIL's IMAP folder cache.
authorTaylor R Campbell <campbell@mumble.net>
Sat, 10 Aug 2013 21:11:17 +0000 (21:11 +0000)
committerTaylor R Campbell <campbell@mumble.net>
Sat, 10 Aug 2013 21:11:19 +0000 (21:11 +0000)
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.

src/imail/imail-imap.scm

index 01afc12f9b1e64751d4a0f98caf0cf220f336095..b5a092f24657625c8573bed328e3a5b6f726fba1 100644 (file)
@@ -795,8 +795,6 @@ USA.
 (define-class <imap-folder> (<folder>)
   (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)
 \f
 (define (message-item-pathname message keyword)
   (init-file-specifier->pathname