+proper Cache Manager flushing during captive shutdown / unmount
authorshort <>
Thu, 1 May 2003 21:23:24 +0000 (21:23 +0000)
committershort <>
Thu, 1 May 2003 21:23:24 +0000 (21:23 +0000)
src/libcaptive/client/init.c
src/libcaptive/include/captive/leave.h

index 72a298d..4e81c94 100644 (file)
@@ -46,6 +46,7 @@
 #include "giochannel-blind.h"
 #include <glib-object.h>
 #include "reactos/internal/se.h"       /* for SeInit2() */
+#include "captive/leave.h"
 
 
 /* Are we initialized? */
@@ -458,6 +459,9 @@ args_err:
 }
 
 
+BOOLEAN captive_cc_FileObject_delete(FILE_OBJECT *FileObject);
+void captive_cc_flush(void);
+
 /**
  * captive_shutdown:
  *
@@ -481,11 +485,28 @@ GIOStatus erriostatus;
                g_log(G_LOG_DOMAIN,G_LOG_LEVEL_DEBUG,"%s: g_main_context_iteration() proceeded",G_STRLOC);
 
        captive_PoQueueShutdownWorkItem_hooklist_invoke();
+       captive_cc_flush();
+
+       /* During IoShutdownRegisteredFileSystems() - IRP_MJ_SHUTDOWN to be specific
+        * some buffers will be written but after the IofCallDriver() it will be
+        * no longer possible to flush such buffers to their DeviceVolumeFile.
+        * Therefore we must flush such buffers on the fly although such behaviour
+        * would crash us in regular case as filesystems access BCBs even after their
+        * CcUnpinData().
+        */
+       captive_cc_unmounting=TRUE;
 
        /* FIXME: ntoskrnl/ex/power.c/NtShutdownSystem() does
         * IoShutdownRegistered{Devices,FileSystems} order; is it correct?
         */
        IoShutdownRegisteredFileSystems();
+
+       /* Just a sanity check as all the dirty data should
+        * get already flushed during IoShutdownRegisteredFileSystems().
+        */
+       captive_cc_FileObject_delete(
+                       NULL);  /* FileObject */
+
        IoShutdownRegisteredDevices();
 
        /* libcaptive is not authorized to shutdown 'captive_image_channel'. */
index 30eb43a..0c16813 100644 (file)
@@ -29,6 +29,7 @@ G_BEGIN_DECLS
 void captive_leave(void);
 typedef void (*captive_leave_func)(gpointer data);
 void captive_leave_register(captive_leave_func func,gpointer data);
+extern gboolean captive_cc_unmounting;
 
 G_END_DECLS