[nginx] Mail: simplified ngx_mail_proxy_handler().

Maxim Dounin mdounin at mdounin.ru
Mon Jun 30 22:41:00 UTC 2025


details:   http://freenginx.org/hg/nginx/rev/6d3269e83928
branches:  
changeset: 9380:6d3269e83928
user:      Maxim Dounin <mdounin at mdounin.ru>
date:      Tue Jul 01 01:08:20 2025 +0300
description:
Mail: simplified ngx_mail_proxy_handler().

diffstat:

 src/mail/ngx_mail_proxy_module.c |  42 ++++++++++++---------------------------
 1 files changed, 13 insertions(+), 29 deletions(-)

diffs (54 lines):

diff --git a/src/mail/ngx_mail_proxy_module.c b/src/mail/ngx_mail_proxy_module.c
--- a/src/mail/ngx_mail_proxy_module.c
+++ b/src/mail/ngx_mail_proxy_module.c
@@ -1148,37 +1148,21 @@ ngx_mail_proxy_handler(ngx_event_t *ev)
         return;
     }
 
-    if (c == s->connection) {
-        if (ev->write) {
-            recv_action = "proxying and reading from upstream";
-            send_action = "proxying and sending to client";
-            src = s->proxy->upstream.connection;
-            dst = c;
-            b = s->proxy->buffer;
-
-        } else {
-            recv_action = "proxying and reading from client";
-            send_action = "proxying and sending to upstream";
-            src = c;
-            dst = s->proxy->upstream.connection;
-            b = s->buffer;
-        }
+    if ((c == s->connection && ev->write)
+        || (c != s->connection && !ev->write))
+    {
+        recv_action = "proxying and reading from upstream";
+        send_action = "proxying and sending to client";
+        src = s->proxy->upstream.connection;
+        dst = s->connection;
+        b = s->proxy->buffer;
 
     } else {
-        if (ev->write) {
-            recv_action = "proxying and reading from client";
-            send_action = "proxying and sending to upstream";
-            src = s->connection;
-            dst = c;
-            b = s->buffer;
-
-        } else {
-            recv_action = "proxying and reading from upstream";
-            send_action = "proxying and sending to client";
-            src = c;
-            dst = s->connection;
-            b = s->proxy->buffer;
-        }
+        recv_action = "proxying and reading from client";
+        send_action = "proxying and sending to upstream";
+        src = s->connection;
+        dst = s->proxy->upstream.connection;
+        b = s->buffer;
     }
 
     do_write = ev->write ? 1 : 0;


More information about the nginx-devel mailing list