---
This patch converts the peers parser from the peers-specific keyword
registration system (peers_register_keywords/peers_kw_list) to the standard
cfg_kw_list mechanism used by other cofiguration sections.
This change:
- Removes extern declarations and uses proper header includes
- Converts global variables (errmsg, err_code, newpeer, bind_conf) to
function-local variables for better encapsulation
- Replaces peers_keywords iteration with cfg_kw_list iteration
- Preserves rc < 0 (error) and rc > 0 (warning) return value handling for
backward compatibility with external modules using EXTRA_OBJS
The peers_register_keywords() system was peers-specific and did not integrate
with the standard configuration keyword infrastructure. Using cfg_kw_list
ensures consistency with other parsers and enables the keywords to be
discovered by the -dKall option.
---
src/cfgparse-peers.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/src/cfgparse-peers.c b/src/cfgparse-peers.c
index b7183229e..2e03f8531 100644
--- a/src/cfgparse-peers.c
+++ b/src/cfgparse-peers.c
@@ -571,22 +571,24 @@ int cfg_parse_peers(const char *file, int linenum, char
**args, int kwm)
curpeers->disabled = 0;
}
else if (*args[0] != 0) {
- struct peers_kw_list *pkwl;
+ struct cfg_kw_list *kwl;
int index;
- int rc = -1;
+ int rc;
- list_for_each_entry(pkwl, &peers_keywords.list, list) {
- for (index = 0; pkwl->kw[index].kw != NULL; index++) {
- if (strcmp(pkwl->kw[index].kw, args[0]) == 0) {
- rc = pkwl->kw[index].parse(args,
curpeers, file, linenum, &errmsg);
+ list_for_each_entry(kwl, &cfg_keywords.list, list) {
+ for (index = 0; kwl->kw[index].kw != NULL; index++) {
+ if ((kwl->kw[index].section == CFG_PEERS) &&
+ strcmp(kwl->kw[index].kw, args[0]) == 0) {
+ rc = kwl->kw[index].parse(args,
CFG_PEERS, curpeers->peers_fe, NULL, file, linenum, &errmsg);
if (rc < 0) {
ha_alert("parsing [%s:%d] :
%s\n", file, linenum, errmsg);
err_code |= ERR_ALERT |
ERR_FATAL;
goto out;
}
else if (rc > 0) {
- ha_warning("parsing [%s:%d] :
%s\n", file, linenum, errmsg);
- err_code |= ERR_WARN;
+ if (errmsg)
+ ha_warning("parsing
[%s:%d] : %s\n", file, linenum, errmsg);
+ err_code |= rc;
goto out;
}
goto out;
--
2.48.1