This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

fixed produce stall when messages are written while no partitions are…

… ready
  • Loading branch information...
dannycoates committed Nov 18, 2012
1 parent e8bd7d1 commit 5726b0d1ca7618e752ee7c06cdec7c2fc9b94ea3
Showing with 4 additions and 4 deletions.
  1. +4 −4 message-buffer.js
View
@@ -14,8 +14,7 @@ module.exports = function (
}
inherits(MessageBuffer, EventEmitter)
- MessageBuffer.prototype.reset = function () {
- this.messages = []
+ MessageBuffer.prototype.clearTimer = function () {
clearTimeout(this.timer)
this.timer = null
}
@@ -59,14 +58,15 @@ module.exports = function (
function send() {
var sent = false
- if (this.partitions.isReady()) {
+ if (this.partitions.isReady() && this.messages.length > 0) {
var batches = batchify(this.messages, this.batchSize)
for (var i = 0; i < batches.length; i++) {
var partition = this.partitions.nextWritable()
sent = partition.write(batches[i], this.onProduceResponse)
}
- this.reset()
+ this.messages = []
}
+ this.clearTimer()
return sent
}

0 comments on commit 5726b0d

Please sign in to comment.