Bug 681085 - sync cache map file after writing the header
authorMichal Novotny <michal.novotny@gmail.com>
Tue, 23 Aug 2011 00:24:23 +0200
changeset 75659 212179627888890b98d17ec176c26bf5634d2e21
parent 75658 0ae2d673d617df09898d4067790a16c9e3c47357
child 75660 7eb1a56eaaf1bdd55c3897a3d1d9c1445f5474b5
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
bugs681085
milestone9.0a1
Bug 681085 - sync cache map file after writing the header
netwerk/cache/nsDiskCacheMap.cpp
--- a/netwerk/cache/nsDiskCacheMap.cpp
+++ b/netwerk/cache/nsDiskCacheMap.cpp
@@ -229,17 +229,20 @@ nsDiskCacheMap::FlushHeader()
     
     // write the header
     mHeader.Swap();
     PRInt32 bytesWritten = PR_Write(mMapFD, &mHeader, sizeof(nsDiskCacheHeader));
     mHeader.Unswap();
     if (sizeof(nsDiskCacheHeader) != bytesWritten) {
         return NS_ERROR_UNEXPECTED;
     }
-    
+
+    PRStatus err = PR_Sync(mMapFD);
+    if (err != PR_SUCCESS) return NS_ERROR_UNEXPECTED;
+
     return NS_OK;
 }
 
 
 nsresult
 nsDiskCacheMap::FlushRecords(PRBool unswap)
 {
     if (!mMapFD)  return NS_ERROR_NOT_AVAILABLE;