Skip to content

Commit

Permalink
handle end of stream better
Browse files Browse the repository at this point in the history
  • Loading branch information
joeferner committed Feb 27, 2013
1 parent 918bb86 commit 91b9578
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/pcapConverter.js
Expand Up @@ -173,9 +173,12 @@ PcapConverter.prototype.convertStream = function(inputStream) {
}
return;
}
var timePassed = new Date() - tempFile.createdOn;
var timePassed = Date.now() - tempFile.createdOn;

if ((timePassed >= 5000 && tempFile.packetCount > 0) || tempFile.packetCount >= 1000 || (tempFile.packetCount > 0 && parseOnEndOccured)) {
if (
(timePassed >= 5000 && tempFile.packetCount > 0)
|| tempFile.packetCount >= 1000
|| (tempFile.packetCount > 0 && parseOnEndOccured && packetQueue.length() == 0)) {
var oldTempFile = tempFile;
tempFile = null;
return fs.close(oldTempFile.fd, function(err) {
Expand Down

0 comments on commit 91b9578

Please sign in to comment.