summaryrefslogtreecommitdiffstats
path: root/src/rspamd_proxy.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-06-11 13:15:35 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-06-11 13:15:35 +0100
commite48dc88595c2ddd7be31512ba6677ceff09d7632 (patch)
treefc71880a931f2c2326f65c5c7af60af6f0fbbaef /src/rspamd_proxy.c
parent78ba3dfdbf1b5e0747f4e9258f48c8adc2a5482d (diff)
downloadrspamd-e48dc88595c2ddd7be31512ba6677ceff09d7632.tar.gz
rspamd-e48dc88595c2ddd7be31512ba6677ceff09d7632.zip
[Fix] Use shared memory merely for local backends in the proxy
Diffstat (limited to 'src/rspamd_proxy.c')
-rw-r--r--src/rspamd_proxy.c38
1 files changed, 29 insertions, 9 deletions
diff --git a/src/rspamd_proxy.c b/src/rspamd_proxy.c
index 6e0c1c254..65339b3d5 100644
--- a/src/rspamd_proxy.c
+++ b/src/rspamd_proxy.c
@@ -1035,10 +1035,19 @@ proxy_open_mirror_connections (struct rspamd_proxy_session *session)
session->ctx->local_key);
msg->peer_key = rspamd_pubkey_ref (m->key);
- rspamd_http_connection_write_message_shared (bk_conn->backend_conn,
- msg, NULL, NULL, bk_conn,
- bk_conn->backend_sock,
- &session->ctx->io_tv, session->ctx->ev_base);
+ if (m->local ||
+ rspamd_inet_address_is_local (rspamd_upstream_addr (bk_conn->up))) {
+ rspamd_http_connection_write_message_shared (bk_conn->backend_conn,
+ msg, NULL, NULL, bk_conn,
+ bk_conn->backend_sock,
+ &session->ctx->io_tv, session->ctx->ev_base);
+ }
+ else {
+ rspamd_http_connection_write_message (bk_conn->backend_conn,
+ msg, NULL, NULL, bk_conn,
+ bk_conn->backend_sock,
+ &session->ctx->io_tv, session->ctx->ev_base);
+ }
g_ptr_array_add (session->mirror_conns, bk_conn);
REF_RETAIN (session);
@@ -1218,11 +1227,22 @@ proxy_client_finish_handler (struct rspamd_http_connection *conn,
session->ctx->local_key);
msg->peer_key = rspamd_pubkey_ref (backend->key);
- rspamd_http_connection_write_message_shared (
- session->master_conn->backend_conn,
- msg, NULL, NULL, session->master_conn,
- session->master_conn->backend_sock,
- &session->ctx->io_tv, session->ctx->ev_base);
+ if (backend->local ||
+ rspamd_inet_address_is_local (
+ rspamd_upstream_addr (session->master_conn->up))) {
+ rspamd_http_connection_write_message_shared (
+ session->master_conn->backend_conn,
+ msg, NULL, NULL, session->master_conn,
+ session->master_conn->backend_sock,
+ &session->ctx->io_tv, session->ctx->ev_base);
+ }
+ else {
+ rspamd_http_connection_write_message (
+ session->master_conn->backend_conn,
+ msg, NULL, NULL, session->master_conn,
+ session->master_conn->backend_sock,
+ &session->ctx->io_tv, session->ctx->ev_base);
+ }
}
}
else {