Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Be sure to release any xShmLock locks held when closing an OTA handle. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | ota-update |
Files: | files | file ages | folders |
SHA1: |
d0fba72a47f73082ade40a732aab114b |
User & Date: | dan 2015-04-16 18:49:53.533 |
Context
2015-04-17
| ||
08:36 | Have OTA always specify SQLITE_CONFIG_URI when opening databases. Fix a test issue causing otacrash.test to fail. (check-in: 0d0e5ec064 user: dan tags: ota-update) | |
2015-04-16
| ||
18:49 | Be sure to release any xShmLock locks held when closing an OTA handle. (check-in: d0fba72a47 user: dan tags: ota-update) | |
14:33 | Fix a mismatched printf() argument and format specifier. Add ota files to Makefile.in. (check-in: 5db810a88d user: dan tags: ota-update) | |
Changes
Changes to ext/ota/otaA.test.
︙ | ︙ | |||
27 28 29 30 31 32 33 34 35 36 37 38 39 40 | CREATE TABLE data_t1(a, b, c, ota_control); INSERT INTO data_t1 VALUES(1, 2, 3, 0); INSERT INTO data_t1 VALUES(4, 5, 6, 0); INSERT INTO data_t1 VALUES(7, 8, 9, 0); } do_test 1.0 { forcedelete test.db ota.db sqlite3 db test.db db eval $db_sql db eval { PRAGMA journal_mode = wal } db close | > | 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | CREATE TABLE data_t1(a, b, c, ota_control); INSERT INTO data_t1 VALUES(1, 2, 3, 0); INSERT INTO data_t1 VALUES(4, 5, 6, 0); INSERT INTO data_t1 VALUES(7, 8, 9, 0); } do_test 1.0 { db close forcedelete test.db ota.db sqlite3 db test.db db eval $db_sql db eval { PRAGMA journal_mode = wal } db close |
︙ | ︙ |
Changes to ext/ota/sqlite3ota.c.
︙ | ︙ | |||
625 626 627 628 629 630 631 632 633 634 635 636 637 638 | ** error has already occurred when this function is called, return NULL ** immediately without attempting the allocation or modifying the stored ** error code. */ static void *otaMalloc(sqlite3ota *p, int nByte){ void *pRet = 0; if( p->rc==SQLITE_OK ){ pRet = sqlite3_malloc(nByte); if( pRet==0 ){ p->rc = SQLITE_NOMEM; }else{ memset(pRet, 0, nByte); } } | > | 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 | ** error has already occurred when this function is called, return NULL ** immediately without attempting the allocation or modifying the stored ** error code. */ static void *otaMalloc(sqlite3ota *p, int nByte){ void *pRet = 0; if( p->rc==SQLITE_OK ){ assert( nByte>0 ); pRet = sqlite3_malloc(nByte); if( pRet==0 ){ p->rc = SQLITE_NOMEM; }else{ memset(pRet, 0, nByte); } } |
︙ | ︙ | |||
2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 | ** are recorded. Additionally, successful attempts to obtain exclusive ** xShmLock() WRITER, CHECKPOINTER and READ0 locks on the target ** database file are recorded. xShmLock() calls to unlock the same ** locks are no-ops (so that once obtained, these locks are never ** relinquished). Finally, calls to xSync() on the target database ** file fail with SQLITE_INTERNAL errors. */ /* ** Close an ota file. */ static int otaVfsClose(sqlite3_file *pFile){ ota_file *p = (ota_file*)pFile; int rc; | > > > > > > > > > > > > > | 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 | ** are recorded. Additionally, successful attempts to obtain exclusive ** xShmLock() WRITER, CHECKPOINTER and READ0 locks on the target ** database file are recorded. xShmLock() calls to unlock the same ** locks are no-ops (so that once obtained, these locks are never ** relinquished). Finally, calls to xSync() on the target database ** file fail with SQLITE_INTERNAL errors. */ static void otaUnlockShm(ota_file *p){ if( p->pOta ){ int (*xShmLock)(sqlite3_file*,int,int,int) = p->pReal->pMethods->xShmLock; int i; for(i=0; i<SQLITE_SHM_NLOCK;i++){ if( (1<<i) & p->pOta->mLock ){ xShmLock(p->pReal, i, 1, SQLITE_SHM_UNLOCK|SQLITE_SHM_EXCLUSIVE); } } p->pOta->mLock = 0; } } /* ** Close an ota file. */ static int otaVfsClose(sqlite3_file *pFile){ ota_file *p = (ota_file*)pFile; int rc; |
︙ | ︙ | |||
2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 | if( p->openFlags & SQLITE_OPEN_MAIN_DB ){ ota_file **pp; sqlite3_mutex_enter(p->pOtaVfs->mutex); for(pp=&p->pOtaVfs->pMain; *pp!=p; pp=&((*pp)->pMainNext)); *pp = p->pMainNext; sqlite3_mutex_leave(p->pOtaVfs->mutex); p->pReal->pMethods->xShmUnmap(p->pReal, 0); } /* Close the underlying file handle */ rc = p->pReal->pMethods->xClose(p->pReal); return rc; } | > | 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 | if( p->openFlags & SQLITE_OPEN_MAIN_DB ){ ota_file **pp; sqlite3_mutex_enter(p->pOtaVfs->mutex); for(pp=&p->pOtaVfs->pMain; *pp!=p; pp=&((*pp)->pMainNext)); *pp = p->pMainNext; sqlite3_mutex_leave(p->pOtaVfs->mutex); otaUnlockShm(p); p->pReal->pMethods->xShmUnmap(p->pReal, 0); } /* Close the underlying file handle */ rc = p->pReal->pMethods->xClose(p->pReal); return rc; } |
︙ | ︙ | |||
3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 | int rc = SQLITE_OK; int eStage = (p->pOta ? p->pOta->eStage : 0); assert( p->openFlags & (SQLITE_OPEN_MAIN_DB|SQLITE_OPEN_TEMP_DB) ); if( eStage==OTA_STAGE_OAL || eStage==OTA_STAGE_MOVE ){ /* no-op */ }else{ rc = p->pReal->pMethods->xShmUnmap(p->pReal, delFlag); } return rc; } /* ** Given that zWal points to a buffer containing a wal file name passed to | > > | 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 | int rc = SQLITE_OK; int eStage = (p->pOta ? p->pOta->eStage : 0); assert( p->openFlags & (SQLITE_OPEN_MAIN_DB|SQLITE_OPEN_TEMP_DB) ); if( eStage==OTA_STAGE_OAL || eStage==OTA_STAGE_MOVE ){ /* no-op */ }else{ /* Release the checkpointer and writer locks */ otaUnlockShm(p); rc = p->pReal->pMethods->xShmUnmap(p->pReal, delFlag); } return rc; } /* ** Given that zWal points to a buffer containing a wal file name passed to |
︙ | ︙ |