Force sandbox commit on each 16MB read.
authorlace <>
Mon, 26 Dec 2005 05:09:21 +0000 (05:09 +0000)
committerlace <>
Mon, 26 Dec 2005 05:09:21 +0000 (05:09 +0000)
 - Temporary workaround till NT multithreading gets implemented.

src/libcaptive/client/file-parent.c
src/libcaptive/client/file-slave.c

index 038bdc5..cf680b6 100644 (file)
@@ -348,6 +348,7 @@ static GnomeVFSResult captive_file_parent_read(CaptiveFileObject *captive_file_o
 CaptiveFileParentObject *captive_file_parent_object;
 GnomeVFSResult r;
 gint retried=0;
+gint retried_commit=0;
 
        g_return_val_if_fail(CAPTIVE_FILE_PARENT_IS_OBJECT(captive_file_object),GNOME_VFS_ERROR_BAD_PARAMETERS);
        g_return_val_if_fail(buffer!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
@@ -360,8 +361,17 @@ gint retried=0;
                if (GNOME_VFS_OK!=(r=captive_parent_connector_open(CAPTIVE_PARENT_CONNECTOR(captive_file_parent_object))))
                        return r;
                if (GNOME_VFS_ERROR_SERVICE_NOT_AVAILABLE
-                               !=(r=captive_sandbox_parent_file_read(captive_file_parent_object,buffer,num_bytes,bytes_read_return)))
+                               !=(r=captive_sandbox_parent_file_read(captive_file_parent_object,buffer,num_bytes,bytes_read_return))) {
+                       if (GNOME_VFS_ERROR_SERVICE_OBSOLETE==r) {
+                               if (!retried_commit++) {
+                                       if (GNOME_VFS_OK!=(r=captive_vfs_commit(captive_file_object->vfs)))
+                                               return r;
+                                       retried=0;
+                                       continue;
+                                       }
+                               }
                        return r;
+                       }
                } while (!retried++);
        return r;
 }
index fac5eef..aeca8e8 100644 (file)
@@ -40,6 +40,7 @@
 
 
 /* Config: */
+#define MAX_FILE_READ   0x1000000      /* FIXME: Workaround memory consumption for non-journalled fastfat.sys */
 #define MAX_FILE_WRITTEN 0x100000      /* FIXME: Workaround memory consumption for non-journalled fastfat.sys */
 
 
@@ -298,6 +299,7 @@ NTSTATUS err;
 IO_STATUS_BLOCK file_IoStatusBlock;
 LARGE_INTEGER file_offset;
 GnomeVFSResult errvfsresult;
+static GnomeVFSFileSize total_read=0;
 
        g_return_val_if_fail(CAPTIVE_FILE_SLAVE_IS_OBJECT(captive_file_object),GNOME_VFS_ERROR_BAD_PARAMETERS);
        g_return_val_if_fail(buffer!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
@@ -308,6 +310,11 @@ GnomeVFSResult errvfsresult;
 
        g_return_val_if_fail(captive_file_slave_object->file_Handle!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
 
+       /* FIXME: Workaround memory consumption for non-journalled fastfat.sys */
+       if (total_read>=MAX_FILE_READ && captive_options->sandbox)
+               return GNOME_VFS_ERROR_SERVICE_OBSOLETE;
+       total_read+=num_bytes;
+
        file_offset.QuadPart=captive_file_slave_object->offset;
        err=NtReadFile(
                        captive_file_slave_object->file_Handle, /* FileHandle */