userlibandfileserver/fileserver/sfile/sf_file_cache.cpp
changeset 286 48e57fb1237e
parent 254 1560c419b176
child 297 b2826f67641f
child 300 1d28c8722707
--- a/userlibandfileserver/fileserver/sfile/sf_file_cache.cpp	Wed Oct 06 17:13:14 2010 +0100
+++ b/userlibandfileserver/fileserver/sfile/sf_file_cache.cpp	Mon Oct 11 17:54:41 2010 +0100
@@ -2117,7 +2117,13 @@
 	// Remember the last session which caused the file to become dirty
 	// Always record whether any session has reserved access so the CheckDiskSpace() behaves correctly
 	if (iDirtyDataOwner == NULL || session->ReservedAccess(iDriveNum))
+		{
+		if (iDirtyDataOwner)
+			iDirtyDataOwner->Close();
 		iDirtyDataOwner = session;
+		// open the session to prevent it from being deleted while there is dirty data
+		iDirtyDataOwner->Open();
+		}
 
 	// start a timer after which file will be flushed
 	CDriveThread* driveThread=NULL;
@@ -2132,6 +2138,9 @@
 */
 void CFileCache::MarkFileClean()
 	{
+	if (iDirtyDataOwner)
+		iDirtyDataOwner->Close();
+
 	iDirtyDataOwner = NULL;
 
 	if (!iDriveThread)