#include <freeradius-devel/radiusd.h>
#include <freeradius-devel/exfile.h>
#include <sys/stat.h>
#include <fcntl.h>
Go to the source code of this file.
Definition at line 32 of file exfile.c.
Data Fields |
int |
dup |
|
int |
fd |
File descriptor associated with an entry. |
char * |
filename |
Filename. |
uint32_t |
hash |
Hash for cheap comparison. |
time_t |
last_used |
Last time the entry was used. |
Definition at line 41 of file exfile.c.
Data Fields |
exfile_entry_t * |
entries |
|
bool |
locking |
|
uint32_t |
max_entries |
How many file descriptors we keep track of. |
uint32_t |
max_idle |
Maximum idle time for a descriptor. |
How many times we attempt to acquire a lock.
before giving up.
Definition at line 65 of file exfile.c.
#define PTHREAD_MUTEX_LOCK |
( |
|
_x | ) |
|
#define PTHREAD_MUTEX_UNLOCK |
( |
|
_x | ) |
|
static int _exfile_free |
( |
exfile_t * |
ef | ) |
|
|
static |
int exfile_close |
( |
exfile_t * |
ef, |
|
|
int |
fd |
|
) |
| |
Close the log file.
Really just return it to the pool.
When multithreaded, the FD is locked via a mutex. This way we're sure that no other thread is writing to the file. This function will unlock the mutex, so that other threads can write to the file.
- Parameters
-
ef | The logfile context returned from exfile_init. |
fd | the FD to close (i.e. return to the pool). |
- Returns
- 0 on success.
- -1 on failure.
Definition at line 356 of file exfile.c.
exfile_t* exfile_init |
( |
TALLOC_CTX * |
ctx, |
|
|
uint32_t |
max_entries, |
|
|
uint32_t |
max_idle, |
|
|
bool |
locking |
|
) |
| |
Initialize a way for multiple threads to log to one or more files.
- Parameters
-
ctx | The talloc context |
max_entries | Max file descriptors to cache, and manage locks for. |
max_idle | Maximum time a file descriptor can be idle before it's closed. |
locking | whether or not to lock the files. |
- Returns
- new context.
- NULL on error.
Definition at line 100 of file exfile.c.
int exfile_open |
( |
exfile_t * |
ef, |
|
|
char const * |
filename, |
|
|
mode_t |
permissions, |
|
|
bool |
append |
|
) |
| |
Open a new log file, or maybe an existing one.
When multithreaded, the FD is locked via a mutex. This way we're sure that no other thread is writing to the file.
- Parameters
-
ef | The logfile context returned from exfile_init(). |
filename | the file to open. |
permissions | to use. |
append | If true seek to the end of the file. |
- Returns
- FD used to write to the file.
- -1 on failure.
Definition at line 142 of file exfile.c.
int exfile_unlock |
( |
exfile_t * |
ef, |
|
|
int |
fd |
|
) |
| |