Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixing continued packet error in the packetHandler, also cleaning the…

… code out a bit
  • Loading branch information...
commit af2183d8534c4b06b9b6359a24128dcb5bea455b 1 parent a08f292
@miksago authored
Showing with 11 additions and 11 deletions.
  1. +11 −11 lib/smtp/packetHandler.js
View
22 lib/smtp/packetHandler.js
@@ -27,25 +27,24 @@ exports.PacketHandler.prototype.push = function(data){
var packets = data.split("\r\n");
while(packets.length && (packet = packets.shift())){
this._stack.push(packet);
- if( !this._processing ){
- this._processor();
- }
+ }
+
+ if( !this._processing ){
+ this._processor();
}
};
exports.PacketHandler.prototype.process = function(){
var status = 0, data = [], continued = false;
- while(this._stack.length && (packet = this._stack.shift())){
- if(continued == false){
- // not a number, strings are easier to work with as status codes.
- status = packet.substr(0,3);
+ for(var continued = false; this._stack.length && (packet = this._stack.shift());){
+ if( !continued ){
+ status = packet.substr(0,3); // not a number, strings are easier to work with as status codes.
}
data.push(packet.substr(4));
- continued = (packet.substr(3,1) == "-");
- if( !continued){
+ if( ! (continued = (/[0-9]{3}\-/i.test(packet))) ){
break;
}
}
@@ -54,8 +53,9 @@ exports.PacketHandler.prototype.process = function(){
status: status,
data: data
});
-
+
if(this._stack.length == 0){
- this.emit("idle");
+ this.emit("drain");
}
+
};
Please sign in to comment.
Something went wrong with that request. Please try again.