Limit maximum number of SharedCacheMap mapped objects.
authorlace <>
Mon, 26 Dec 2005 07:11:39 +0000 (07:11 +0000)
committerlace <>
Mon, 26 Dec 2005 07:11:39 +0000 (07:11 +0000)
 - It should fix some icons scanning file managers, I hope.

src/libcaptive/cc/sharedcachemap.c
src/libcaptive/cc/sharedcachemap.h
src/libcaptive/client/file-slave.c

index 42c6780..811e31b 100644 (file)
 #include <stdlib.h>
 
 
+/* 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;
index 9c0e309..85fa2fe 100644 (file)
@@ -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
 
index aeca8e8..8193e38 100644 (file)
 #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);