1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-07 02:42:48 +03:00

Make sure the sqlite3_vfs_register() and sqlite3_vfs_unregister() APIs

work right even if not VFS is currently registered.  Ticket #2738. (CVS 4505)

FossilOrigin-Name: c36500871e85b55cb0804d5c9e88fa6861a507a9
This commit is contained in:
drh
2007-10-23 14:49:59 +00:00
parent 0d6e7a00d6
commit 9bc5449f9d
5 changed files with 56 additions and 16 deletions

View File

@@ -214,7 +214,7 @@ static sqlite3_vfs *vfsList = 0;
*/
sqlite3_vfs *sqlite3_vfs_find(const char *zVfs){
sqlite3_mutex *mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER);
sqlite3_vfs *pVfs;
sqlite3_vfs *pVfs = 0;
static int isInit = 0;
sqlite3_mutex_enter(mutex);
if( !isInit ){
@@ -234,9 +234,11 @@ sqlite3_vfs *sqlite3_vfs_find(const char *zVfs){
*/
static void vfsUnlink(sqlite3_vfs *pVfs){
assert( sqlite3_mutex_held(sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER)) );
if( vfsList==pVfs ){
if( pVfs==0 ){
/* No-op */
}else if( vfsList==pVfs ){
vfsList = pVfs->pNext;
}else{
}else if( vfsList ){
sqlite3_vfs *p = vfsList;
while( p->pNext && p->pNext!=pVfs ){
p = p->pNext;
@@ -276,7 +278,6 @@ int sqlite3_vfs_unregister(sqlite3_vfs *pVfs){
sqlite3_mutex *mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER);
sqlite3_mutex_enter(mutex);
vfsUnlink(pVfs);
assert(vfsList);
sqlite3_mutex_leave(mutex);
return SQLITE_OK;
}