mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Fix safe-pathwatcher memory leak
This commit is contained in:
@@ -64,7 +64,10 @@ exports.testDirectory = function (dir) {
|
||||
|
||||
try {
|
||||
// Watch the candidate directory using pathwatcher.watch.
|
||||
var watcher = files.pathwatcherWatch(dir, cleanUp);
|
||||
var watcher = files.pathwatcherWatch(dir, function () {
|
||||
cleanUp();
|
||||
switchFunctions = null;
|
||||
});
|
||||
|
||||
} catch (err) {
|
||||
// If the directory did not exist, do not treat this failure as
|
||||
@@ -110,17 +113,19 @@ exports.watch = function (absPath, callback) {
|
||||
var closed = false;
|
||||
var switched = false;
|
||||
|
||||
switchFunctions.push(function switchToPolling() {
|
||||
if (! switched && ! closed) {
|
||||
switched = true;
|
||||
watcher.close();
|
||||
if (switchFunctions) {
|
||||
switchFunctions.push(function switchToPolling() {
|
||||
if (! switched && ! closed) {
|
||||
switched = true;
|
||||
watcher.close();
|
||||
|
||||
// Re-watch the file using files.watchFile instead.
|
||||
files.watchFile(absPath, {
|
||||
interval: pollingInterval
|
||||
}, callback);
|
||||
}
|
||||
});
|
||||
// Re-watch the file using files.watchFile instead.
|
||||
files.watchFile(absPath, {
|
||||
interval: pollingInterval
|
||||
}, callback);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
close: function close() {
|
||||
|
||||
Reference in New Issue
Block a user