Bug 878411 - define xFetch and xUnfetch methods in TelemetryVFS file objects; r=mak
authorNathan Froyd <froydnj@mozilla.com>
Sat, 01 Jun 2013 12:26:17 -0400
changeset 134248 dc8e78ed8c44bc61fd3caaa7410f1703ac4f9718
parent 134247 2551c645b78225a06dac124d90dbd053c5637ee4
child 134249 9ca690835a5eff4af37effc64986d3352f7da20c
child 134251 bcc7265b1f99b9567401855d53f7eb5497060468
child 134271 76bea01d8db1d30c660e42229447d0b89af60ed5
child 134274 dfcabf3d307a6f71b1dd26a21a62793666d67a21
push id24786
push userryanvm@gmail.com
push dateThu, 06 Jun 2013 19:18:49 +0000
treeherdermozilla-central@dc8e78ed8c44 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs878411
milestone24.0a1
first release with
nightly linux32
dc8e78ed8c44 / 24.0a1 / 20130607031055 / files
nightly linux64
dc8e78ed8c44 / 24.0a1 / 20130607031055 / files
nightly mac
dc8e78ed8c44 / 24.0a1 / 20130607031055 / files
nightly win32
dc8e78ed8c44 / 24.0a1 / 20130607031055 / files
nightly win64
dc8e78ed8c44 / 24.0a1 / 20130607031055 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 878411 - define xFetch and xUnfetch methods in TelemetryVFS file objects; r=mak
storage/src/TelemetryVFS.cpp
--- a/storage/src/TelemetryVFS.cpp
+++ b/storage/src/TelemetryVFS.cpp
@@ -285,17 +285,33 @@ xShmBarrier(sqlite3_file *pFile){
 
 int
 xShmUnmap(sqlite3_file *pFile, int delFlag){
   telemetry_file *p = (telemetry_file *)pFile;
   int rc;
   rc = p->pReal->pMethods->xShmUnmap(p->pReal, delFlag);
   return rc;
 }
- 
+
+int
+xFetch(sqlite3_file *pFile, sqlite3_int64 iOff, int iAmt, void **pp)
+{
+  telemetry_file *p = (telemetry_file *)pFile;
+  MOZ_ASSERT(p->pReal->pMethods->iVersion >= 3);
+  return p->pReal->pMethods->xFetch(p->pReal, iOff, iAmt, pp);
+}
+
+int
+xUnfetch(sqlite3_file *pFile, sqlite3_int64 iOff, void *pResOut)
+{
+  telemetry_file *p = (telemetry_file *)pFile;
+  MOZ_ASSERT(p->pReal->pMethods->iVersion >= 3);
+  return p->pReal->pMethods->xUnfetch(p->pReal, iOff, pResOut);
+}
+
 int
 xOpen(sqlite3_vfs* vfs, const char *zName, sqlite3_file* pFile,
           int flags, int *pOutFlags)
 {
   IOThreadAutoTimer ioTimer(Telemetry::MOZ_SQLITE_OPEN_MS);
   Telemetry::AutoTimer<Telemetry::MOZ_SQLITE_OPEN_MS> timer;
   sqlite3_vfs *orig_vfs = static_cast<sqlite3_vfs*>(vfs->pAppData);
   int rc;
@@ -332,35 +348,45 @@ xOpen(sqlite3_vfs* vfs, const char *zNam
 
   rc = orig_vfs->xOpen(orig_vfs, zName, p->pReal, flags, pOutFlags);
   if( rc != SQLITE_OK )
     return rc;
   if( p->pReal->pMethods ){
     sqlite3_io_methods *pNew = new sqlite3_io_methods;
     const sqlite3_io_methods *pSub = p->pReal->pMethods;
     memset(pNew, 0, sizeof(*pNew));
-    pNew->iVersion = pSub->iVersion;
+    // If you update this version number, you must add appropriate IO methods
+    // for any methods added in the version change.
+    pNew->iVersion = 3;
+    MOZ_ASSERT(pNew->iVersion >= pSub->iVersion);
     pNew->xClose = xClose;
     pNew->xRead = xRead;
     pNew->xWrite = xWrite;
     pNew->xTruncate = xTruncate;
     pNew->xSync = xSync;
     pNew->xFileSize = xFileSize;
     pNew->xLock = xLock;
     pNew->xUnlock = xUnlock;
     pNew->xCheckReservedLock = xCheckReservedLock;
     pNew->xFileControl = xFileControl;
     pNew->xSectorSize = xSectorSize;
     pNew->xDeviceCharacteristics = xDeviceCharacteristics;
-    if( pNew->iVersion>=2 ){
-      pNew->xShmMap = pSub->xShmMap ? xShmMap : 0;
-      pNew->xShmLock = pSub->xShmLock ? xShmLock : 0;
-      pNew->xShmBarrier = pSub->xShmBarrier ? xShmBarrier : 0;
-      pNew->xShmUnmap = pSub->xShmUnmap ? xShmUnmap : 0;
-    }
+    // Methods added in version 2.
+    pNew->xShmMap = pSub->xShmMap ? xShmMap : 0;
+    pNew->xShmLock = pSub->xShmLock ? xShmLock : 0;
+    pNew->xShmBarrier = pSub->xShmBarrier ? xShmBarrier : 0;
+    pNew->xShmUnmap = pSub->xShmUnmap ? xShmUnmap : 0;
+    // Methods added in version 3.
+    // SQLite 3.7.17 calls these methods without checking for NULL first,
+    // so we always define them.  Verify that we're not going to call
+    // NULL pointers, though.
+    MOZ_ASSERT(pSub->xFetch);
+    pNew->xFetch = xFetch;
+    MOZ_ASSERT(pSub->xUnfetch);
+    pNew->xUnfetch = xUnfetch;
     pFile->pMethods = pNew;
   }
   return rc;
 }
 
 int
 xDelete(sqlite3_vfs* vfs, const char *zName, int syncDir)
 {
@@ -494,18 +520,19 @@ sqlite3_vfs* ConstructTelemetryVFS()
     expected_vfs = vfs->zName && !strcmp(vfs->zName, EXPECTED_VFS);
   }
   if (!expected_vfs) {
     return NULL;
   }
 
   sqlite3_vfs *tvfs = new ::sqlite3_vfs;
   memset(tvfs, 0, sizeof(::sqlite3_vfs));
+  // If you update this version number, you must add appropriate VFS methods
+  // for any methods added in the version change.
   tvfs->iVersion = 3;
-  // If the SQLite VFS version is updated, this shim must be updated as well.
   MOZ_ASSERT(vfs->iVersion == tvfs->iVersion);
   tvfs->szOsFile = sizeof(telemetry_file) - sizeof(sqlite3_file) + vfs->szOsFile;
   tvfs->mxPathname = vfs->mxPathname;
   tvfs->zName = "telemetry-vfs";
   tvfs->pAppData = vfs;
   tvfs->xOpen = xOpen;
   tvfs->xDelete = xDelete;
   tvfs->xAccess = xAccess;
@@ -513,19 +540,19 @@ sqlite3_vfs* ConstructTelemetryVFS()
   tvfs->xDlOpen = xDlOpen;
   tvfs->xDlError = xDlError;
   tvfs->xDlSym = xDlSym;
   tvfs->xDlClose = xDlClose;
   tvfs->xRandomness = xRandomness;
   tvfs->xSleep = xSleep;
   tvfs->xCurrentTime = xCurrentTime;
   tvfs->xGetLastError = xGetLastError;
-  // Added in version 2.
+  // Methods added in version 2.
   tvfs->xCurrentTimeInt64 = xCurrentTimeInt64;
-  // Added in version 3.
+  // Methods added in version 3.
   tvfs->xSetSystemCall = xSetSystemCall;
   tvfs->xGetSystemCall = xGetSystemCall;
   tvfs->xNextSystemCall = xNextSystemCall;
 
   return tvfs;
 }
 
 }