All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Typedefs | Functions
exfile.h File Reference

API for managing concurrent file access. More...

Go to the source code of this file.

Typedefs

typedef struct exfile_t exfile_t
 

Functions

int exfile_close (exfile_t *lf, int fd)
 Close the log file. More...
 
exfile_texfile_init (TALLOC_CTX *ctx, uint32_t entries, uint32_t idle, bool locking)
 Initialize a way for multiple threads to log to one or more files. More...
 
int exfile_open (exfile_t *lf, char const *filename, mode_t permissions, bool append)
 Open a new log file, or maybe an existing one. More...
 
int exfile_unlock (exfile_t *lf, int fd)
 

Detailed Description

API for managing concurrent file access.

Id:
f820f161d115600712077517c92adf3ffcb90099

Definition in file exfile.h.

Typedef Documentation

typedef struct exfile_t exfile_t

Definition at line 36 of file exfile.h.

Function Documentation

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
efThe logfile context returned from exfile_init.
fdthe FD to close (i.e. return to the pool).
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 356 of file exfile.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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
ctxThe talloc context
max_entriesMax file descriptors to cache, and manage locks for.
max_idleMaximum time a file descriptor can be idle before it's closed.
lockingwhether or not to lock the files.
Returns
  • new context.
  • NULL on error.

Definition at line 100 of file exfile.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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
efThe logfile context returned from exfile_init().
filenamethe file to open.
permissionsto use.
appendIf 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.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int exfile_unlock ( exfile_t lf,
int  fd 
)

Definition at line 382 of file exfile.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function: