[PATCH 3 of 7] Mail: simplified ngx_mail_proxy_handler()
Maxim Dounin
mdounin at mdounin.ru
Wed Jun 18 12:37:35 UTC 2025
# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1750204968 -10800
# Wed Jun 18 03:02:48 2025 +0300
# Node ID cd85e94f52db98778bac968957277a41bc944927
# Parent 1a6f707ab976e825a00d32d8eaba6fb6402fd7a8
Mail: simplified ngx_mail_proxy_handler().
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