Don't close the VERP Server on error. And improved error reporting.
Based on https://git.io/vQLS7 , I believe the change introduced in https://git.io/vQL7u "server.close()" to be in error, and intended to close one connection, like it’s handled in https://git.io/vQLSF Perhaps SMTPServer isn't even meant to throw ECONNRESET and EPIPE in the first place.
This commit is contained in:
parent
277b2cadf5
commit
963aef53b5
3 changed files with 62 additions and 16 deletions
|
@ -70,17 +70,37 @@ let server = net.createServer(socket => {
|
|||
});
|
||||
});
|
||||
|
||||
server.on('error', err => {
|
||||
log.error('POSTFIXBOUNCE', err && err.stack);
|
||||
});
|
||||
|
||||
module.exports = callback => {
|
||||
if (config.postfixbounce.enabled) {
|
||||
server.listen(config.postfixbounce.port, config.postfixbounce.host, () => {
|
||||
log.info('POSTFIXBOUNCE', 'Server listening on port %s', config.postfixbounce.port);
|
||||
setImmediate(callback);
|
||||
});
|
||||
} else {
|
||||
setImmediate(callback);
|
||||
if (!config.postfixbounce.enabled) {
|
||||
return setImmediate(callback);
|
||||
}
|
||||
|
||||
let started = false;
|
||||
|
||||
server.on('error', err => {
|
||||
const port = config.postfixbounce.port;
|
||||
const bind = typeof port === 'string' ? 'Pipe ' + port : 'Port ' + port;
|
||||
|
||||
switch (err.code) {
|
||||
case 'EACCES':
|
||||
log.error('POSTFIXBOUNCE', '%s requires elevated privileges.', bind);
|
||||
break;
|
||||
case 'EADDRINUSE':
|
||||
log.error('POSTFIXBOUNCE', '%s is already in use', bind);
|
||||
break;
|
||||
default:
|
||||
log.error('POSTFIXBOUNCE', err);
|
||||
}
|
||||
|
||||
if (!started) {
|
||||
started = true;
|
||||
return callback(err);
|
||||
}
|
||||
});
|
||||
|
||||
server.listen(config.postfixbounce.port, config.postfixbounce.host, () => {
|
||||
started = true;
|
||||
log.info('POSTFIXBOUNCE', 'Server listening on port %s', config.postfixbounce.port);
|
||||
setImmediate(callback);
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue