Skip to content

Commit

Permalink
Merge commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
satyamshekhar committed Apr 20, 2012
2 parents 2e7780c + b1b5c4d commit 0cd54d0
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 18 deletions.
1 change: 1 addition & 0 deletions src/helper.js
Expand Up @@ -142,6 +142,7 @@ function save_terminate_condition_for_wait_time(obj, attr, condition, wait) {
timer: setTimeout(function () {
if (obj.hasOwnProperty(attr)) {
delete obj[attr];
clearTimeout(obj[attr].timer);
}
}, (wait + 5) * 1000)
};
Expand Down
17 changes: 8 additions & 9 deletions src/session.js
Expand Up @@ -288,6 +288,7 @@ Session.prototype = {
// Check if this is a new stream start packet (multiple streams)
log.trace("%s: Stream Add", this.sid);
if (this.is_max_streams_violation(node)) {
log.info("%s %s max stream violation - will terminate", this.sid, stream_log_name);
// Make this a session terminate request.
node.attrs.type = 'terminate';
node.attrs.condition = 'policy-violation';
Expand All @@ -299,7 +300,7 @@ Session.prototype = {

// Check for stream terminate
if (helper.is_stream_terminate_request(node)) {
log.trace("%s Stream Terminate", this.sid);
log.info("%s Stream Terminate Request", this.sid);
// We may be required to terminate one stream, or all
// the open streams on this BOSH session.
this.handle_client_stream_terminate_request(stream, nodes,
Expand Down Expand Up @@ -408,7 +409,7 @@ Session.prototype = {
// Process pending (queued) responses (if any)
// this.send_pending_responses();
} else {
log.trace("%s broken-request - no-need-to-process - session.rid: %s", this.sid, this.rid);
log.info("%s broken-request - no-need-to-process - session.rid: %s", this.sid, this.rid);
should_process = false;
}
if (this.queued_requests.hasOwnProperty(node.attrs.rid)) {
Expand Down Expand Up @@ -444,6 +445,7 @@ Session.prototype = {
// because of the rule below.
if (this.res.length > this._options.MAX_BOSH_CONNECTIONS) {
// Just send the termination message and destroy the socket.
log.info("%s will terminate due to MAX_BOSH_CONNECTION exceeded", this.sid);

This comment has been minimized.

Copy link
@dhruvbird

dhruvbird Apr 20, 2012

Collaborator

MAX_BOSH_CONNECTION -> MAX_BOSH_CONNECTIONS ;)

This comment has been minimized.

Copy link
@satyamshekhar

satyamshekhar Apr 21, 2012

Author Collaborator

:P.. fixed

var condition = 'policy-violation';
this.send_terminate_response(ro, condition);

Expand Down Expand Up @@ -484,7 +486,7 @@ Session.prototype = {
// all open streams (on the XMPP server side)
terminate: function (condition) {
if (this.streams.length !== 0) {
log.trace("%s terminate - Terminating potentially non-empty BOSH session", this.sid);
log.warn("%s terminate - Terminating potentially non-empty BOSH session", this.sid);
}

// Clear out this.streams to aid GC
Expand Down Expand Up @@ -524,7 +526,7 @@ Session.prototype = {

var self = this;
this.timeout = setTimeout(function () {
log.trace("%s terminating Session due to inactivity", self.sid);
log.info("%s terminating Session due to inactivity", self.sid);
// Raise a no-client event on pending, unstitched as well as unacked
// responses.
var _p = us.pluck(self.pending_stitched_responses, 'response');
Expand Down Expand Up @@ -556,7 +558,7 @@ Session.prototype = {
// These functions actually send responses to the client

send_invalid_packet_terminate_response: function (res, node) {
log.trace("%s send_invalid_packet_terminate_response", this.sid);
log.info("%s send_invalid_packet_terminate_response -- will terminate", this.sid);
var attrs = {
condition : 'item-not-found',
message : 'Invalid packet'
Expand All @@ -581,7 +583,7 @@ Session.prototype = {
// send to the client as to why the session was closed.
//
send_terminate_response: function (ro, condition) {
log.trace("%s send_terminate_response - ro: %s, condition: %s", this.sid, !!ro, condition || "no-condition");
log.info("%s send_terminate_response - ro: %s, condition: %s", this.sid, !!ro, condition || "no-condition");
var attrs = { };
if (condition) {
attrs.condition = condition;
Expand Down Expand Up @@ -794,9 +796,6 @@ Session.prototype = {
// that the client will request the missing
// RID.
this._send_no_requeue(ro, response);

// We try sending more queued responses
this.send_pending_responses();
} else {
log.trace("%s send_pending_responses - nothing to send, 0 pending - return", this.sid);
break;
Expand Down
3 changes: 2 additions & 1 deletion src/stream-parser.js
Expand Up @@ -33,7 +33,8 @@ function XmppStreamParser() {
events.EventEmitter.apply(this);

this.__defineGetter__("getCurrentByteIndex", function () {
return this._parser.getCurrentByteIndex();
if (!this._parser) return 0;
else return this._parser.getCurrentByteIndex();
});

this._start();
Expand Down
4 changes: 2 additions & 2 deletions src/xmpp-proxy-connector.js
Expand Up @@ -59,7 +59,7 @@ function XMPPProxyConnector(bosh_server, options) {

// Fired when an 'close' event is raised by the XMPP Proxy.
this._on_xmpp_proxy_close = function(error, stream) {
log.trace("%s %s _on_xmpp_proxy_close - terminate stream", stream.session.sid, stream.name);
log.info("%s %s _on_xmpp_proxy_close - terminate stream", stream.session.sid, stream.name);
// Remove the object and notify the bosh server.
var ss = this.streams[stream.name];
if (!ss) {
Expand Down Expand Up @@ -191,7 +191,7 @@ XMPPProxyConnector.prototype = {
return;
}

log.trace("%s %s stream_terminate", stream.session.sid, stream.name);
log.info("%s %s stream_terminate", stream.session.sid, stream.name);
ss.proxy.terminate();
delete this.streams[stream.name];
}
Expand Down
12 changes: 6 additions & 6 deletions src/xmpp-proxy.js
Expand Up @@ -222,7 +222,7 @@ dutil.copy(XMPPProxy.prototype, {

terminate: function() {
if (this._is_connected) {
log.trace("%s %s - terminating", this._void_star.session.sid, this._void_star.name);
log.info("%s %s - terminating", this._void_star.session.sid, this._void_star.name);
// Detach the 'data' handler so that we don't get any more events.
this._sock.removeAllListeners('data');
this._parser.end();
Expand All @@ -241,7 +241,7 @@ dutil.copy(XMPPProxy.prototype, {
this._sock.end();
}
else {
log.trace("%s %s terminate - will terminate on connect", this._void_star.session.sid, this._void_star.name);
log.info("%s %s terminate - will terminate on connect", this._void_star.session.sid, this._void_star.name);
this._terminate_on_connect = true;
}
},
Expand Down Expand Up @@ -310,7 +310,7 @@ dutil.copy(XMPPProxy.prototype, {
},

_on_stream_end: function(attr) {
log.trace("%s %s _on_stream_end: stream terminated", this._void_star.session.sid, this._void_star.name);
log.info("%s %s _on_stream_end: stream terminated", this._void_star.session.sid, this._void_star.name);
this.terminate();
},

Expand All @@ -320,18 +320,18 @@ dutil.copy(XMPPProxy.prototype, {
},

_close_connection: function(error) {
log.trace("%s %s _close_connection error: %s", this._void_star.session.sid, this._void_star.name, error);
log.info("%s %s _close_connection error: %s", this._void_star.session.sid, this._void_star.name, error);
this.emit('close', error, this._void_star);
},

_on_close: function(had_error) {
had_error = had_error || false;
log.trace("%s %s _on_close error: %s", this._void_star.session.sid, this._void_star.name, !!had_error);
log.info("%s %s _on_close error: %s", this._void_star.session.sid, this._void_star.name, !!had_error);
this._close_connection(had_error ? 'remote-connection-failed' : null);
},

_on_lookup_error: function(error) {
log.warn("%s %s _on_lookup_error - %s", this._void_star.session.sid, this._void_star.name, error);
log.info("%s %s _on_lookup_error - %s", this._void_star.session.sid, this._void_star.name, error);
this._close_connection(error);
}
});

0 comments on commit 0cd54d0

Please sign in to comment.