![]() |
The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
Support functions to allow libraries to provide errors to their callers. More...
#include <freeradius-devel/util/dlist.h>#include <freeradius-devel/util/strerror.h>#include <freeradius-devel/util/atexit.h>
Include dependency graph for strerror.c:Go to the source code of this file.
Data Structures | |
| struct | fr_log_buffer_t |
| Holds data used by the logging stack. More... | |
| struct | fr_log_entry_s |
Macros | |
| #define | FR_STRERROR_BUFSIZE (2048) |
Typedefs | |
| typedef struct fr_log_entry_s | fr_log_entry_t |
Functions | |
| static int | _fr_logging_free (void *arg) |
| void | _fr_strerror_const (char const *file, int line, char const *msg) |
| Log to thread local error buffer. | |
| void | _fr_strerror_const_push (char const *file, int line, char const *msg) |
| Add a message to an existing stack of messages at the tail. | |
| void | _fr_strerror_const_push_head (char const *file, int line, char const *msg) |
| Add a message to an existing stack of messages at the head. | |
| void | _fr_strerror_marker_vprintf (char const *file, int line, char const *subject, size_t offset, char const *fmt, va_list ap) |
| Add an error marker to an existing stack of messages. | |
| void | _fr_strerror_marker_vprintf_push (char const *file, int line, char const *subject, size_t offset, char const *fmt, va_list ap) |
| Add an error marker to an existing stack of messages at the tail. | |
| void | _fr_strerror_marker_vprintf_push_head (char const *file, int line, char const *subject, size_t offset, char const *fmt, va_list ap) |
| Add an error marker to an existing stack of messages at the head. | |
| void | _fr_strerror_vprintf (char const *file, int line, char const *fmt, va_list ap) |
| Log to thread local error buffer. | |
| void | _fr_strerror_vprintf_push (char const *file, int line, char const *fmt, va_list ap) |
| Add a message to an existing stack of messages at the tail. | |
| void | _fr_strerror_vprintf_push_head (char const *file, int line, char const *fmt, va_list ap) |
| Add a message to an existing stack of messages at the head. | |
| void | fr_perror (char const *fmt,...) |
| Print the current error to stderr with a prefix. | |
| char const * | fr_perror_to_str (char const *line_sep, char const *fmt,...) |
| Print the stack of string buffers to a thread local buffer. | |
| char const * | fr_strerror (void) |
| Get the last library error. | |
| void | fr_strerror_clear (void) |
| Clears all pending messages from the talloc pools. | |
| static fr_log_buffer_t * | fr_strerror_init (void) |
| Initialise thread local storage. | |
| char const * | fr_strerror_marker (char const **subject, size_t *offset) |
| Get the last library error marker. | |
| char const * | fr_strerror_marker_peek (char const **subject, size_t *offset) |
| Get the last library error marker. | |
| char const * | fr_strerror_marker_pop (char const **subject, size_t *offset) |
| Pop the last library error with marker information. | |
| char const * | fr_strerror_peek (void) |
| Get the last library error. | |
| char const * | fr_strerror_pop (void) |
| Pop the last library error. | |
| static TALLOC_CTX * | pool_alt (fr_log_buffer_t *buffer) |
| static void | pool_alt_free_children (fr_log_buffer_t *buffer) |
| static fr_log_entry_t * | strerror_const (char const *file, int line, char const *msg) |
| Create an entry in the thread local logging stack using a const string, clearing all other entries. | |
| static fr_log_entry_t * | strerror_const_push (char const *file, int line, fr_log_buffer_t *buffer, char const *msg) |
| Add a message to an existing stack of messages. | |
| static fr_log_entry_t * | strerror_vprintf (char const *file, int line, char const *fmt, va_list ap) |
| Create an entry in the thread local logging stack, clearing all other entries. | |
| static fr_log_entry_t * | strerror_vprintf_push (char const *file, int line, fr_log_buffer_t *buffer, char const *fmt, va_list ap) |
| Add a message to an existing stack of messages. | |
Variables | |
| static _Thread_local fr_log_buffer_t * | fr_strerror_buffer |
| static _Thread_local bool | logging_stop |
| Due to ordering issues we may get errors being logged from within other thread local destructors which cause a crash on exit if the logging buffer has already been freed. | |
Support functions to allow libraries to provide errors to their callers.
Definition in file strerror.c.
| struct fr_log_buffer_t |
Holds data used by the logging stack.
pool_a and pool_b allow fr_strerror and fr_strerror_pop during a call to fr_strerror_printf or fr_strerror_printf_push.
Definition at line 50 of file strerror.c.
Collaboration diagram for fr_log_buffer_t:| Data Fields | ||
|---|---|---|
| fr_dlist_head_t | entries | |
| TALLOC_CTX * | pool | Current pool in use. |
| TALLOC_CTX * | pool_a | Pool to avoid memory allocations. |
| TALLOC_CTX * | pool_b | Pool to avoid memory allocations. |
| struct fr_log_entry_s |
Definition at line 34 of file strerror.c.
Collaboration diagram for fr_log_entry_s:| Data Fields | ||
|---|---|---|
| char const * | file | File where the error was created. |
| int | line | Line where the error occurred. |
| fr_dlist_t | list | |
| char const * | msg | Log message. |
| size_t | offset | Where to place the msg marker relative to the subject. |
| char const * | subject | Subject for error markers. |
| #define FR_STRERROR_BUFSIZE (2048) |
Definition at line 31 of file strerror.c.
| typedef struct fr_log_entry_s fr_log_entry_t |
Definition at line 33 of file strerror.c.
|
static |
Definition at line 68 of file strerror.c.
Here is the call graph for this function:
Here is the caller graph for this function:| void _fr_strerror_const | ( | char const * | file, |
| int | line, | ||
| char const * | msg | ||
| ) |
Log to thread local error buffer.
| [in] | file | the error occurred in. |
| [in] | line | the error occurred on. |
| [in] | msg | To add to error stack. Must have a lifetime equal to that of the program. |
Definition at line 449 of file strerror.c.
Here is the call graph for this function:| void _fr_strerror_const_push | ( | char const * | file, |
| int | line, | ||
| char const * | msg | ||
| ) |
Add a message to an existing stack of messages at the tail.
| [in] | file | the error occurred in. |
| [in] | line | the error occurred on. |
| [in] | msg | To add to error stack. Must have a lifetime equal to that of the program. |
Definition at line 507 of file strerror.c.
Here is the call graph for this function:| void _fr_strerror_const_push_head | ( | char const * | file, |
| int | line, | ||
| char const * | msg | ||
| ) |
Add a message to an existing stack of messages at the head.
| [in] | file | the error occurred in. |
| [in] | line | the error occurred on. |
| [in] | msg | To add to error stack. Must have a lifetime equal to that of the program. |
Definition at line 530 of file strerror.c.
Here is the call graph for this function:| void _fr_strerror_marker_vprintf | ( | char const * | file, |
| int | line, | ||
| char const * | subject, | ||
| size_t | offset, | ||
| char const * | fmt, | ||
| va_list | ap | ||
| ) |
Add an error marker to an existing stack of messages.
| [in] | file | the error occurred in. |
| [in] | line | the error occurred on. |
| [in] | subject | to mark up. |
| [in] | offset | Positive offset to show where the error should be positioned. |
| [in] | fmt | Error string. |
| [in] | ap | Arguments for the error string. |
Definition at line 319 of file strerror.c.
Here is the call graph for this function:| void _fr_strerror_marker_vprintf_push | ( | char const * | file, |
| int | line, | ||
| char const * | subject, | ||
| size_t | offset, | ||
| char const * | fmt, | ||
| va_list | ap | ||
| ) |
Add an error marker to an existing stack of messages at the tail.
| [in] | file | the error occurred in. |
| [in] | line | the error occurred on. |
| [in] | subject | to mark up. |
| [in] | offset | Positive offset to show where the error should be positioned. |
| [in] | fmt | Error string. |
| [in] | ap | Arguments for the error string. |
Definition at line 347 of file strerror.c.
Here is the call graph for this function:| void _fr_strerror_marker_vprintf_push_head | ( | char const * | file, |
| int | line, | ||
| char const * | subject, | ||
| size_t | offset, | ||
| char const * | fmt, | ||
| va_list | ap | ||
| ) |
Add an error marker to an existing stack of messages at the head.
| [in] | file | the error occurred in. |
| [in] | line | the error occurred on. |
| [in] | subject | to mark up. |
| [in] | offset | Positive offset to show where the error should be positioned. |
| [in] | fmt | Error string. |
| [in] | ap | Arguments for the error string. |
Definition at line 381 of file strerror.c.
Here is the call graph for this function:| void _fr_strerror_vprintf | ( | char const * | file, |
| int | line, | ||
| char const * | fmt, | ||
| va_list | ap | ||
| ) |
Log to thread local error buffer.
| [in] | file | the error occurred in. |
| [in] | line | the error occurred on. |
| [in] | fmt | printf style format string. If NULL clears any existing messages. |
| [in] | ap | Arguments for the format string. |
Definition at line 244 of file strerror.c.
Here is the call graph for this function:| void _fr_strerror_vprintf_push | ( | char const * | file, |
| int | line, | ||
| char const * | fmt, | ||
| va_list | ap | ||
| ) |
Add a message to an existing stack of messages at the tail.
| [in] | file | the error occurred in. |
| [in] | line | the error occurred on. |
| [in] | fmt | printf style format string. |
| [in] | ap | Arguments for the format string. |
Definition at line 262 of file strerror.c.
Here is the call graph for this function:| void _fr_strerror_vprintf_push_head | ( | char const * | file, |
| int | line, | ||
| char const * | fmt, | ||
| va_list | ap | ||
| ) |
Add a message to an existing stack of messages at the head.
| [in] | file | the error occurred in. |
| [in] | line | the error occurred on. |
| [in] | fmt | printf style format string. |
| [in] | ap | Arguments for the format string. |
Definition at line 289 of file strerror.c.
Here is the call graph for this function:| void fr_perror | ( | char const * | fmt, |
| ... | |||
| ) |
Print the current error to stderr with a prefix.
Used by utility functions lacking their own logging infrastructure
Definition at line 732 of file strerror.c.
Here is the call graph for this function:| char const * fr_perror_to_str | ( | char const * | line_sep, |
| char const * | fmt, | ||
| ... | |||
| ) |
Print the stack of string buffers to a thread local buffer.
Used by utility functions lacking their own logging infrastructure
| [in] | line_sep | to insert between the log lines. |
| [in] | fmt | to prefix all log messages with. |
Definition at line 778 of file strerror.c.
Here is the call graph for this function:| char const * fr_strerror | ( | void | ) |
Get the last library error.
Will only return the last library error once, after which it will return a zero length string. If there are additional messages on the log stack they will be discarded.
Definition at line 553 of file strerror.c.
Here is the call graph for this function:| void fr_strerror_clear | ( | void | ) |
Clears all pending messages from the talloc pools.
Definition at line 576 of file strerror.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Initialise thread local storage.
Definition at line 87 of file strerror.c.
Here is the call graph for this function:
Here is the caller graph for this function:| char const * fr_strerror_marker | ( | char const ** | subject, |
| size_t * | offset | ||
| ) |
Get the last library error marker.
| [out] | subject | The subject string the error relates to. |
| [out] | offset | Where to place the marker. |
Definition at line 597 of file strerror.c.
Here is the call graph for this function:| char const * fr_strerror_marker_peek | ( | char const ** | subject, |
| size_t * | offset | ||
| ) |
Get the last library error marker.
| [out] | subject | The subject string the error relates to. |
| [out] | offset | Where to place the marker. |
Definition at line 650 of file strerror.c.
Here is the call graph for this function:| char const * fr_strerror_marker_pop | ( | char const ** | subject, |
| size_t * | offset | ||
| ) |
Pop the last library error with marker information.
Return the first message added to the error stack using fr_strerror_printf or fr_strerror_printf_push.
Definition at line 707 of file strerror.c.
Here is the call graph for this function:| char const * fr_strerror_peek | ( | void | ) |
Get the last library error.
Definition at line 626 of file strerror.c.
Here is the call graph for this function:| char const * fr_strerror_pop | ( | void | ) |
Pop the last library error.
Return the first message added to the error stack using fr_strerror_printf or fr_strerror_printf_push.
Definition at line 680 of file strerror.c.
Here is the call graph for this function:
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Create an entry in the thread local logging stack using a const string, clearing all other entries.
Definition at line 407 of file strerror.c.
Here is the call graph for this function:
|
inlinestatic |
Add a message to an existing stack of messages.
| [in] | file | the error occurred in. |
| [in] | line | the error occurred on. |
| [in] | buffer | to add the message to. |
| [in] | msg | To add to error stack. Must have a lifetime equal to that of the program. |
Definition at line 464 of file strerror.c.
Here is the call graph for this function:
|
static |
Create an entry in the thread local logging stack, clearing all other entries.
Definition at line 148 of file strerror.c.
Here is the call graph for this function:
|
static |
Add a message to an existing stack of messages.
| [in] | file | the error occurred in. |
| [in] | line | the error occurred on. |
| [in] | buffer | The log buffer to allocate memory from. |
| [in] | fmt | printf style format string. |
| [in] | ap | Arguments for the error string. |
Definition at line 200 of file strerror.c.
Here is the call graph for this function:
|
static |
Definition at line 58 of file strerror.c.
|
static |
Due to ordering issues we may get errors being logged from within other thread local destructors which cause a crash on exit if the logging buffer has already been freed.
Definition at line 59 of file strerror.c.
1.9.8