From: lace <> Date: Mon, 26 Dec 2005 07:11:39 +0000 (+0000) Subject: Limit maximum number of SharedCacheMap mapped objects. X-Git-Tag: captive-1_1_6~34 X-Git-Url: http://git.jankratochvil.net/?p=captive.git;a=commitdiff_plain;h=0629f8bd3224b53621f1f19157b715c444c0d256 Limit maximum number of SharedCacheMap mapped objects. - It should fix some icons scanning file managers, I hope. --- diff --git a/src/libcaptive/cc/sharedcachemap.c b/src/libcaptive/cc/sharedcachemap.c index 42c6780..811e31b 100644 --- a/src/libcaptive/cc/sharedcachemap.c +++ b/src/libcaptive/cc/sharedcachemap.c @@ -31,6 +31,19 @@ #include +/* Config: */ +/* Maximum allocatable (without filling in data) on test: 0xA8000000 */ +#define TOTAL_MAPPED_MAX 0x30000000 /* Maximum mapped area; FIXME: Fix Cache Manager. */ + +static size_t total_mapped=0; + + +gboolean captive_shared_cache_map_restart_needed(void) +{ + return total_mapped>=TOTAL_MAPPED_MAX; +} + + static GHashTable *CaptiveSharedCacheMapObject_hash; static void CaptiveSharedCacheMapObject_hash_init(void) @@ -222,6 +235,7 @@ int errint; if (base==MAP_FAILED) goto size_new_big; g_assert(base!=NULL); + total_mapped+=alloc_new; base+=PAGE_SIZE; errint=munmap(base-PAGE_SIZE,PAGE_SIZE); /* unmap leading boundary check page */ @@ -240,6 +254,7 @@ int errint; errint=munmap(captive_shared_cache_map_object->buffer,captive_shared_cache_map_object->alloc_length); g_assert(errint==0); + total_mapped-=captive_shared_cache_map_object->alloc_length; } captive_shared_cache_map_object->buffer=buffer_new; diff --git a/src/libcaptive/cc/sharedcachemap.h b/src/libcaptive/cc/sharedcachemap.h index 9c0e309..85fa2fe 100644 --- a/src/libcaptive/cc/sharedcachemap.h +++ b/src/libcaptive/cc/sharedcachemap.h @@ -74,6 +74,7 @@ void captive_shared_cache_map_flush_all(void); gboolean captive_shared_cache_map_is_any_dirty(void); gint64 captive_shared_cache_map_CcGetDirtyPages(PDIRTY_PAGE_ROUTINE DirtyPageRoutine,VOID *Context1,VOID *Context2); gpointer captive_shared_cache_map_get_buffer(CaptiveSharedCacheMapObject *captive_shared_cache_map_object); +gboolean captive_shared_cache_map_restart_needed(void); G_END_DECLS diff --git a/src/libcaptive/client/file-slave.c b/src/libcaptive/client/file-slave.c index aeca8e8..8193e38 100644 --- a/src/libcaptive/client/file-slave.c +++ b/src/libcaptive/client/file-slave.c @@ -37,10 +37,11 @@ #include "captive/usecount.h" #include "vfs.h" #include "vfs-slave.h" +#include "../cc/sharedcachemap.h" /* Config: */ -#define MAX_FILE_READ 0x1000000 /* FIXME: Workaround memory consumption for non-journalled fastfat.sys */ +#define MAX_FILE_READ 0x8000000 /* FIXME: Workaround memory consumption for non-journalled fastfat.sys */ #define MAX_FILE_WRITTEN 0x100000 /* FIXME: Workaround memory consumption for non-journalled fastfat.sys */ @@ -150,6 +151,9 @@ NTSTATUS err; g_return_val_if_fail(captive_file_slave_object!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS); g_return_val_if_fail(pathname!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS); + if (captive_shared_cache_map_restart_needed()) + return GNOME_VFS_ERROR_SERVICE_OBSOLETE; + errvfsresult=captive_ObjectAttributes_init(pathname,&file_ObjectAttributes); g_return_val_if_fail(errvfsresult==GNOME_VFS_OK,errvfsresult);