emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[nongnu] elpa/inf-clojure e1a93c7 121/313: Add lock around REPL type det


From: ELPA Syncer
Subject: [nongnu] elpa/inf-clojure e1a93c7 121/313: Add lock around REPL type detection
Date: Wed, 11 Aug 2021 09:59:59 -0400 (EDT)

branch: elpa/inf-clojure
commit e1a93c73a24dd35914642725d351010a0909aa41
Author: Andrea Richiardi <a.richiardi.work@gmail.com>
Commit: Bozhidar Batsov <bozhidar.batsov@gmail.com>

    Add lock around REPL type detection
    
    The patch solves, maybe not in the best way, a couple of problems
    detected when emacs triggers multiple process output filters. See
    
http://blog.jorgenschaefer.de/2014/05/race-conditions-in-emacs-process-filter.html
---
 inf-clojure.el | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/inf-clojure.el b/inf-clojure.el
index fe6aa7d..c8aa815 100644
--- a/inf-clojure.el
+++ b/inf-clojure.el
@@ -195,17 +195,23 @@ often connecting to a remote REPL process."
 Its root binding is nil and it can be further customized using
 either `setq-local` or an entry in `.dir-locals.el`." )
 
-(defun inf-clojure--detect-type (proc)
+(defvar inf-clojure--repl-type-lock nil
+  "Global lock for protecting against proc filter race conditions.
+See 
http://blog.jorgenschaefer.de/2014/05/race-conditions-in-emacs-process-filter.html";)
+
+(defun inf-clojure--detect-repl-type (proc)
   "Identifies the current REPL type for PROC."
-  (cond
-   ((inf-clojure--lumo-p proc) 'lumo)
-   (t 'clojure)))
+  (when (not inf-clojure--repl-type-lock)
+    (let ((inf-clojure--repl-type-lock t))
+      (cond
+       ((inf-clojure--lumo-p proc) 'lumo)
+       (t 'clojure)))))
 
 (defun inf-clojure--set-repl-type (proc)
   "Set the REPL type if has not already been set.
 It requires a REPL PROC for inspecting the correct type."
   (if (not inf-clojure-repl-type)
-      (setq inf-clojure-repl-type (inf-clojure--detect-type proc))
+      (setq inf-clojure-repl-type (inf-clojure--detect-repl-type proc))
     inf-clojure-repl-type))
 
 (defun inf-clojure--send-string (proc string)



reply via email to

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