void lumiera_backend_destroy (void) { TRACE (backend_dbg); lumiera_mmapcache_delete (); lumiera_filehandlecache_delete (); lumiera_filedescriptorregistry_destroy (); lumiera_threadpool_destroy (); lumiera_safeclib_set_resourcecollector (NULL); mpool_init_hook = NULL; mpool_destroy_hook = NULL; mpool_malloc_hook = malloc; mpool_free_hook = free; lumiera_resourcecollector_destroy (); lumiera_mutex_destroy (&lumiera_filecreate_mutex, &NOBUG_FLAG (mutex_dbg), NOBUG_CONTEXT); }
int lumiera_backend_init (void) { TRACE (backend_dbg); lumiera_mutex_init (&lumiera_filecreate_mutex, "fileaccess", &NOBUG_FLAG (mutex_dbg), NOBUG_CONTEXT); lumiera_resourcecollector_init (); /* hook the resourcecollector into the mpool*/ mpool_malloc_hook = lumiera_malloc; mpool_free_hook = lumiera_free; mpool_init_hook = lumiera_backend_resourcecollector_register_mpool; mpool_destroy_hook = lumiera_backend_resourcecollector_unregister_mpool; /* hook the resourcecollector into the safeclib allocation functions */ lumiera_safeclib_set_resourcecollector (lumiera_resourcecollector_run); PLANNED("The resourcecollector aborts by default when there is no final strategy for recovery, TODO: initiate sane shutdown"); lumiera_threadpool_init (); PLANNED ("hook threadpool into the resourcecollector (maybe in threadpool_init() instead here"); lumiera_filedescriptorregistry_init (); lumiera_backend_pagesize = sysconf(_SC_PAGESIZE); /////////////////////////////////////////////////////////////////////TICKET #838 add config options to override following defaults" const char* filehandles = lumiera_tmpbuf_snprintf (SIZE_MAX, "vault.file.max_handles = %d", /* roughly 2/3 of all available filehandles are managed by the Lumiera Vault */ (sysconf (_SC_OPEN_MAX)-10)*2/3); lumiera_config_setdefault (filehandles); long long max_entries; lumiera_config_number_get ("vault.file.max_handles", &max_entries); lumiera_filehandlecache_new (max_entries); #if SIZE_MAX <= 4294967295UL lumiera_config_setdefault ("vault.mmap.as_limit = 3221225469"); #else lumiera_config_setdefault ("vault.mmap.as_limit = 211106232532992"); #endif struct rlimit as_rlimit; getrlimit (RLIMIT_AS, &as_rlimit); long long as_limit = (long long)as_rlimit.rlim_cur; if (as_rlimit.rlim_cur == RLIM_INFINITY) { lumiera_config_number_get ("vault.mmap.as_limit", &as_limit); } else { INFO (vault, "address space limited to %luMiB", as_rlimit.rlim_cur/1024/1024); } lumiera_mmapcache_new (as_limit); return 0; }