Skip to content

Commit

Permalink
fix(canSend): move state check to canSend based on review
Browse files Browse the repository at this point in the history
  • Loading branch information
mbroadst committed Aug 3, 2015
1 parent c66b0f0 commit 06e0edc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/sender_link.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ SenderLink.prototype.attach = function() {
};

SenderLink.prototype.canSend = function() {
var sendable = (this.linkCredit >= 1 && (!this.session.policy.enableSessionFlowControl || this.session._sessionParams.remoteIncomingWindow >= 1));
if (this.state() !== 'attached') {
return false;
}

var sendable = this.linkCredit >= 1 &&
(!this.session.policy.enableSessionFlowControl || this.session._sessionParams.remoteIncomingWindow >= 1);
debug('canSend(' + this.linkCredit + ',' + this.session._sessionParams.remoteIncomingWindow + ') = ' + sendable);
return sendable;
};
Expand Down Expand Up @@ -89,7 +94,7 @@ SenderLink.prototype.send = function(msg, options) {
}
};

if (self.state() !== 'attached' || !self.canSend()) {
if (!self.canSend()) {
self._pendingSends.push(sendMessage);
return;
}
Expand Down

0 comments on commit 06e0edc

Please sign in to comment.