Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

test if the connector has been .destroy()d in the reconnect callback …

…logic, fixes off and on again bug
  • Loading branch information...
commit 813c7defed8203439c0a2710caff023d7c2fdee7 1 parent f572a92
@substack authored
Showing with 11 additions and 1 deletion.
  1. +10 −0 index.js
  2. +1 −1  package.json
View
10 index.js
@@ -44,7 +44,9 @@ Airport.prototype.connect = function (role, fn) {
up.removeListener('down', ondown);
var s = pick(ps);
+ if (res) res.destroy();
res = connector(s, function f (s_) {
+ if (res) res.destroy();
res = connector(s_, f);
});
@@ -89,14 +91,17 @@ Airport.prototype.connect = function (role, fn) {
var pending = false;
c.on('reconnect', function () {
+ if (!active) return;
if (pending) return;
target.emit('reconnect');
ports.get(role, function (ps) {
+ if (!active) return;
pending = false;
var s = pick(ps);
if (s.port !== service.port || s.host !== service.host
|| s.secret !== service.secret) {
+ if (!active) return;
c.close();
cb(s);
}
@@ -104,6 +109,11 @@ Airport.prototype.connect = function (role, fn) {
pending = true;
});
+ var active = true;
+ c.destroy = function () {
+ active = false;
+ };
+
return c;
}
View
2  package.json
@@ -1,7 +1,7 @@
{
"name" : "airport",
"description" : "role-based port management for upnode",
- "version" : "0.3.6",
+ "version" : "0.3.7",
"repository" : {
"type" : "git",
"url" : "git://github.com/substack/airport.git"
Please sign in to comment.
Something went wrong with that request. Please try again.