Skip to content

Commit

Permalink
performance improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
grs committed Jan 20, 2017
1 parent 5b97ff1 commit 7b65737
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 131 deletions.
6 changes: 6 additions & 0 deletions lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ Connection.prototype.accept = function (socket) {

Connection.prototype.init = function (socket) {
this.socket = socket;
if (this.get_option('tcp_no_delay', false) && this.socket.setNoDelay) {
this.socket.setNoDelay(true);
}
this.socket.on('data', this.input.bind(this));
this.socket.on('error', this.on_error.bind(this));
this.socket.on('end', this.eof.bind(this));
Expand Down Expand Up @@ -297,6 +300,9 @@ Connection.prototype.attach_sender = function (options) {
Connection.prototype.open_sender = Connection.prototype.attach_sender;//alias

Connection.prototype.attach_receiver = function (options) {
if (this.get_option('tcp_no_delay', true) && this.socket.setNoDelay) {
this.socket.setNoDelay(true);
}
return this.session_policy.get_session().attach_receiver(options);
};
Connection.prototype.open_receiver = Connection.prototype.attach_receiver;//alias
Expand Down
2 changes: 1 addition & 1 deletion lib/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ Sender.prototype.send = function (msg, tag) {
var Receiver = function (session, name, local_handle, opts) {
this.init(session, name, local_handle, opts, true);
this.drain = false;
this.set_credit_window(this.get_option('credit_window', 1000));
this.set_credit_window(this.get_option('credit_window', 100));
if (this.get_option('autoaccept', true)) {
this.observers.on('message', auto_accept);
}
Expand Down
5 changes: 0 additions & 5 deletions lib/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,6 @@ message.decode = function(buffer) {
console.warn('WARNING: expected described message section got ' + JSON.stringify(s));
}
}
if (msg.application_properties) {
for (var key in msg.application_properties) {
add_property_shortcut(msg, 'application_properties', key);
}
}
return msg;
};

Expand Down
2 changes: 1 addition & 1 deletion lib/transport.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Transport.prototype.read = function (buffer) {
offset = 8;
}
}
while (offset < buffer.length && !this.read_complete) {
while (offset < (buffer.length - 4) && !this.read_complete) {
var frame_size = buffer.readUInt32BE(offset);
log.io('[%s] got frame of size %d', this.identifier, frame_size);
if (buffer.length < offset + frame_size) {
Expand Down
Loading

0 comments on commit 7b65737

Please sign in to comment.