From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: sqlite3 Date: Sun, 26 Dec 2021 16:42:52 +0200 Message-ID: <83ilvbo2ab.fsf@gnu.org> References: <87tufmjyai.fsf@gnus.org> <83o85feitv.fsf@gnu.org> <87lf0jzifm.fsf@gnus.org> <83a6gze705.fsf@gnu.org> <87k0g2xsu9.fsf@gnus.org> <871r2axqp4.fsf@gnus.org> <83sfuqb5yo.fsf@gnu.org> <87fsqoyiao.fsf@gnus.org> <83v8zk96yh.fsf@gnu.org> <87zgowvmt5.fsf@gnus.org> <838rwg8z8i.fsf@gnu.org> <871r28vg4y.fsf@gnus.org> <834k748wez.fsf@gnu.org> <831r288vne.fsf@gnu.org> <83zgow7fpi.fsf@gnu.org> <83y24g7dui.fsf@gnu.org> <8735mnr5cb.fsf@gnus.org> <83bl19zwwy.fsf@gnu.org> <87bl18g7r3.fsf@gnus.org> <83ee64ych1.fsf@gnu.org> <83o853pydo.fsf@gnu.org> <875yrbzjc5.fsf@gnus.org> <8335mfpox7.fsf@gnu.org> <83pmpjo79j.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29459"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: larsi@gnus.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Dec 26 15:43:53 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n1Ukb-0007X1-2m for ged-emacs-devel@m.gmane-mx.org; Sun, 26 Dec 2021 15:43:53 +0100 Original-Received: from localhost ([::1]:44768 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n1UkY-0003Ha-Vy for ged-emacs-devel@m.gmane-mx.org; Sun, 26 Dec 2021 09:43:51 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:49868) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n1UjP-0002Kb-SF for emacs-devel@gnu.org; Sun, 26 Dec 2021 09:42:39 -0500 Original-Received: from [2001:470:142:3::e] (port=55288 helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n1UjO-0000RO-U1; Sun, 26 Dec 2021 09:42:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=CFvDy6jtjr8BSoXAmEpz3KVzlk+ZwMop9StBJvlaCbs=; b=Umy3CCgfxPXa xhOUEK6H9aC12nz+Op0Hp95f06AY3mWHezVf56X7309e8PD/GtwRXj3nAUiZ/zxsqftemShhmuPxv 8jw+iLbyqOGhy9dOyynTB7D0WfxgSiZozj8XiEEvyWSaJVvuYjfFGEJQs1J4GSUkU+p11+5VTiEsr wXQN9tOmnotEMu25i9E6JFBC9iYIu+wGWJicX33x9Pgo/uUBlhneTvmSVhkxD9SWVNH0I/a8xET3M syx9zkwYE3ShITAGIVFlbZIr551eK4MPsY5aReHYHx0EbP7S7CQUxkn3r3d9GovGTDC2QvIBW76VO 9zNnJDCelDH/klLScaQKcA==; Original-Received: from [87.69.77.57] (port=4741 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n1UjO-0006uK-Rx; Sun, 26 Dec 2021 09:42:39 -0500 In-Reply-To: <83pmpjo79j.fsf@gnu.org> (message from Eli Zaretskii on Sun, 26 Dec 2021 14:55:20 +0200) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:283330 Archived-At: > Date: Sun, 26 Dec 2021 14:55:20 +0200 > From: Eli Zaretskii > 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)))