emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sqlite3


From: Eli Zaretskii
Subject: Re: sqlite3
Date: Sun, 26 Dec 2021 16:42:52 +0200

> Date: Sun, 26 Dec 2021 14:55:20 +0200
> From: Eli Zaretskii <eliz@gnu.org>
> Cc: emacs-devel@gnu.org
> 
> So I think we should simply restructure the code, and let
> multisession--read-file-value do the test and the waiting, and
> multisession-backend-value should just return the cached value if
> multisession--read-file-value failed to read the file.

For example, with the simple changes below (which also make the sleep
between retries somewhat shorter), the test didn't fail even once in
20 runs:

diff --git a/lisp/emacs-lisp/multisession.el b/lisp/emacs-lisp/multisession.el
index c58a9ab..acd830f 100644
--- a/lisp/emacs-lisp/multisession.el
+++ b/lisp/emacs-lisp/multisession.el
@@ -275,7 +275,7 @@ multisession--read-file-value
           ((permission-denied file-missing)
            (setq i (1+ i)
                  last-error err)
-           (sleep-for (+ 0.1 (/ (float (random 10)) 10))))))
+           (sleep-for (+ 0.01 (* (float (random 10)) 0.01))))))
       (signal (car last-error) (cdr last-error)))))
 
 (defun multisession--object-file-name (object)
@@ -299,10 +299,16 @@ multisession-backend-value
      ;; We have a value, but we want to update in case some other
      ;; Emacs instance has updated.
      ((multisession--synchronized object)
-      (if (and (file-exists-p file)
-               (time-less-p (multisession--cached-sequence object)
-                            (file-attribute-modification-time
-                             (file-attributes file))))
+      ;; On MS-Windows/MS-DOS, we could have race conditions whereby
+      ;; the value file might not exist for short windows of
+      ;; opportunity.  So try reading the file on those systems if it
+      ;; doesn't exist or looks outdated, as our reading method can
+      ;; cope with some of those races.
+      (if (or (and (file-exists-p file)
+                   (time-less-p (multisession--cached-sequence object)
+                                (file-attribute-modification-time
+                                 (file-attributes file))))
+              (memq system-type '(windows-nt ms-dos)))
           (multisession--read-file-value file object)
         ;; Nothing, return the cached value.
         (multisession--cached-value object)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]