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:57:57 +0200

> Date: Sun, 26 Dec 2021 16:42:52 +0200
> From: Eli Zaretskii <eliz@gnu.org>
> Cc: emacs-devel@gnu.org
> 
> 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:

Actually, this slightly different version is better:

diff --git a/lisp/emacs-lisp/multisession.el b/lisp/emacs-lisp/multisession.el
index c58a9ab..2dcddc2 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,11 +299,19 @@ 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))))
-          (multisession--read-file-value file object)
+      ;; 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)))
+          (condition-case nil
+              (multisession--read-file-value file object)
+            (error (multisession--cached-value object)))
         ;; Nothing, return the cached value.
         (multisession--cached-value object)))
      ;; Just return the cached value.



reply via email to

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