MINOR: resolvers: Add function to change the srv status based on SRV resolution
srvrq_update_srv_status() update the server status based on result of SRV
resolution. For now, it is only used from snr_update_srv_status() when
appropriate.
(cherry picked from commit 5efdef24c1753d7a68d1f6c8dc8cb6b4b84a3361)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
diff --git a/src/server.c b/src/server.c
index dcc2a6a..8314f78 100644
--- a/src/server.c
+++ b/src/server.c
@@ -3692,6 +3692,31 @@
return msg->area;
}
+/*
+ * update server status based on result of SRV resolution
+ * returns:
+ * 0 if server status is updated
+ * 1 if server status has not changed
+ *
+ * Must be called with the server lock held.
+ */
+int srvrq_update_srv_status(struct server *s, int has_no_ip)
+{
+ if (!s->srvrq)
+ return 1;
+
+ /* since this server has an IP, it can go back in production */
+ if (has_no_ip == 0) {
+ srv_clr_admin_flag(s, SRV_ADMF_RMAINT);
+ return 1;
+ }
+
+ if (s->next_admin & SRV_ADMF_RMAINT)
+ return 1;
+
+ srv_set_admin_flag(s, SRV_ADMF_RMAINT, "entry removed from SRV record");
+ return 0;
+}
/*
* update server status based on result of name resolution
@@ -3708,19 +3733,8 @@
int exp;
/* If resolution is NULL we're dealing with SRV records Additional records */
- if (resolution == NULL) {
- /* since this server has an IP, it can go back in production */
- if (has_no_ip == 0) {
- srv_clr_admin_flag(s, SRV_ADMF_RMAINT);
- return 1;
- }
-
- if (s->next_admin & SRV_ADMF_RMAINT)
- return 1;
-
- srv_set_admin_flag(s, SRV_ADMF_RMAINT, "entry removed from SRV record");
- return 0;
- }
+ if (resolution == NULL)
+ return srvrq_update_srv_status(s, has_no_ip);
switch (resolution->status) {
case RSLV_STATUS_NONE: