]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: server: generalize the "updater" source
authorThierry Fournier <tfournier@arpalert.org>
Wed, 24 Feb 2016 07:25:39 +0000 (08:25 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 24 Feb 2016 22:37:39 +0000 (23:37 +0100)
the function server_parse_addr_change_request() contain an hardcoded
updater source "stats command". this function can be called from other
sources than the "stats command", so this patch make this argument
generic.

include/proto/server.h
src/dumpstats.c
src/server.c

index 99af0d4528f91b15cbd69031d1d91c0ff165625a..872503c1a7f0ca094df655df02b774b2429b0bab 100644 (file)
@@ -105,11 +105,12 @@ const char *server_parse_weight_change_request(struct server *sv,
                                               const char *weight_str);
 
 /*
- * Parses addr_str and configures sv accordingly.
+ * Parses addr_str and configures sv accordingly. updater precise
+ * the source of the change in the associated message log.
  * Returns NULL on success, error message string otherwise.
  */
 const char *server_parse_addr_change_request(struct server *sv,
-                                             const char *addr_str);
+                                             const char *addr_str, const char *updater);
 
 /*
  * Return true if the server has a zero user-weight, meaning it's in draining
index 8b55fe3a202c451a8e4c47b38714144e34ae7bf3..0ffbd5ac0116746cf25120a54101a5da12c646be 100644 (file)
@@ -1600,7 +1600,7 @@ static int stats_sock_parse_request(struct stream_interface *si, char *line)
                                }
                        }
                        else if (strcmp(args[3], "addr") == 0) {
-                               warning = server_parse_addr_change_request(sv, args[4]);
+                               warning = server_parse_addr_change_request(sv, args[4], "stats command");
                                if (warning) {
                                        appctx->ctx.cli.msg = warning;
                                        appctx->st0 = STAT_CLI_PRINT;
index 4e8f835dc5cdae462665e26a6c95e7d059b40e98..7941a485815726d7d5cc13c39266e2784980093f 100644 (file)
@@ -808,22 +808,23 @@ const char *server_parse_weight_change_request(struct server *sv,
 }
 
 /*
- * Parses <addr_str> and configures <sv> accordingly.
+ * Parses <addr_str> and configures <sv> accordingly. <from> precise
+ * the source of the change in the associated message log.
  * Returns:
  *  - error string on error
  *  - NULL on success
  */
 const char *server_parse_addr_change_request(struct server *sv,
-                                             const char *addr_str)
+                                             const char *addr_str, const char *updater)
 {
        unsigned char ip[INET6_ADDRSTRLEN];
 
        if (inet_pton(AF_INET6, addr_str, ip)) {
-               update_server_addr(sv, ip, AF_INET6, "stats command");
+               update_server_addr(sv, ip, AF_INET6, updater);
                return NULL;
        }
        if (inet_pton(AF_INET, addr_str, ip)) {
-               update_server_addr(sv, ip, AF_INET, "stats command");
+               update_server_addr(sv, ip, AF_INET, updater);
                return NULL;
        }