summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-02-18 12:58:57 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-02-18 12:58:57 +0000
commit0f32df6f44c75cb9be69618e699fb2972cc7d421 (patch)
treec7be839a23808ac274a0fc5c14c75a55607600ad /test
parentc9d04a923e2a64321df8128aa4efaacdfccbed2f (diff)
downloadrspamd-0f32df6f44c75cb9be69618e699fb2972cc7d421.tar.gz
rspamd-0f32df6f44c75cb9be69618e699fb2972cc7d421.zip
[Fix] Core: Fix address rotation bug
Previously, upstream.get_addr function returned the new address of the upstream. Unfortunately, it was used for printing addresses. It caused the following situation: let's imagine we have A1 and A2 where A1 was initially selected. So the connection was performed to A1: Current addr Selected addr Connect+---------+ A2+------>A1 A1 | +-+Print failure<---+ A1+------>A2 A2 | +----+ +->Mark failure+-------->+ A2 | +----+ But the failure OP as well as log message told about `A2` where the real problem happened with `A1`. This commit adds distinguishing between getting the next and the current address of the upstream resolving this issue.
Diffstat (limited to 'test')
-rw-r--r--test/rspamd_upstream_test.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/test/rspamd_upstream_test.c b/test/rspamd_upstream_test.c
index 4e4f1ae87..668651c8f 100644
--- a/test/rspamd_upstream_test.c
+++ b/test/rspamd_upstream_test.c
@@ -87,27 +87,27 @@ rspamd_upstream_test_func (void)
rspamd_parse_inet_address (&paddr, "::1", 0);
g_assert (rspamd_upstream_add_addr (up, paddr));
/* Rewind to start */
- addr = rspamd_upstream_addr (up);
- addr = rspamd_upstream_addr (up);
+ addr = rspamd_upstream_addr_next (up);
+ addr = rspamd_upstream_addr_next (up);
/* cur should be zero here */
- addr = rspamd_upstream_addr (up);
- next_addr = rspamd_upstream_addr (up);
+ addr = rspamd_upstream_addr_next (up);
+ next_addr = rspamd_upstream_addr_next (up);
g_assert (rspamd_inet_address_get_af (addr) == AF_INET);
g_assert (rspamd_inet_address_get_af (next_addr) == AF_INET);
- next_addr = rspamd_upstream_addr (up);
+ next_addr = rspamd_upstream_addr_next (up);
g_assert (rspamd_inet_address_get_af (next_addr) == AF_INET6);
- next_addr = rspamd_upstream_addr (up);
+ next_addr = rspamd_upstream_addr_next (up);
g_assert (rspamd_inet_address_get_af (next_addr) == AF_INET);
- next_addr = rspamd_upstream_addr (up);
+ next_addr = rspamd_upstream_addr_next (up);
g_assert (rspamd_inet_address_get_af (next_addr) == AF_INET);
- next_addr = rspamd_upstream_addr (up);
+ next_addr = rspamd_upstream_addr_next (up);
g_assert (rspamd_inet_address_get_af (next_addr) == AF_INET6);
/* Test errors with IPv6 */
rspamd_upstream_fail (up, TRUE);
/* Now we should have merely IPv4 addresses in rotation */
- addr = rspamd_upstream_addr (up);
+ addr = rspamd_upstream_addr_next (up);
for (i = 0; i < 256; i++) {
- next_addr = rspamd_upstream_addr (up);
+ next_addr = rspamd_upstream_addr_next (up);
g_assert (rspamd_inet_address_get_af (addr) == AF_INET);
g_assert (rspamd_inet_address_get_af (next_addr) == AF_INET);
g_assert (rspamd_inet_address_compare (addr, next_addr) != 0);