summaryrefslogtreecommitdiff
path: root/include/haproxy/errors.h
Commit message (Collapse)AuthorAgeFilesLines
* MINOR: stats: report the total number of warnings issuedWilly Tarreau2023-05-111-0/+1
| | | | | | Now in "show info" we have a TotalWarnings field that reports the total number of warnings issued since the process started. It's also reported in the the stats page next to the uptime.
* MINOR: logs: startup-logs can use a shm for logging the reloadWilliam Lallemand2022-10-131-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | When compiled with USE_SHM_OPEN=1 the startup-logs are now able to use an shm which is used to keep the logs when switching to mworker wait mode. This allows to keep the failed reload logs. When allocating the startup-logs at first start of the process, haproxy will do a shm_open with a unique path using the PID of the process, the file is unlink immediatly so we don't let unwelcomed files be. The fd resulting from this shm is stored in the HAPROXY_STARTUPLOGS_FD environment variable so it can be mmap again when switching to wait mode. When forking children, the process is copying the mmap to a a mallocated ring so we never share the same memory section between the master and the workers. When switching to wait mode, the shm is not used anymore as it is also copied to a mallocated structure. This allow to use the "show startup-logs" command over the master CLI, to get the logs of the latest startup or reload. This way the logs of the latest failed reload are also kept. This is only activated on the linux-glibc target for now.
* MEDIUM: stick-table: handle arrays of standard types into stick-tablesEmeric Brun2021-07-061-0/+1
| | | | | | | | | | | | This patch provides the code to handle arrays of some standard types (SINT, UINT, ULL and FRQP) in stick table. This way we could define new "array" data types. Note: the number of elements of an array was limited to 100 to put a limit and to ensure that an encoded update message will continue to fit into a buffer when the peer protocol will handle such data types.
* BUG/MEDIUM: errors: include missing obj_type fileWilly Tarreau2021-06-111-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | A tiny change in commit 6af81f80f ("MEDIUM: errors: implement parsing context type") triggered an awful bug in gcc 5 and below (4.7.4 to 5.5 confirmed affected, at least on aarch64/mips/x86_64) causing the startup to loop forever in acl_find_target(). This was tracked down to the acl.c file seeing a different definition of the struct proxy than other files. The reason for this is that it sees an unpacked "enum obj_type" (4 bytes) while others see it packed (1 byte), thus all fields in the struct are having a different alignment, and the "acl" list is shifted one pointer to the next struct and seems to loop onto itself. The commit above did nothing more than adding "enum obj_type *obj" in a new struct without including obj_type.h, and that was apparently enough for the compiler to internally declare obj_type as a regular enum and silently ignore the packed attribute that it discovers later, so depending on the order of includes, some files would see it as 1 byte and others as 4. This patch simply adds the missing include but due to the nature of the bug, probably that creating a special "packed_enum" definition to disable the packed attribute on such compilers could be a safer option. No backport is needed as this is only in -dev.
* BUG: errors: remove printf positional args for user messages contextAmaury Denoyelle2021-06-081-0/+4
| | | | | | | | | | | | | | | | | Change the algorithm for the generation of the user messages context prefix. Remove the dubious API relying on optional printf positional arguments. This may be non portable, and in fact the CI glibc crashes with the following error when some arguments are not present in the format string : "invalid %N$ use detected". Now, a fixed buffer attached to the context instance is allocated once for the program lifetime. Then call repeatedly snprintf with the optional arguments of context if present to build the context string. The buffer is deallocated via a per-thread free handler. This does not need to be backported.
* MEDIUM: errors: implement parsing context typeAmaury Denoyelle2021-06-071-1/+11
| | | | | | | Create a parsing_ctx structure. This type is used to store information about the current file/line parsed. A global context is created and can be manipulated when haproxy is in STARTING mode. When starting is over, the context is resetted and should not be accessed anymore.
* MEDIUM: errors: implement user messages bufferAmaury Denoyelle2021-06-071-0/+4
| | | | | | | | | | The user messages buffer is used to store the stderr output after the starting is over. Each thread has it own user messages buffer. Add some functions to add a new message, retrieve and clear the content. The user messages buffer primary goal is to be consulted by CLI handlers. Each handlers using it must clear the buffer before starting its operation.
* REORG: errors: split errors reporting function from log.cAmaury Denoyelle2021-06-071-1/+1
| | | | | | Move functions related to errors output on stderr from log.c to a newly created errors.c file. It targets print_message and ha_alert/warning/notice/diag functions and related startup_logs feature.
* MINOR: errors: allow empty va_args for diag variadic macroAmaury Denoyelle2021-06-071-1/+1
| | | | | | | Use the '##' operator to allow the usage of HA_DIAG_WARNING_COND macro without extra arguments. This must be backported up to 2.4.
* BUILD: errors: include stdarg in errors.hWilly Tarreau2021-05-091-0/+1
| | | | It's needed for va_list as defined in ha_vdiag_warning().
* MINOR: global: define diagnostic mode of executionAmaury Denoyelle2021-04-011-0/+16
| | | | | | | | | | | | | Define MODE_DIAG which is used to run haproxy in diagnostic mode. This mode is used to output extra warnings about possible configuration blunder or sub-optimal usage. It can be activated with argument '-dD'. A new output function ha_diag_warning is implemented reserved for diagnostic output. It serves to standardize the format of diagnostic messages. A macro HA_DIAG_WARN_COND is also available to automatically check if diagnostic mode is on before executing the diagnostic check.
* REORG: include: move the error reporting functions to from log.h to errors.hWilly Tarreau2020-06-111-0/+30
| | | | | | | | | | | | | | Most of the files dealing with error reports have to include log.h in order to access ha_alert(), ha_warning() etc. But while these functions don't depend on anything, log.h depends on a lot of stuff because it deals with log-formats and samples. As a result it's impossible not to embark long dependencies when using ha_warning() or qfprintf(). This patch moves these low-level functions to errors.h, which already defines the error codes used at the same places. About half of the users of log.h could be adjusted, sometimes revealing other issues such as missing tools.h. Interestingly the total preprocessed size shrunk by 4%.
* REORG: include: move base64.h, errors.h and hash.h from common to to haproxy/Willy Tarreau2020-06-111-0/+66
These ones do not depend on any other file. One used to include haproxy/api.h but that was solely for stddef.h.