Permalink
Browse files

Remove debugging logs; add mailbox dependency; handle early-closed so…

…ckets
  • Loading branch information...
1 parent 276e8ad commit 88e9a1c0857da75e10dd2ad270e49f73cf86e225 @aredridel committed Jun 13, 2011
Showing with 11 additions and 8 deletions.
  1. +10 −8 lib/smtp.js
  2. +1 −0 package.json
View
18 lib/smtp.js
@@ -111,7 +111,6 @@ function connectionListener(socket) {
} catch(e) {
socket.emit('error', e)
}
- console.info('>'+a.replace("\n", ">\n"));
}
socket.on('connect', function () {
@@ -129,7 +128,6 @@ function connectionListener(socket) {
var f = function() { acceptOrReject(socket, message) }
if(typeof(message.smtpCode) == 'undefined') {
message.pause()
- console.log('waiting for accept or reject')
message.on('accept', f)
message.on('reject', f)
message.on('error', f)
@@ -190,7 +188,11 @@ function connectionListener(socket) {
socket.pause()
})
message.on('resume', function() {
- socket.resume()
+ try {
+ socket.resume()
+ } catch(e) {
+ // ignore: Probably already closed the socket.
+ }
})
message.on('error', function(e) {
message.error = e
@@ -234,7 +236,6 @@ function connectionListener(socket) {
}
}.bind(this));
socket.on('end', function () {
- console.info(' Unexpected End, Terminating connection.');
socket.destroy();
});
}
@@ -248,14 +249,15 @@ function resetSMTPState(socket) {
function acceptOrReject(socket, message) {
if(message.smtpCode >= 200 && message.smtpCode < 300) {
- console.info("Accept!")
socket.out(message.smtpCode + " " + message.smtpMessage)
} else if(message.smtpCode >= 500 && message.smtpCode < 600) {
- console.info("Reject!")
socket.out(message.smtpCode + " " + message.smtpMessage)
} else {
- console.info("Error!")
socket.out("451 Something went wrong")
}
- socket.resume()
+ try {
+ socket.resume()
+ } catch(e) {
+ // Socket probably closed already.
+ }
}
View
1 package.json
@@ -3,4 +3,5 @@
, "description" : "SMTP daemon (and eventually client) library"
, "engines" : {"node": "0.4.x || 0.5.x"}
, "directories" : { "lib" : "./lib", "bin": "./bin" }
+, "dependencies": { "mailbox" : "*" }
}

0 comments on commit 88e9a1c

Please sign in to comment.