void trace_register_source(struct trace_source *source);
-int trace_parse_cmd(const char *arg_src, char **errmsg);
+int trace_add_cmd(const char *arg_src, char **errmsg);
+void trace_parse_cmds(void);
/* return a single char to describe a trace state */
static inline char trace_state_char(enum trace_state st)
argc--; argv++;
}
- ret = trace_parse_cmd(arg, &err_msg);
- if (ret <= -1) {
- if (ret < -1) {
- ha_alert("-dt: %s.\n", err_msg);
- ha_free(&err_msg);
- exit(EXIT_FAILURE);
- }
- else {
- printf("%s\n", err_msg);
- ha_free(&err_msg);
- exit(0);
- }
+ ret = trace_add_cmd(arg, &err_msg);
+ if (ret) {
+ ha_alert("-dt: %s.\n", err_msg);
+ ha_free(&err_msg);
+ exit(EXIT_FAILURE);
}
}
#ifdef HA_USE_KTLS
list_for_each_entry_safe(cfg, cfg_tmp, &cfg_cfgfiles, list)
ha_free(&cfg->content);
+ trace_parse_cmds();
usermsgs_clr(NULL);
}
struct list trace_sources = LIST_HEAD_INIT(trace_sources);
THREAD_LOCAL struct buffer trace_buf = { };
+struct trace_cmd {
+ struct list next;
+ const char *arg;
+};
+
+/* List of arguments to "-dt" options for deferred processing. */
+static struct list trace_cmds = LIST_HEAD_INIT(trace_cmds);
+
/* allocates the trace buffers. Returns 0 in case of failure. It is safe to
* call to call this function multiple times if the size changes.
*/
return _trace_parse_statement(args, msg, NULL, 0);
}
+int trace_add_cmd(const char *arg_src, char **errmsg)
+{
+ struct trace_cmd *cmd;
+
+ cmd = malloc(sizeof(*cmd));
+ if (!cmd) {
+ memprintf(errmsg, "Can't allocate trace cmd!");
+ return -1;
+ }
+
+ cmd->arg = arg_src;
+ LIST_APPEND(&trace_cmds, &cmd->next);
+ return 0;
+}
+
void _trace_parse_cmd(struct trace_source *src, int level, int verbosity)
{
trace_source_reset(src);
*
* Returns 0 on success else non-zero.
*/
-int trace_parse_cmd(const char *arg_src, char **errmsg)
+static int trace_parse_cmd(const char *arg_src, char **errmsg)
{
char *str;
char *arg, *oarg;
return 0;
}
+void trace_parse_cmds(void)
+{
+ struct trace_cmd *cmd;
+ char *errmsg = NULL;
+ int ret = 0;
+
+ while (!LIST_ISEMPTY(&trace_cmds)) {
+ cmd = LIST_ELEM(trace_cmds.n, struct trace_cmd *, next);
+ if (!ret)
+ ret = trace_parse_cmd(cmd->arg, &errmsg);
+ LIST_DELETE(&cmd->next);
+ free(cmd);
+ }
+
+ if (ret <= -1) {
+ if (ret < -1) {
+ ha_alert("-dt: %s.\n", errmsg);
+ ha_free(&errmsg);
+ exit(EXIT_FAILURE);
+ }
+ else {
+ printf("%s\n", errmsg);
+ ha_free(&errmsg);
+ exit(0);
+ }
+ }
+}
+
/* parse a "trace" statement in the "global" section, returns 1 if a message is returned, otherwise zero */
static int cfg_parse_trace(char **args, int section_type, struct proxy *curpx,
const struct proxy *defpx, const char *file, int line,