WIP: deploy new logging flags in backend

This commit is contained in:
Christian Thaeter 2009-01-24 03:12:32 +01:00
parent 16ebdd65b1
commit 65142d9cae
15 changed files with 131 additions and 118 deletions

View file

@ -19,6 +19,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "common/logging.h"
#include "lib/safeclib.h"
#include "backend/backend.h"
@ -31,20 +32,20 @@
#include <sys/resource.h>
//NOBUG_DEFINE_FLAG_PARENT (backend, lumiera); TODO
NOBUG_DEFINE_FLAG (backend);
NOBUG_DEFINE_FLAG_PARENT (file_all, backend);
NOBUG_DEFINE_FLAG_PARENT (filehandle, file_all);
//NOBUG_DEFINE_FLAG (backend);
//NOBUG_DEFINE_FLAG_PARENT (file_all, backend);
//NOBUG_DEFINE_FLAG_PARENT (filehandle, file_all);
NOBUG_DEFINE_FLAG_PARENT (mmapings, mmap_all);
//NOBUG_DEFINE_FLAG_PARENT (mmapings, mmap_all);
NOBUG_DECLARE_FLAG (file);
//NOBUG_DECLARE_FLAG (file);
NOBUG_DECLARE_FLAG (mmap_all);
NOBUG_DECLARE_FLAG (mmap);
NOBUG_DECLARE_FLAG (mmapings);
NOBUG_DECLARE_FLAG (mmapcache);
//NOBUG_DECLARE_FLAG (mmap_all);
//NOBUG_DECLARE_FLAG (mmap);
//NOBUG_DECLARE_FLAG (mmapings);
//NOBUG_DECLARE_FLAG (mmapcache);
size_t lumiera_backend_pagesize;
@ -52,16 +53,16 @@ size_t lumiera_backend_pagesize;
int
lumiera_backend_init (void)
{
NOBUG_INIT_FLAG (backend);
NOBUG_INIT_FLAG (file_all);
NOBUG_INIT_FLAG (file);
NOBUG_INIT_FLAG (filehandle);
NOBUG_INIT_FLAG (mmap_all);
NOBUG_INIT_FLAG (mmap);
NOBUG_INIT_FLAG (mmapings);
NOBUG_INIT_FLAG (mmapcache);
//NOBUG_INIT_FLAG (backend);
//NOBUG_INIT_FLAG (file_all);
//NOBUG_INIT_FLAG (file);
//NOBUG_INIT_FLAG (filehandle);
//NOBUG_INIT_FLAG (mmap_all);
//NOBUG_INIT_FLAG (mmap);
//NOBUG_INIT_FLAG (mmapings);
//NOBUG_INIT_FLAG (mmapcache);
TRACE (backend);
TRACE (backend_dbg);
lumiera_filedescriptor_registry_init ();
lumiera_backend_pagesize = sysconf(_SC_PAGESIZE);
@ -107,7 +108,7 @@ lumiera_backend_init (void)
void
lumiera_backend_destroy (void)
{
TRACE (backend);
TRACE (backend_dbg);
lumiera_mmapcache_delete ();
lumiera_filehandlecache_delete ();
lumiera_filedescriptor_registry_destroy ();

View file

@ -23,7 +23,7 @@
#include <nobug.h>
NOBUG_DECLARE_FLAG (backend);
//NOBUG_DECLARE_FLAG (backend);
extern size_t lumiera_backend_pagesize;

View file

@ -19,6 +19,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "common/logging.h"
#include "lib/mutex.h"
#include "lib/safeclib.h"
@ -28,7 +29,7 @@
#include <limits.h>
#include <unistd.h>
NOBUG_DEFINE_FLAG_PARENT (file, file_all);
//NOBUG_DEFINE_FLAG_PARENT (file, file_all);
LUMIERA_ERROR_DEFINE (FILE_CHANGED, "File changed unexpected");
LUMIERA_ERROR_DEFINE (FILE_NOCHUNKSIZE, "Chunksize not set");
@ -37,7 +38,7 @@ LUMIERA_ERROR_DEFINE (FILE_NOCHUNKSIZE, "Chunksize not set");
LumieraFile
lumiera_file_init (LumieraFile self, const char* name, int flags)
{
TRACE (file);
TRACE (file_dbg);
if (self)
{
@ -55,7 +56,7 @@ lumiera_file_init (LumieraFile self, const char* name, int flags)
LumieraFile
lumiera_file_destroy (LumieraFile self)
{
TRACE (file);
TRACE (file_dbg);
lumiera_filedescriptor_release (self->descriptor, self->name, &self->node);
lumiera_free (self->name);
@ -66,7 +67,9 @@ lumiera_file_destroy (LumieraFile self)
LumieraFile
lumiera_file_new (const char* name, int flags)
{
TRACE (file);
TRACE (file_dbg);
TRACE (file, "opening file '%s' with flags '%x'", name, flags);
LumieraFile self = lumiera_malloc (sizeof (lumiera_file));
if (!lumiera_file_init (self, name, flags))
{
@ -80,7 +83,8 @@ lumiera_file_new (const char* name, int flags)
void
lumiera_file_delete (LumieraFile self)
{
TRACE (file);
TRACE (file_dbg);
TRACE (file, "close file '%s'", self->name);
lumiera_free (lumiera_file_destroy (self));
}
@ -88,7 +92,7 @@ lumiera_file_delete (LumieraFile self)
int
lumiera_file_handle_acquire (LumieraFile self)
{
TRACE (file);
TRACE (file_dbg);
REQUIRE (self);
REQUIRE (self->descriptor);
REQUIRE (lumiera_fhcache);
@ -100,7 +104,7 @@ lumiera_file_handle_acquire (LumieraFile self)
void
lumiera_file_handle_release (LumieraFile self)
{
TRACE (file);
TRACE (file_dbg);
REQUIRE (self);
REQUIRE (self->descriptor);
REQUIRE (lumiera_fhcache);

View file

@ -27,7 +27,7 @@
#include "lib/llist.h"
#include "lib/error.h"
NOBUG_DECLARE_FLAG (file);
//NOBUG_DECLARE_FLAG (file);
LUMIERA_ERROR_DECLARE(FILE_CHANGED);
LUMIERA_ERROR_DECLARE(FILE_NOCHUNKSIZE);

View file

@ -19,6 +19,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "common/logging.h"
#include "lib/mutex.h"
#include "lib/safeclib.h"
@ -34,7 +35,7 @@
#include <errno.h>
NOBUG_DEFINE_FLAG_PARENT (filedescriptor, file_all);
//NOBUG_DEFINE_FLAG_PARENT (filedescriptor, file_all);
/*
Filedescriptor registry
@ -89,24 +90,24 @@ key_fn (const PSplaynode node)
void
lumiera_filedescriptor_registry_init (void)
{
NOBUG_INIT_FLAG (filedescriptor);
TRACE (filedescriptor);
//NOBUG_INIT_FLAG (filedescriptor);
TRACE (filedescriptor_dbg);
REQUIRE (!registry);
registry = psplay_new (cmp_fn, key_fn, delete_fn);
if (!registry)
LUMIERA_DIE (NO_MEMORY);
lumiera_mutex_init (&registry_mutex, "filedescriptor_registry", &NOBUG_FLAG (filedescriptor));
lumiera_mutex_init (&registry_mutex, "filedescriptor_registry", &NOBUG_FLAG (mutex_dbg));
}
void
lumiera_filedescriptor_registry_destroy (void)
{
TRACE (filedescriptor);
TRACE (filedescriptor_dbg);
REQUIRE (!psplay_nelements (registry));
lumiera_mutex_destroy (&registry_mutex, &NOBUG_FLAG (filedescriptor));
lumiera_mutex_destroy (&registry_mutex, &NOBUG_FLAG (mutex_dbg));
if (registry)
psplay_destroy (registry);
@ -117,13 +118,13 @@ lumiera_filedescriptor_registry_destroy (void)
LumieraFiledescriptor
lumiera_filedescriptor_acquire (const char* name, int flags, LList filenode)
{
TRACE (filedescriptor, "%s", name);
TRACE (filedescriptor_dbg, "%s", name);
REQUIRE (registry, "not initialized");
REQUIRE (llist_is_empty (filenode));
LumieraFiledescriptor dest = NULL;
LUMIERA_MUTEX_SECTION (filedescriptor, &registry_mutex)
LUMIERA_MUTEX_SECTION (mutex_sync, &registry_mutex)
{
lumiera_filedescriptor fdesc;
fdesc.flags = flags;
@ -138,28 +139,28 @@ lumiera_filedescriptor_acquire (const char* name, int flags, LList filenode)
while ((slash = strchr (slash+1, '/')))
{
*slash = '\0';
INFO (filedescriptor, "try creating dir: %s", dir);
INFO (filedescriptor_dbg, "try creating dir: %s", dir);
if (mkdir (dir, 0777) == -1 && errno != EEXIST)
{
LUMIERA_ERROR_SET_CRITICAL (filedescriptor, ERRNO, name);
LUMIERA_ERROR_SET_CRITICAL (file, ERRNO, name);
goto error;
}
*slash = '/';
}
int fd;
INFO (filedescriptor, "try creating file: %s", name);
INFO (filedescriptor_dbg, "try creating file: %s", name);
TODO ("creat mode from config");
fd = creat (name, 0666);
if (fd == -1)
{
LUMIERA_ERROR_SET_CRITICAL (filedescriptor, ERRNO, name);
LUMIERA_ERROR_SET_CRITICAL (file, ERRNO, name);
goto error;
}
close (fd);
if (stat (name, &fdesc.stat) != 0)
{
/* finally, no luck */
LUMIERA_ERROR_SET_CRITICAL (filedescriptor, ERRNO, name);
LUMIERA_ERROR_SET_CRITICAL (file, ERRNO, name);
goto error;
}
}
@ -188,10 +189,10 @@ lumiera_filedescriptor_acquire (const char* name, int flags, LList filenode)
void
lumiera_filedescriptor_release (LumieraFiledescriptor self, const char* name, LList filenode)
{
TRACE (filedescriptor);
TRACE (filedescriptor_dbg);
if (filenode)
LUMIERA_MUTEX_SECTION (filedescriptor, &self->lock)
LUMIERA_MUTEX_SECTION (mutex_sync, &self->lock)
{
REQUIRE (llist_is_member (&self->files, filenode));
llist_unlink (filenode);
@ -205,11 +206,11 @@ lumiera_filedescriptor_release (LumieraFiledescriptor self, const char* name, LL
int
lumiera_filedescriptor_handle_acquire (LumieraFiledescriptor self)
{
TRACE (filedescriptor);
TRACE (filedescriptor_dbg);
int fd = -1;
LUMIERA_MUTEX_SECTION (filedescriptor, &self->lock)
LUMIERA_MUTEX_SECTION (mutex_sync, &self->lock)
{
if (!self->handle)
/* no handle yet, get a new one */
@ -227,10 +228,10 @@ lumiera_filedescriptor_handle_acquire (LumieraFiledescriptor self)
void
lumiera_filedescriptor_handle_release (LumieraFiledescriptor self)
{
TRACE (filedescriptor);
TRACE (filedescriptor_dbg);
REQUIRE (self->handle);
LUMIERA_MUTEX_SECTION (filedescriptor, &self->lock)
LUMIERA_MUTEX_SECTION (mutex_sync, &self->lock)
lumiera_filehandlecache_checkin (lumiera_fhcache, self->handle);
}
@ -265,7 +266,7 @@ LumieraFiledescriptor
lumiera_filedescriptor_new (LumieraFiledescriptor template)
{
LumieraFiledescriptor self = lumiera_malloc (sizeof (lumiera_filedescriptor));
TRACE (filedescriptor, "at %p", self);
TRACE (filedescriptor_dbg, "at %p", self);
psplaynode_init (&self->node);
self->stat = template->stat;
@ -276,7 +277,7 @@ lumiera_filedescriptor_new (LumieraFiledescriptor template)
self->mmapings = NULL;
llist_init (&self->files);
lumiera_mutex_init (&self->lock, "filedescriptor", &NOBUG_FLAG (filedescriptor));
lumiera_mutex_init (&self->lock, "filedescriptor", &NOBUG_FLAG (mutex_dbg));
return self;
}
@ -285,9 +286,9 @@ lumiera_filedescriptor_new (LumieraFiledescriptor template)
void
lumiera_filedescriptor_delete (LumieraFiledescriptor self, const char* name)
{
TRACE (filedescriptor, "%p %s", self, name);
TRACE (filedescriptor_dbg, "%p %s", self, name);
LUMIERA_MUTEX_SECTION (filedescriptor, &registry_mutex)
LUMIERA_MUTEX_SECTION (mutex_sync, &registry_mutex)
{
REQUIRE (llist_is_empty (&self->files));
@ -297,7 +298,7 @@ lumiera_filedescriptor_delete (LumieraFiledescriptor self, const char* name)
if (self->handle && name && ((self->flags & O_RDWR) == O_RDWR))
{
TRACE (filedescriptor, "truncate %s to %lld", name, self->realsize);
TRACE (filedescriptor_dbg, "truncate %s to %lld", name, self->realsize);
lumiera_filehandlecache_checkout (lumiera_fhcache, self->handle);
int dummy = ftruncate (lumiera_filehandle_handle (self->handle), self->realsize);
(void) dummy; /* this is present to silence a warning */
@ -309,7 +310,7 @@ lumiera_filedescriptor_delete (LumieraFiledescriptor self, const char* name)
TODO ("release filehandle");
lumiera_mutex_destroy (&self->lock, &NOBUG_FLAG (filedescriptor));
lumiera_mutex_destroy (&self->lock, &NOBUG_FLAG (mutex_dbg));
lumiera_free (self);
}
}

View file

@ -19,6 +19,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "common/logging.h"
#include "lib/llist.h"
#include "lib/safeclib.h"
@ -31,7 +32,7 @@
LumieraFilehandle
lumiera_filehandle_init (LumieraFilehandle self, LumieraFiledescriptor desc)
{
TRACE (filehandle, "%p", self);
TRACE (filehandle_dbg, "%p", self);
if (self)
{
llist_init (&self->cachenode);
@ -54,7 +55,7 @@ lumiera_filehandle_new (LumieraFiledescriptor desc)
void*
lumiera_filehandle_destroy_node (LList node)
{
TRACE (filehandle);
TRACE (filehandle_dbg);
REQUIRE (llist_is_empty (node));
LumieraFilehandle self = (LumieraFilehandle)node;
REQUIRE (self->use_cnt == 0);
@ -76,7 +77,7 @@ lumiera_filehandle_get (LumieraFilehandle self)
int
lumiera_filehandle_handle (LumieraFilehandle self)
{
TRACE (filehandle);
TRACE (filehandle_dbg);
int fd = -1;
if (self->fd == -1)
@ -85,7 +86,7 @@ lumiera_filehandle_handle (LumieraFilehandle self)
if (fd == -1)
{
FIXME ("Handle EMFILE etc with the resourcecollector");
LUMIERA_ERROR_SET_CRITICAL (filehandle, ERRNO, lumiera_filedescriptor_name (self->descriptor));
LUMIERA_ERROR_SET_CRITICAL (file, ERRNO, lumiera_filedescriptor_name (self->descriptor));
}
else
{
@ -94,14 +95,14 @@ lumiera_filehandle_handle (LumieraFilehandle self)
{
close (fd);
fd = -1;
LUMIERA_ERROR_SET_CRITICAL (filehandle, ERRNO, lumiera_filedescriptor_name (self->descriptor));
LUMIERA_ERROR_SET_CRITICAL (file, ERRNO, lumiera_filedescriptor_name (self->descriptor));
}
else if (!lumiera_filedescriptor_samestat (self->descriptor, &st))
{
close (fd);
fd = -1;
/* Woops this is not the file we expected to use */
LUMIERA_ERROR_SET_CRITICAL (filehandle, FILE_CHANGED, lumiera_filedescriptor_name (self->descriptor));
LUMIERA_ERROR_SET_CRITICAL (file, FILE_CHANGED, lumiera_filedescriptor_name (self->descriptor));
}
}
self->fd = fd;

View file

@ -29,7 +29,7 @@ typedef lumiera_filehandle* LumieraFilehandle;
#include "backend/filedescriptor.h"
NOBUG_DECLARE_FLAG (filehandle);
//NOBUG_DECLARE_FLAG (filehandle);
/**
* @file

View file

@ -19,12 +19,13 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "common/logging.h"
#include "lib/safeclib.h"
#include "backend/file.h"
#include "backend/filehandlecache.h"
NOBUG_DEFINE_FLAG_PARENT (filehandlecache, file_all);
//NOBUG_DEFINE_FLAG_PARENT (filehandlecache, file_all);
/* errors */
@ -39,12 +40,12 @@ lumiera_filehandlecache_new (int max_entries)
{
REQUIRE (!lumiera_fhcache, "Filehandlecache already initialized");
NOBUG_INIT_FLAG (filehandlecache);
//NOBUG_INIT_FLAG (filehandlecache);
lumiera_fhcache = lumiera_malloc (sizeof (lumiera_filehandlecache));
lumiera_mrucache_init (&lumiera_fhcache->cache, lumiera_filehandle_destroy_node);
lumiera_fhcache->available = max_entries;
lumiera_fhcache->checked_out = 0;
lumiera_mutex_init (&lumiera_fhcache->lock, "filehandlecache", &NOBUG_FLAG (filehandlecache));
lumiera_mutex_init (&lumiera_fhcache->lock, "filehandlecache", &NOBUG_FLAG (mutex_dbg));
}
@ -55,7 +56,7 @@ lumiera_filehandlecache_delete (void)
{
REQUIRE (!lumiera_fhcache->checked_out, "Filehandles in use at shutdown");
lumiera_mrucache_destroy (&lumiera_fhcache->cache);
lumiera_mutex_destroy (&lumiera_fhcache->lock, &NOBUG_FLAG (filehandlecache));
lumiera_mutex_destroy (&lumiera_fhcache->lock, &NOBUG_FLAG (mutex_dbg));
lumiera_free (lumiera_fhcache);
lumiera_fhcache = NULL;
}
@ -65,10 +66,10 @@ lumiera_filehandlecache_delete (void)
LumieraFilehandle
lumiera_filehandlecache_handle_acquire (LumieraFilehandlecache self, LumieraFiledescriptor desc)
{
TRACE (filehandlecache);
TRACE (filehandlecache_dbg);
LumieraFilehandle ret = NULL;
LUMIERA_MUTEX_SECTION (filehandlecache, &self->lock)
LUMIERA_MUTEX_SECTION (mutex_sync, &self->lock)
{
if (self->available <= 0 && self->cache.cached)
{
@ -82,11 +83,11 @@ lumiera_filehandlecache_handle_acquire (LumieraFilehandlecache self, LumieraFile
else
{
/* allocate new filehandle if we are below the limit or no cached handles are available (overallocating) */
NOTICE (filehandlecache, "overallocating filehandle");
NOTICE (file, "overallocating filehandle");
ret = lumiera_filehandle_new (desc);
TODO ("use resourcecollector here");
if (!ret)
LUMIERA_ERROR_SET_ALERT (filehandlecache, FILEHANDLECACHE_NOHANDLE, lumiera_filedescriptor_name (desc));
LUMIERA_ERROR_SET_ALERT (file, FILEHANDLECACHE_NOHANDLE, lumiera_filedescriptor_name (desc));
else
--self->available;
}
@ -106,7 +107,7 @@ lumiera_filehandlecache_checkout (LumieraFilehandlecache self, LumieraFilehandle
if (!handle->use_cnt)
{
/* lock cache and checkout */
LUMIERA_MUTEX_SECTION (filehandlecache, &self->lock)
LUMIERA_MUTEX_SECTION (mutex_sync, &self->lock)
{
lumiera_mrucache_checkout (&self->cache, &handle->cachenode);
}
@ -129,7 +130,7 @@ lumiera_filehandlecache_checkin (LumieraFilehandlecache self, LumieraFilehandle
if (!--handle->use_cnt)
{
/* lock cache and checin */
LUMIERA_MUTEX_SECTION (filehandlecache, &self->lock)
LUMIERA_MUTEX_SECTION (mutex_sync, &self->lock)
{
--self->checked_out;
lumiera_mrucache_checkin (&self->cache, &handle->cachenode);

View file

@ -19,6 +19,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "common/logging.h"
#include "lib/safeclib.h"
#include "backend/mmap.h"
@ -34,8 +35,8 @@
*
*/
NOBUG_DEFINE_FLAG_PARENT (mmap_all, backend);
NOBUG_DEFINE_FLAG_PARENT (mmap, mmap_all);
//NOBUG_DEFINE_FLAG_PARENT (mmap_all, backend);
//NOBUG_DEFINE_FLAG_PARENT (mmap, mmap_all);
LUMIERA_ERROR_DEFINE (MMAP_NWRITE, "Backing file not writable");
@ -51,7 +52,7 @@ LUMIERA_ERROR_DEFINE (MMAP_SPACE, "Address space exhausted");
LumieraMMap
lumiera_mmap_init (LumieraMMap self, LumieraFile file, off_t start, size_t size)
{
TRACE (mmap);
TRACE (mmap_dbg);
REQUIRE (self);
REQUIRE (file);
@ -80,7 +81,7 @@ lumiera_mmap_init (LumieraMMap self, LumieraFile file, off_t start, size_t size)
LumieraFiledescriptor descriptor = file->descriptor;
int fd = lumiera_file_handle_acquire (file);
TRACE (mmap, "got fd %d", fd);
TRACE (mmap_dbg, "got fd %d", fd);
if (fd == -1)
goto efile;
@ -128,7 +129,7 @@ lumiera_mmap_init (LumieraMMap self, LumieraFile file, off_t start, size_t size)
switch (strategy++)
{
case FIRST_TRY:
TRACE (mmap, "FIRST_TRY");
TRACE (mmap_dbg, "FIRST_TRY");
/* align begin and end to chunk boundaries */
begin = start & ~(chunksize-1);
length = ((start+size+chunksize-1) & ~(chunksize-1)) - begin;
@ -159,17 +160,17 @@ lumiera_mmap_init (LumieraMMap self, LumieraFile file, off_t start, size_t size)
break;
case DROP_FROM_CACHE:
TRACE (mmap, "drop a mapping from cache");
TRACE (mmap_dbg, "drop a mapping from cache");
UNIMPLEMENTED ("mmap cache drop");
break;
case REDUCE_WINDOW:
NOTICE (mmap, "mmaping window reduced to NN MB");
NOTICE (mmap_dbg, "mmaping window reduced to NN MB");
UNIMPLEMENTED ("mmap window reduce");
break;
case REDUCE_IN_USE:
NOTICE (mmap, "reduce mmapings in use");
NOTICE (mmap_dbg, "reduce mmapings in use");
UNIMPLEMENTED ("mmapings in use reduce");
break;
@ -185,7 +186,7 @@ lumiera_mmap_init (LumieraMMap self, LumieraFile file, off_t start, size_t size)
fd,
begin);
INFO_IF (addr==(void*)-1, mmap, "mmap failed %s", strerror (errno));
INFO_IF (addr==(void*)-1, mmap_dbg, "mmap failed %s", strerror (errno));
ENSURE (errno == 0 || errno == ENOMEM, "unexpected mmap error %s", strerror (errno));
}
@ -213,7 +214,7 @@ lumiera_mmap_init (LumieraMMap self, LumieraFile file, off_t start, size_t size)
LumieraMMap
lumiera_mmap_new (LumieraFile file, off_t start, size_t size)
{
TRACE (mmap);
TRACE (mmap_dbg);
LumieraMMap self = lumiera_mmapcache_mmap_acquire (lumiera_mcache);
@ -230,7 +231,7 @@ lumiera_mmap_new (LumieraFile file, off_t start, size_t size)
void
lumiera_mmap_delete (LumieraMMap self)
{
TRACE (mmap);
TRACE (mmap_dbg);
if (self)
{
lumiera_mmapcache_forget (lumiera_mcache, self);
@ -238,7 +239,7 @@ lumiera_mmap_delete (LumieraMMap self)
/* The matching mappings->lock must be hold or being irrelevant (mappings destructor) here, we can't asset this from here, good luck */
llist_unlink (&self->searchnode);
TRACE (mmap, "unmap at %p with size %zd", self->address, self->size);
TRACE (mmap_dbg, "unmap at %p with size %zd", self->address, self->size);
munmap (self->address, self->size);
lumiera_free (self->refmap);
lumiera_free (self);
@ -249,7 +250,7 @@ lumiera_mmap_delete (LumieraMMap self)
void*
lumiera_mmap_destroy_node (LList node)
{
TRACE (mmap);
TRACE (mmap_dbg);
REQUIRE (llist_is_empty (node));
LumieraMMap self = (LumieraMMap)node;

View file

@ -36,7 +36,7 @@ typedef lumiera_mmap* LumieraMMap;
#include <nobug.h>
#include <sys/mman.h>
NOBUG_DECLARE_FLAG (mmap);
//NOBUG_DECLARE_FLAG (mmap);
/**

View file

@ -19,6 +19,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "common/logging.h"
#include "lib/safeclib.h"
#include "backend/mmapcache.h"
@ -28,7 +29,7 @@
*
*/
NOBUG_DEFINE_FLAG_PARENT (mmapcache, mmap_all);
//NOBUG_DEFINE_FLAG_PARENT (mmapcache, mmap_all);
LumieraMMapcache lumiera_mcache = NULL;
@ -36,7 +37,7 @@ LumieraMMapcache lumiera_mcache = NULL;
void
lumiera_mmapcache_new (size_t limit)
{
TRACE (mmapcache);
TRACE (mmapcache_dbg);
lumiera_mcache = lumiera_malloc (sizeof (*lumiera_mcache));
lumiera_mrucache_init (&lumiera_mcache->cache, lumiera_mmap_destroy_node);
@ -45,19 +46,19 @@ lumiera_mmapcache_new (size_t limit)
lumiera_mcache->total = 0;
lumiera_mcache->cached = 0;
lumiera_mutex_init (&lumiera_mcache->lock, "mmapcache", &NOBUG_FLAG (mmapcache));
lumiera_mutex_init (&lumiera_mcache->lock, "mmapcache", &NOBUG_FLAG (mutex_dbg));
}
void
lumiera_mmapcache_delete (void)
{
TRACE (mmapcache);
TRACE (mmapcache_dbg);
if (lumiera_mcache)
{
REQUIRE (lumiera_mcache->total == lumiera_mcache->cached, "MMaps still checked out at shutdown");
lumiera_mrucache_destroy (&lumiera_mcache->cache);
lumiera_mutex_destroy (&lumiera_mcache->lock, &NOBUG_FLAG (mmapcache));
lumiera_mutex_destroy (&lumiera_mcache->lock, &NOBUG_FLAG (mutex_dbg));
free (lumiera_mcache);
lumiera_mcache = NULL;
}
@ -67,10 +68,10 @@ lumiera_mmapcache_delete (void)
void*
lumiera_mmapcache_mmap_acquire (LumieraMMapcache self)
{
TRACE (mmapcache);
TRACE (mmapcache_dbg);
void* map = NULL;
LUMIERA_MUTEX_SECTION (mmapcache, &self->lock)
LUMIERA_MUTEX_SECTION (mutex_sync, &self->lock)
{
map = lumiera_mrucache_pop (&self->cache);
}
@ -78,11 +79,11 @@ lumiera_mmapcache_mmap_acquire (LumieraMMapcache self)
if (!map)
{
map = lumiera_malloc (sizeof (*self));
TRACE (mmapcache, "allocated new mmap");
TRACE (mmapcache_dbg, "allocated new mmap");
}
else
{
TRACE (mmapcache, "poped mmap from cache");
TRACE (mmapcache_dbg, "poped mmap from cache");
}
return map;
@ -92,8 +93,8 @@ lumiera_mmapcache_mmap_acquire (LumieraMMapcache self)
void
lumiera_mmapcache_announce (LumieraMMapcache self, LumieraMMap map)
{
TRACE (mmapcache);
LUMIERA_MUTEX_SECTION (mmapcache, &self->lock)
TRACE (mmapcache_dbg);
LUMIERA_MUTEX_SECTION (mutex_sync, &self->lock)
{
self->total += map->size;
}
@ -103,8 +104,8 @@ lumiera_mmapcache_announce (LumieraMMapcache self, LumieraMMap map)
void
lumiera_mmapcache_forget (LumieraMMapcache self, LumieraMMap map)
{
TRACE (mmapcache);
LUMIERA_MUTEX_SECTION (mmapcache, &self->lock)
TRACE (mmapcache_dbg);
LUMIERA_MUTEX_SECTION (mutex_sync, &self->lock)
{
if (!llist_is_empty (&map->cachenode))
{
@ -120,7 +121,7 @@ lumiera_mmapcache_forget (LumieraMMapcache self, LumieraMMap map)
int
lumiera_mmapcache_age (LumieraMMapcache self)
{
TRACE (mmapcache);
TRACE (mmapcache_dbg);
int ret = 0;
LUMIERA_MUTEX_SECTION (mmapcache, &self->lock)
@ -135,9 +136,9 @@ lumiera_mmapcache_age (LumieraMMapcache self)
LumieraMMap
lumiera_mmapcache_checkout (LumieraMMapcache self, LumieraMMap handle)
{
TRACE (mmapcache);
TRACE (mmapcache_dbg);
LUMIERA_MUTEX_SECTION (mmapcache, &self->lock)
LUMIERA_MUTEX_SECTION (mutex_sync, &self->lock)
{
TODO ("cached stats");
lumiera_mrucache_checkout (&self->cache, &handle->cachenode);
@ -151,9 +152,9 @@ lumiera_mmapcache_checkout (LumieraMMapcache self, LumieraMMap handle)
void
lumiera_mmapcache_checkin (LumieraMMapcache self, LumieraMMap handle)
{
TRACE (mmapcache);
TRACE (mmapcache_dbg);
LUMIERA_MUTEX_SECTION (mmapcache, &self->lock)
LUMIERA_MUTEX_SECTION (mutex_sync, &self->lock)
{
TODO ("cached stats");
--handle->refcnt;

View file

@ -19,6 +19,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "common/logging.h"
#include "lib/mutex.h"
#include "lib/safeclib.h"
@ -36,14 +37,14 @@
LumieraMMapings
lumiera_mmapings_init (LumieraMMapings self, LumieraFile file, size_t chunksize)
{
TRACE (mmapings);
TRACE (mmapings_dbg);
REQUIRE (!file->descriptor->mmapings);
llist_init (&self->mmaps);
self->descriptor = file->descriptor;
self->chunksize = chunksize;
lumiera_mutex_init (&self->lock, "mmapings", &NOBUG_FLAG(mmapings));
lumiera_mutex_init (&self->lock, "mmapings", &NOBUG_FLAG(mutex_dbg));
return self;
}
@ -52,7 +53,7 @@ lumiera_mmapings_init (LumieraMMapings self, LumieraFile file, size_t chunksize)
LumieraMMapings
lumiera_mmapings_destroy (LumieraMMapings self)
{
TRACE (mmapings);
TRACE (mmapings_dbg);
if (!self)
return NULL;
@ -62,7 +63,7 @@ lumiera_mmapings_destroy (LumieraMMapings self)
lumiera_mmap_delete (mmap);
}
lumiera_mutex_destroy (&self->lock, &NOBUG_FLAG(mmapings));
lumiera_mutex_destroy (&self->lock, &NOBUG_FLAG(mutex_dbg));
return self;
}
@ -71,6 +72,7 @@ lumiera_mmapings_destroy (LumieraMMapings self)
LumieraMMapings
lumiera_mmapings_new (LumieraFile file, size_t chunksize)
{
TRACE (mmapings_dbg);
LumieraMMapings self = lumiera_malloc (sizeof (*self));
return lumiera_mmapings_init (self, file, chunksize);
}
@ -79,7 +81,7 @@ lumiera_mmapings_new (LumieraFile file, size_t chunksize)
void
lumiera_mmapings_delete (LumieraMMapings self)
{
TRACE (mmapings);
TRACE (mmapings_dbg);
free (lumiera_mmapings_destroy (self));
}
@ -87,11 +89,11 @@ lumiera_mmapings_delete (LumieraMMapings self)
LumieraMMap
lumiera_mmapings_mmap_acquire (LumieraMMapings self, LumieraFile file, LList acquirer, off_t start, size_t size)
{
TRACE (mmapings);
TRACE (mmapings_dbg);
LumieraMMap ret = NULL;
LUMIERA_MUTEX_SECTION (mmapings, &self->lock)
LUMIERA_MUTEX_SECTION (mutex_sync, &self->lock)
{
REQUIRE (llist_is_empty (acquirer));
@ -119,7 +121,7 @@ lumiera_mmapings_mmap_acquire (LumieraMMapings self, LumieraFile file, LList acq
else
{
/* create new mmap */
TRACE (mmapings, "mmap not found, creating", mmap);
TRACE (mmapings_dbg, "mmap not found, creating", mmap);
ret = lumiera_mmap_new (file, start, size);
llist_insert_head (&self->mmaps, &ret->searchnode);
@ -137,13 +139,14 @@ lumiera_mmapings_mmap_acquire (LumieraMMapings self, LumieraFile file, LList acq
void
lumiera_mmapings_release_mmap (LumieraMMapings self, LList acquirer, LumieraMMap map)
{
TRACE (mmapings);
LUMIERA_MUTEX_SECTION (mmapings, &self->lock)
TRACE (mmapings_dbg);
LUMIERA_MUTEX_SECTION (mutex_sync, &self->lock)
{
llist_unlink (acquirer);
if (llist_is_empty (&map->cachenode))
{
TRACE (mmapings, "checkin");
TRACE (mmapcache_dbg, "checkin");
lumiera_mmapcache_checkin (lumiera_mcache, map);
}
}

View file

@ -34,7 +34,7 @@ typedef lumiera_mmapings* LumieraMMapings;
#include <nobug.h>
NOBUG_DECLARE_FLAG (mmapings);
//NOBUG_DECLARE_FLAG (mmapings);
/**
* @file

View file

@ -25,7 +25,7 @@
#define LIB_THREADWRAPPER_H
#include "include/nobugcfg.h"
#include "common/logging.h"
#include "lib/sync.hpp"
extern "C" {
@ -74,7 +74,7 @@ namespace lib {
static void
run (void* arg)
{
ASSERT (arg);
REQUIRE (arg);
Thread* startingWrapper = reinterpret_cast<Thread*>(arg);
Operation _doIt_(startingWrapper->operation_);
{
@ -88,7 +88,7 @@ namespace lib {
public:
Thread (Literal& purpose, Operation const& operation, struct nobug_flag *logging_flag = &NOBUG_FLAG(operate))
Thread (Literal& purpose, Operation const& operation, struct nobug_flag *logging_flag = &NOBUG_FLAG(thread))
: started_(false),
operation_(operation)
{

View file

@ -36,7 +36,7 @@
*
*/
NOBUG_DEFINE_FLAG_PARENT (threads, lumiera); /*TODO insert a suitable/better parent flag here */
//NOBUG_DEFINE_FLAG_PARENT (threads, lumiera); /*TODO insert a suitable/better parent flag here */
//code goes here//