From 38fac42a0d75ca83869a78d0368f4a2804a93f47 Mon Sep 17 00:00:00 2001 From: nightwing Date: Fri, 27 Feb 2015 18:43:20 +0400 Subject: [PATCH 1/4] revert watcher changes causing memory leak --- node_modules/vfs-local/localfs.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/node_modules/vfs-local/localfs.js b/node_modules/vfs-local/localfs.js index f5262624..cfbd0aac 100644 --- a/node_modules/vfs-local/localfs.js +++ b/node_modules/vfs-local/localfs.js @@ -1380,23 +1380,21 @@ module.exports = function setup(fsOptions) { }); callback(done); - function loop(watchers, path, event, callback) { + function done(callback) { if (!watchers.length) return callback(); - + + // Notify each watcher of changes and reactivate it var watcher = watchers.pop(); - watcher.handleWatchEvent(event, basename(path), true); - + fs.stat(path, function(err, stat) { + if (err || !stat) return; + stat.vfsWrite = true; + watcher.sendToAllListeners("change", basename(path), stat); + }); watcher.resume(function() { - loop(watchers, path, event, callback); + done(callback); }); } - - function done(callback) { - loop(watchers, path, "change", function() { - loop(dirWatchers, parentDir, "directory", callback); - }); - } } function connect(port, options, callback) { From aa36c77facc3ca0d1068b2d6d5cd24a3421f73ce Mon Sep 17 00:00:00 2001 From: nightwing Date: Fri, 27 Feb 2015 18:59:35 +0400 Subject: [PATCH 2/4] do not report false error when saving empty document --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 27aea251..a2a73b1d 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "c9.ide.language.javascript.tern": "#a65ad88dd9", "c9.ide.language.javascript.infer": "#ebb2daf81a", "c9.ide.language.jsonalyzer": "#5262f6b4b9", - "c9.ide.collab": "#51b8b72e0f", + "c9.ide.collab": "#7bcd5ef65f", "c9.ide.local": "#2bfd7ff051", "c9.ide.find": "#989c06e6a7", "c9.ide.find.infiles": "#28b3cfcb47", From 6f197414c325d88013b948d529993e211c54002a Mon Sep 17 00:00:00 2001 From: Lennart Kats Date: Sat, 28 Feb 2015 10:18:45 +0100 Subject: [PATCH 3/4] Add server-side latency (vfs -> docker host) --- node_modules/vfs-socket/worker.js | 20 ++++++++++++++++++++ plugins/c9.vfs.client/vfs.ping.js | 7 +++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/node_modules/vfs-socket/worker.js b/node_modules/vfs-socket/worker.js index 0fc07f34..03ac51c8 100644 --- a/node_modules/vfs-socket/worker.js +++ b/node_modules/vfs-socket/worker.js @@ -322,10 +322,30 @@ function Worker(vfs) { delete watchers[id]; watcher.close(); } + + /** + * Add additional timing info to any "ping" call. + */ + function wrapPingCall(name, fnName, args) { + if (name === "ping" && fnName === "ping" && args.length === 2) { + var start = Date.now(); + var cb = args[1]; + + args[1] = function(err, payload) { + if (err) return cb(err); + cb(null, { + payload: payload, + serverTime: Date.now() - start + }); + }; + } + } function call(name, fnName, args) { var api = apis[name]; if (!api) return; + + wrapPingCall(name, fnName, args); // If the last arg is a function, assume it's a callback and process it. if (typeof args[args.length - 1] == "function") { diff --git a/plugins/c9.vfs.client/vfs.ping.js b/plugins/c9.vfs.client/vfs.ping.js index 8128bfeb..9cd41afb 100644 --- a/plugins/c9.vfs.client/vfs.ping.js +++ b/plugins/c9.vfs.client/vfs.ping.js @@ -60,11 +60,14 @@ define(function(require, exports, module) { if (!api) return callback(new Error("Client is offline")); var start = Date.now(); - api.ping("ping", function(err) { + api.ping("ping", function(err, response) { var took = Date.now() - start; if (err) return callback(err); - callback(null, took); + callback(null, { + serverTime: response.serverTime, + total: took + }); }); } From c7ec9d7b4f84d0e666b67c2fd75386a0f732798e Mon Sep 17 00:00:00 2001 From: Lennart Kats Date: Sat, 28 Feb 2015 15:03:57 +0100 Subject: [PATCH 4/4] Make new serverPing logic backward & forward compatible --- node_modules/vfs-socket/worker.js | 2 +- plugins/c9.vfs.client/ping-service.js | 1 + plugins/c9.vfs.client/vfs.ping.js | 5 ++--- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/node_modules/vfs-socket/worker.js b/node_modules/vfs-socket/worker.js index 03ac51c8..bf1ad040 100644 --- a/node_modules/vfs-socket/worker.js +++ b/node_modules/vfs-socket/worker.js @@ -327,7 +327,7 @@ function Worker(vfs) { * Add additional timing info to any "ping" call. */ function wrapPingCall(name, fnName, args) { - if (name === "ping" && fnName === "ping" && args.length === 2) { + if (name === "ping" && fnName === "ping" && args[0] === "serverTime" && args.length === 2) { var start = Date.now(); var cb = args[1]; diff --git a/plugins/c9.vfs.client/ping-service.js b/plugins/c9.vfs.client/ping-service.js index 52fb886a..fb9a5210 100644 --- a/plugins/c9.vfs.client/ping-service.js +++ b/plugins/c9.vfs.client/ping-service.js @@ -1,6 +1,7 @@ module.exports = function(vfs, options, register) { register(null, { ping: function (payload, callback) { + // We simply return the payload, while vfs-socket adds a time stamp callback(null, payload); } }); diff --git a/plugins/c9.vfs.client/vfs.ping.js b/plugins/c9.vfs.client/vfs.ping.js index 9cd41afb..13ae4c44 100644 --- a/plugins/c9.vfs.client/vfs.ping.js +++ b/plugins/c9.vfs.client/vfs.ping.js @@ -60,13 +60,12 @@ define(function(require, exports, module) { if (!api) return callback(new Error("Client is offline")); var start = Date.now(); - api.ping("ping", function(err, response) { - var took = Date.now() - start; + api.ping("serverTime", function(err, response) { if (err) return callback(err); callback(null, { serverTime: response.serverTime, - total: took + total: Date.now() - start }); }); }