Add a close method on DDP client connections.

It's implemented by the forceDisconnect method on streams. Fix forceDisconnect
on Node streams when forceDisconnect is called during the initial connection.
This commit is contained in:
David Glasser
2013-04-30 19:44:20 -07:00
parent 91f5d3c132
commit 8ec4e07961
4 changed files with 17 additions and 11 deletions

View File

@@ -802,6 +802,11 @@ _.extend(Meteor._LivedataConnection.prototype, {
return self._stream.reconnect.apply(self._stream, arguments);
},
close: function () {
var self = this;
return self._stream.forceDisconnect();
},
///
/// Reactive user system
///

View File

@@ -62,6 +62,13 @@ _.extend(Meteor._DdpClientStream.prototype, {
_onConnect: function (connection) {
var self = this;
if (self._forcedToDisconnect) {
// We were asked to disconnect between trying to open the connection and
// actually opening it. Let's just pretend this never happened.
connection.close();
return;
}
if (self.currentStatus.connected) {
// We already have a connection. It must have been the case that
// we started two parallel connection attempts (because we

View File

@@ -11,7 +11,7 @@ var getMeteor = function (context) {
_meteor = unipackage.load({
library: context.library,
packages: [ 'livedata' ],
release: context.releaseVersion,
release: context.releaseVersion
}).meteor.Meteor;
}
@@ -45,7 +45,7 @@ var exitWithError = function (error, messages) {
if (msg)
process.stderr.write(msg + "\n");
else if (error instanceof Meteor.Error)
process.stderr.write("Denied: " + error.message + "\n")
process.stderr.write("Denied: " + error.message + "\n");
process.exit(1);
};
@@ -86,7 +86,7 @@ exports.deploy = function (options) {
options.bundleOptions);
if (bundleResult.errors) {
process.stdout.write("\n\nErrors prevented deploying:\n");
process.stdout.write(bundleresult.errors.formatMessages());
process.stdout.write(bundleResult.errors.formatMessages());
process.exit(1);
}
@@ -158,4 +158,6 @@ exports.deploy = function (options) {
process.stderr.write(options.service + ": " +
"pushed revision " + result.serial + "\n");
// Close the connection to Galaxy (otherwise Node will continue running).
galaxy.close();
};

View File

@@ -818,14 +818,6 @@ Fiber(function () {
});
}
}
if (useGalaxy) {
// XXX Under certain circumstances (not yet clear), the websocket
// client in the 'websocket' package will block natural program
// exit even if all of its connections have been closed. So just
// go ahead and explicitly exit the process.
process.exit(0);
}
}
});