# DEBUG_NO_POOLS, DEBUG_FAIL_ALLOC, DEBUG_STRICT_ACTION=[0-3], DEBUG_HPACK,
# DEBUG_AUTH, DEBUG_SPOE, DEBUG_UAF, DEBUG_THREAD, DEBUG_STRICT, DEBUG_DEV,
# DEBUG_TASK, DEBUG_MEMORY_POOLS, DEBUG_POOL_TRACING, DEBUG_QPACK, DEBUG_LIST,
-# DEBUG_GLITCHES.
+# DEBUG_GLITCHES, DEBUG_STRESS.
DEBUG =
#### Trace options
values to its internal counters. Use the CLI command "dump stats-file" to
produce such stats-file. See the management manual for more details.
+stress-level <level>
+ Activate alternative code to stress haproxy binary. Level is an integer from
+ 0 to 9. The default value 0 disable any stressing execution. Levels from 1 to
+ 9 will increase the stress pressure on the haproxy binary. Note that using
+ any positive level can significantly hurt performance. As such it should
+ never be activated unless for debugging purpose and on a developer request.
+
strict-limits
Makes process fail at startup when a setrlimit fails. HAProxy tries to set the
best setrlimit according to what has been calculated. If it fails, it will
--- /dev/null
+#ifndef _HAPROXY_STRESS_H
+#define _HAPROXY_STRESS_H
+
+#ifdef DEBUG_STRESS
+enum { mode_stress = 1 };
+#else
+enum { mode_stress = 0 };
+#endif
+
+extern int mode_stress_level;
+
+#define STRESS_RUN1(a,b) (mode_stress && unlikely(mode_stress_level >= 1) ? (a) : (b))
+#define STRESS_RUN2(a,b) (mode_stress && unlikely(mode_stress_level >= 2) ? (a) : (b))
+#define STRESS_RUN3(a,b) (mode_stress && unlikely(mode_stress_level >= 3) ? (a) : (b))
+#define STRESS_RUN4(a,b) (mode_stress && unlikely(mode_stress_level >= 4) ? (a) : (b))
+#define STRESS_RUN5(a,b) (mode_stress && unlikely(mode_stress_level >= 5) ? (a) : (b))
+#define STRESS_RUN6(a,b) (mode_stress && unlikely(mode_stress_level >= 6) ? (a) : (b))
+#define STRESS_RUN7(a,b) (mode_stress && unlikely(mode_stress_level >= 7) ? (a) : (b))
+#define STRESS_RUN8(a,b) (mode_stress && unlikely(mode_stress_level >= 8) ? (a) : (b))
+#define STRESS_RUN9(a,b) (mode_stress && unlikely(mode_stress_level >= 9) ? (a) : (b))
+
+#endif /* _HAPROXY_STRESS_H */
#include <haproxy/log.h>
#include <haproxy/peers.h>
#include <haproxy/protocol.h>
+#include <haproxy/stress.h>
#include <haproxy/tools.h>
int cluster_secret_isset;
return 0;
}
+static int cfg_parse_global_stress_level(char **args, int section_type, struct proxy *curpx,
+ const struct proxy *defpx, const char *file, int line,
+ char **err)
+{
+ char *stop;
+ int level;
+
+ if (too_many_args(1, args, err, NULL))
+ return -1;
+
+ if (*(args[1]) == 0) {
+ memprintf(err, "'%s' expects a level as an argument.", args[0]);
+ return -1;
+ }
+
+ level = strtol(args[1], &stop, 10);
+ if ((*stop != '\0') || level < 0 || level > 9) {
+ memprintf(err, "'%s' level must be between 0 and 9 inclusive.", args[0]);
+ return -1;
+ }
+
+ mode_stress_level = level;
+
+ return 0;
+}
+
static struct cfg_kw_list cfg_kws = {ILH, {
{ CFG_GLOBAL, "prealloc-fd", cfg_parse_prealloc_fd },
{ CFG_GLOBAL, "force-cfg-parser-pause", cfg_parse_global_parser_pause, KWF_EXPERIMENTAL },
{ CFG_GLOBAL, "presetenv", cfg_parse_global_env_opts, KWF_DISCOVERY },
{ CFG_GLOBAL, "chroot", cfg_parse_global_chroot },
{ CFG_GLOBAL, "localpeer", cfg_parse_global_localpeer, KWF_DISCOVERY },
+ { CFG_GLOBAL, "stress-level", cfg_parse_global_stress_level },
{ 0, NULL, NULL },
}};
int must_free;
};
+int mode_stress_level = 0;
+
/*********************************************************************/
/* general purpose functions ***************************************/
/*********************************************************************/