With "log global" line, the global list of loggers are copied into the proxy's
struct. The list coming from the default section is also copied when a frontend
or a backend section is parsed. So it is possible to have duplicate entries in
the proxy's list. For instance, with this following config, all messages will be
logged twice:
global
log 127.0.0.1 local0 debug
daemon
defaults
mode http
log global
option httplog
frontend front-http
log global
bind *:8888
default_backend back-http
backend back-http
server www 127.0.0.1:8000
int level;
int minlvl;
int maxlen;
+ struct logsrv *ref;
};
#endif /* _TYPES_LOG_H */
list_for_each_entry(tmplogsrv, &defproxy.logsrvs, list) {
struct logsrv *node = malloc(sizeof(*node));
memcpy(node, tmplogsrv, sizeof(struct logsrv));
+ node->ref = tmplogsrv->ref;
LIST_INIT(&node->list);
LIST_ADDQ(&curproxy->logsrvs, &node->list);
}
goto error;
}
list_for_each_entry(logsrv, &global.logsrvs, list) {
- struct logsrv *node = malloc(sizeof(*node));
+ struct logsrv *node;
+
+ list_for_each_entry(node, logsrvs, list) {
+ if (node->ref == logsrv)
+ goto skip_logsrv;
+ }
+
+ node = malloc(sizeof(*node));
memcpy(node, logsrv, sizeof(struct logsrv));
+ node->ref = logsrv;
LIST_INIT(&node->list);
LIST_ADDQ(logsrvs, &node->list);
+
+ skip_logsrv:
+ continue;
}
return 1;
}