[Pkg-javascript-commits] [less.js] 18/25: Found race condition that caused file not to be skipped in importOnce, leading to random exceptions. Fixes #1931

Jonas Smedegaard dr at jones.dk
Mon Oct 26 23:23:00 UTC 2015


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag v1.7.4
in repository less.js.

commit d750151536c5f2ae47b0f4e45c41d5d79a407a07
Author: Luke Page <luke.a.page at gmail.com>
Date:   Sun Jul 27 16:09:17 2014 +0100

    Found race condition that caused file not to be skipped in importOnce, leading to random exceptions. Fixes #1931
---
 lib/less/import-visitor.js | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/lib/less/import-visitor.js b/lib/less/import-visitor.js
index 7d69337..b853b56 100644
--- a/lib/less/import-visitor.js
+++ b/lib/less/import-visitor.js
@@ -38,7 +38,7 @@
             var importVisitor = this,
                 evaldImportNode,
                 inlineCSS = importNode.options.inline;
-            
+
             if (!importNode.css || inlineCSS) {
 
                 try {
@@ -61,10 +61,13 @@
                     }
 
                     this._importer.push(importNode.getPath(), importNode.currentFileInfo, importNode.options, function (e, root, importedAtRoot, fullPath) {
-                        if (e && !e.filename) { e.index = importNode.index; e.filename = importNode.currentFileInfo.filename; }
+                        if (e && !e.filename) {
+                            e.index = importNode.index; e.filename = importNode.currentFileInfo.filename;
+                        }
 
-                        if (!env.importMultiple) { 
-                            if (importedAtRoot) {
+                        var duplicateImport = importedAtRoot || fullPath in importVisitor.recursionDetector;
+                        if (!env.importMultiple) {
+                            if (duplicateImport) {
                                 importNode.skip = true;
                             } else {
                                 importNode.skip = function() {
@@ -73,7 +76,7 @@
                                     }
                                     importVisitor.onceFileDetectionMap[fullPath] = true;
                                     return false;
-                                }; 
+                                };
                             }
                         }
 
@@ -88,7 +91,6 @@
                         if (root) {
                             importNode.root = root;
                             importNode.importedFilename = fullPath;
-                            var duplicateImport = importedAtRoot || fullPath in importVisitor.recursionDetector;
 
                             if (!inlineCSS && (env.importMultiple || !duplicateImport)) {
                                 importVisitor.recursionDetector[fullPath] = true;
@@ -139,4 +141,4 @@
         }
     };
 
-})(require('./tree'));
\ No newline at end of file
+})(require('./tree'));

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/less.js.git



More information about the Pkg-javascript-commits mailing list