The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Macros | Functions | Variables
syserror.c File Reference

Support functions to allow libraries to get system errors in a threadsafe and easily debuggable way. More...

#include <freeradius-devel/util/log.h>
#include <freeradius-devel/util/strerror.h>
#include <freeradius-devel/util/syserror.h>
#include <freeradius-devel/util/atexit.h>
+ Include dependency graph for syserror.c:

Go to the source code of this file.

Macros

#define FR_SYSERROR_BUFSIZE   (2048)
 
#define HAVE_DEFINITION(_errno)   ((_errno) < (int)(NUM_ELEMENTS(fr_syserror_macro_names)))
 

Functions

static int _fr_logging_free (UNUSED void *arg)
 
static ssize_t _fr_syserror (int num, char *buffer, size_t buff_len)
 
static char * _fr_syserror_buffer (void)
 
char const * fr_syserror (int num)
 Guaranteed to be thread-safe version of strerror. More...
 
char const * fr_syserror_simple (int num)
 Guaranteed to be thread-safe version of strerror. More...
 

Variables

static _Thread_local char * fr_syserror_buffer
 
static char const * fr_syserror_macro_names []
 POSIX-2008 errno macros. More...
 
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. More...
 

Detailed Description

Support functions to allow libraries to get system errors in a threadsafe and easily debuggable way.

Definition in file syserror.c.

Macro Definition Documentation

◆ FR_SYSERROR_BUFSIZE

#define FR_SYSERROR_BUFSIZE   (2048)

Definition at line 32 of file syserror.c.

◆ HAVE_DEFINITION

#define HAVE_DEFINITION (   _errno)    ((_errno) < (int)(NUM_ELEMENTS(fr_syserror_macro_names)))

Definition at line 40 of file syserror.c.

Function Documentation

◆ _fr_logging_free()

static int _fr_logging_free ( UNUSED void *  arg)
static

Definition at line 46 of file syserror.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _fr_syserror()

static ssize_t _fr_syserror ( int  num,
char *  buffer,
size_t  buff_len 
)
inlinestatic

Definition at line 163 of file syserror.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _fr_syserror_buffer()

static char* _fr_syserror_buffer ( void  )
inlinestatic

Definition at line 220 of file syserror.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_syserror()

char const* fr_syserror ( int  num)

Guaranteed to be thread-safe version of strerror.

Parameters
numerrno as returned by function or from global errno.
Returns
Error string relating to errno, with the macro name added as a prefix.

Definition at line 243 of file syserror.c.

+ Here is the call graph for this function:

◆ fr_syserror_simple()

char const* fr_syserror_simple ( int  num)

Guaranteed to be thread-safe version of strerror.

Parameters
numerrno as returned by function or from global errno.
Returns
Error string relating to errno with no decoration.

Definition at line 291 of file syserror.c.

+ Here is the call graph for this function:

Variable Documentation

◆ fr_syserror_buffer

_Thread_local char* fr_syserror_buffer
static

Definition at line 34 of file syserror.c.

◆ fr_syserror_macro_names

char const* fr_syserror_macro_names[]
static

POSIX-2008 errno macros.

Non-POSIX macros may be added, but you must check they're defined.

Definition at line 58 of file syserror.c.

◆ logging_stop

_Thread_local bool logging_stop
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 35 of file syserror.c.