Skip to content

Commit

Permalink
Merge pull request #13 from chopachom/master
Browse files Browse the repository at this point in the history
fix rotating file handler write lock
  • Loading branch information
seanmonstar committed Nov 4, 2013
2 parents 339ef0f + 63e0257 commit 58c16b8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/handlers/rotating.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ RotatingFileHandler.prototype._write = function write() {
if (this._buffer.length) {
var tuple = this._buffer.shift();
this._withSize(tuple[0], tuple[1]);
} else {
this._writing = false;
}
};

Expand Down
15 changes: 15 additions & 0 deletions test/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,21 @@ module.exports = {
assert.equal(fs.statSync(filename + '.2').size, 56);
assert(!fs.existsSync(filename + '.3'));
}).done(done);
},
'should continue to write after buffer is flushed': function(done) {
this.timeout(5000);

var filename = tmp();
var handler = new intel.handlers.Rotating({
file: filename,
maxSize: 64
});

handler.handle({ message: bytes(29) }).then(function(){
return handler.handle({ message: bytes(31) });
}).then(function(){
assert.equal(fs.statSync(filename).size, 62);
}).done(done);
}
}
}
Expand Down

0 comments on commit 58c16b8

Please sign in to comment.