From b888217060dc4f8d302f64782ce3301692205349 Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Tue, 30 Apr 2024 16:21:20 -0700 Subject: [PATCH] connection: assure remote is connected before queue (#3338) - immediately before queuing, check that remote is still connected --- Changes.md | 1 + connection.js | 5 ++--- plugins/queue/smtp_forward.js | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Changes.md b/Changes.md index 1d48ae434..e441c235f 100644 --- a/Changes.md +++ b/Changes.md @@ -8,6 +8,7 @@ #### Changed - bounce: repackaged plugin as NPM module #3341 +- connection: check remote is connected before queue #3338 - transaction: init with conn.init_transaction, always pass in cfg #3315 - check for local_mx only when default route is used #3307 - dkim: repackaged as NPM module #3311 diff --git a/connection.js b/connection.js index 02202595a..5f2c3c121 100644 --- a/connection.js +++ b/connection.js @@ -3,10 +3,8 @@ // node.js built-in libs const dns = require('dns'); -const fs = require('fs'); const net = require('net'); const os = require('os'); -const path = require('path'); // npm libs const ipaddr = require('ipaddr.js'); @@ -1738,6 +1736,7 @@ class Connection { } } queue_outbound_respond (retval, msg) { + if (this.remote.closed) return; if (!msg) msg = this.queue_msg(retval, msg) || 'Message Queued'; this.store_queue_result(retval, msg); msg = `${msg} (${this.transaction.uuid})`; @@ -1894,4 +1893,4 @@ exports.createConnection = (client, server, cfg) => { return new Connection(client, server, cfg); } -logger.add_log_methods(Connection) \ No newline at end of file +logger.add_log_methods(Connection) diff --git a/plugins/queue/smtp_forward.js b/plugins/queue/smtp_forward.js index 4d035b761..9fbb055b2 100644 --- a/plugins/queue/smtp_forward.js +++ b/plugins/queue/smtp_forward.js @@ -230,6 +230,7 @@ exports.forward_enabled = function (conn, dom_cfg) { exports.queue_forward = function (next, connection) { const plugin = this; + if (connection.remote.closed) return const txn = connection?.transaction; const cfg = plugin.get_config(connection);