Lumiera  0.pre.03
»edityourfreedom«
filehandlecache.c File Reference

Go to the source code of this file.

Description

Implementation of caching for filehandle representation data.

Todo:
development in this area is stalled since 2010

Definition in file filehandlecache.c.

#include "include/logging.h"
#include "lib/safeclib.h"
#include "backend/file.h"
#include "backend/filehandlecache.h"

Functions

 LUMIERA_ERROR_DEFINE (FILEHANDLECACHE_NOHANDLE, "No filehandle available")
 
void lumiera_filehandlecache_checkin (LumieraFilehandle handle)
 Put a filehandle into the cache Filehandles which are checked in are subject of cache aging and might get destroyed and reused. More...
 
LumieraFilehandle lumiera_filehandlecache_checkout (LumieraFilehandle handle)
 Remove a filehandle from cache aging Filehandles which are subject of cache aging must be checked out before they can be used. More...
 
void lumiera_filehandlecache_delete (void)
 Delete the filehandle cache. More...
 
LumieraFilehandle lumiera_filehandlecache_handle_acquire (LumieraFiledescriptor desc)
 Get a fresh filehandle. More...
 
void lumiera_filehandlecache_new (int max_entries)
 Initialises the filehandle cache. More...
 

Variables

LumieraFilehandlecache lumiera_fhcache
 the global cache for file handles. More...
 

Function Documentation

◆ LUMIERA_ERROR_DEFINE()

LUMIERA_ERROR_DEFINE ( FILEHANDLECACHE_NOHANDLE  ,
"No filehandle available"   
)

◆ lumiera_filehandlecache_new()

void lumiera_filehandlecache_new ( int  max_entries)

Initialises the filehandle cache.

Parameters
max_entriesnumber how much filehandles shall be managed The number of elements the cache can hold is static and should be determined by sysconf (_SC_OPEN_MAX) minus some (big) safety margin.

Definition at line 49 of file filehandlecache.c.

References lumiera_fhcache, lumiera_filehandle_destroy_node(), lumiera_malloc(), lumiera_mrucache_init(), and lumiera_mutex_init().

Referenced by lumiera_backend_init().

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

◆ lumiera_filehandlecache_delete()

void lumiera_filehandlecache_delete ( void  )

Delete the filehandle cache.

No filehandles in the cache must be locked, this would be a fatal error. The handles are closed automatically.

Definition at line 62 of file filehandlecache.c.

References lumiera_fhcache, lumiera_free(), lumiera_mrucache_destroy(), lumiera_mutex_destroy(), and NULL.

Referenced by lumiera_backend_destroy().

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

◆ lumiera_filehandlecache_handle_acquire()

LumieraFilehandle lumiera_filehandlecache_handle_acquire ( LumieraFiledescriptor  desc)

Get a fresh filehandle.

Parameters
selfpointer to the cache
Returns
the new filehandle

Definition at line 76 of file filehandlecache.c.

References LUMIERA_ERROR_SET_ALERT, lumiera_fhcache, lumiera_filedescriptor_name(), lumiera_filehandle_init(), lumiera_filehandle_new(), lumiera_mrucache_age(), lumiera_mrucache_pop(), LUMIERA_MUTEX_SECTION, NULL, and TRACE().

Referenced by lumiera_filedescriptor_handle_acquire().

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

◆ lumiera_filehandlecache_checkout()

LumieraFilehandle lumiera_filehandlecache_checkout ( LumieraFilehandle  handle)

Remove a filehandle from cache aging Filehandles which are subject of cache aging must be checked out before they can be used.

Parameters
selfthe filehandlecache
handlethe filehandle to be checked out

Definition at line 111 of file filehandlecache.c.

References lumiera_fhcache, lumiera_mrucache_checkout(), LUMIERA_MUTEX_SECTION, and TRACE().

Referenced by lumiera_filedescriptor_delete(), and lumiera_filedescriptor_handle_acquire().

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

◆ lumiera_filehandlecache_checkin()

void lumiera_filehandlecache_checkin ( LumieraFilehandle  handle)

Put a filehandle into the cache Filehandles which are checked in are subject of cache aging and might get destroyed and reused.

Parameters
handlethe filehandle to be checked in

Definition at line 132 of file filehandlecache.c.

References lumiera_fhcache, lumiera_mrucache_checkin(), LUMIERA_MUTEX_SECTION, and TRACE().

Referenced by lumiera_filedescriptor_delete(), and lumiera_filedescriptor_handle_release().

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

Variable Documentation

◆ lumiera_fhcache