From b65b28e56a373c468d52ab528bfa869abbfc9acd Mon Sep 17 00:00:00 2001
From: Benedict Weis <benedict.weis01@sap.com>
Date: Thu, 12 Feb 2026 15:36:56 +0100
Subject: [PATCH] BUG/MINOR: server: fix server-state-file servers ip address
 entries not being applied

This patch fixes a regression introduced by commit 25e5152.
When using the server-state-file, the regression prevents applying
the server's last IP address that was read from the server-state-file.
Under certain conditions, this could produce unstable behavior when
the port was read from the server-state-file correctly, but the
IP was read from the config file.

This patch adjust the logic around the server IP address
setting such that if the server had an IP in the server-state-file
it is always used.

Affected version are: 2.4, 2.6, 2.8, 3.0, 3.1, 3.2 and 3.3.

Issue Link: https://github.com/haproxy/haproxy/issues/3265

Co-authored-by: Alexander Stephan <alexander.stephan@sap.com>
---
 src/server.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/server.c b/src/server.c
index 925b0c4af..d9eccef9c 100644
--- a/src/server.c
+++ b/src/server.c
@@ -5344,6 +5344,8 @@ int srv_init_addr(void)
 			set_usermsgs_ctx(srv->conf.file, srv->conf.line, &srv->obj_type);
 			if (srv->hostname || srv->srvrq)
 				return_code |= srv_iterate_initaddr(srv);
+			if (srv->lastaddr)
+				return_code |= srv_apply_lastaddr(srv, NULL);
 			reset_usermsgs_ctx();
 		}

--
2.52.0

