[Pkg-javascript-commits] [ltx] 128/469: fixes to stream management

Jonas Smedegaard dr at jones.dk
Wed Aug 31 13:01:13 UTC 2016


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

js pushed a commit to branch master
in repository ltx.

commit 983e27df647e49aa957bcfcfed61832ba83e9a01
Author: Astro <astro at spaceboyz.net>
Date:   Thu Sep 9 19:11:57 2010 +0200

    fixes to stream management
---
 lib/xmpp/connection.js | 3 ---
 lib/xmpp/router.js     | 6 ++++--
 lib/xmpp/server.js     | 1 +
 lib/xmpp/srv.js        | 6 +++---
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/lib/xmpp/connection.js b/lib/xmpp/connection.js
index 121c78e..ebe5acb 100644
--- a/lib/xmpp/connection.js
+++ b/lib/xmpp/connection.js
@@ -120,13 +120,10 @@ Connection.prototype.startStream = function() {
     // make it non-empty to cut the closing tag
     el.t(' ');
     var s = el.toString();
-    console.log({startStream:s.substr(0, s.indexOf(' </stream:stream>'))});
-
     this.send(s.substr(0, s.indexOf(' </stream:stream>')));
 };
 
 Connection.prototype.onData = function(data) {
-    console.log({data:data.toString()});
     if (this.parser)
 	this.parser.write(data);
 };
diff --git a/lib/xmpp/router.js b/lib/xmpp/router.js
index f4a4737..4635ff2 100644
--- a/lib/xmpp/router.js
+++ b/lib/xmpp/router.js
@@ -120,7 +120,7 @@ DomainContext.prototype.getOutStream = function(destDomain) {
 	this.router.setupStream(outStream);
 	this.setupStream(destDomain, outStream);
 
-	outStream.addListener('close', function() {
+	var closeCb = function() {
 	    // purge queue
 	    if (outStream.queue) {
 		outStream.queue.forEach(function(stanza) {
@@ -141,7 +141,9 @@ DomainContext.prototype.getOutStream = function(destDomain) {
 
 	    // remove from DomainContext
 	    delete self.s2sOut[destDomain];
-	});
+	};
+	outStream.addListener('close', closeCb);
+	outStream.addListener('error', closeCb);
 
 	var onAuth =  function(method) {
 	    console.log({auth:method});
diff --git a/lib/xmpp/server.js b/lib/xmpp/server.js
index cfe1156..a78c7b8 100644
--- a/lib/xmpp/server.js
+++ b/lib/xmpp/server.js
@@ -175,6 +175,7 @@ console.log({outCreds:self.credentials});
 	self.startStream();
     });
     attempt.addListener('error', function(e) {
+	console.log({attemptError:e});
 	self.emit('error', e);
     });
 };
diff --git a/lib/xmpp/srv.js b/lib/xmpp/srv.js
index 623df0c..6c8872e 100644
--- a/lib/xmpp/srv.js
+++ b/lib/xmpp/srv.js
@@ -85,7 +85,7 @@ console.log({resolveHost:[name,e,addrs]});
 
 	pending--;
 	if (pending < 1)
-	    cb(results ? null : error, results);
+	    cb((results.length > 0) ? null : error, results);
     };
 
     dns.resolve4(name, cb1);
@@ -133,14 +133,14 @@ exports.connect = function(socket, services, domain, defaultPort) {
 	    });
 	} else {
 	    resolveHost(domain, function(error, addrs) {
-		if (addrs) {
+		if (addrs && addrs.length > 0) {
 		    addrs = addrs.map(function(addr) {
 			return { name: addr,
 				 port: defaultPort };
 		    });
 		    tryConnect(socket, addrs, listener);
 		} else
-		    listener('error', error);
+		    listener.emit('error', error);
 	    });
 	}
 

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



More information about the Pkg-javascript-commits mailing list