diff options
author | drh <drh@noemail.net> | 2009-04-19 12:23:58 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2009-04-19 12:23:58 +0000 |
commit | d1a2440d6a80723c4b67b23b1cbda38aa329a586 (patch) | |
tree | d14228b55275d80ca12d24f8d7b2301ca589b444 /src | |
parent | 0bf9f7bca4a2e3197c46cec8c02ae03e9327a556 (diff) | |
download | sqlite-d1a2440d6a80723c4b67b23b1cbda38aa329a586.tar.gz sqlite-d1a2440d6a80723c4b67b23b1cbda38aa329a586.zip |
Make extra calls to sqlite3_shutdown() be harmless no-ops. (CVS 6520)
FossilOrigin-Name: d80822953c2d2f2fd7f6acdd3caa403c0decacc4
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 22 | ||||
-rw-r--r-- | src/sqlite.h.in | 7 |
2 files changed, 19 insertions, 10 deletions
diff --git a/src/main.c b/src/main.c index 6edaeee59..a6cdefb4c 100644 --- a/src/main.c +++ b/src/main.c @@ -14,7 +14,7 @@ ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** -** $Id: main.c,v 1.537 2009/04/17 16:54:23 drh Exp $ +** $Id: main.c,v 1.538 2009/04/19 12:23:58 drh Exp $ */ #include "sqliteInt.h" @@ -213,18 +213,22 @@ int sqlite3_initialize(void){ ** Undo the effects of sqlite3_initialize(). Must not be called while ** there are outstanding database connections or memory allocations or ** while any part of SQLite is otherwise in use in any thread. This -** routine is not threadsafe. Not by a long shot. +** routine is not threadsafe. But it is safe to invoke this routine +** on when SQLite is already shut down. If SQLite is already shut down +** when this routine is invoked, then this routine is a harmless no-op. */ int sqlite3_shutdown(void){ - sqlite3GlobalConfig.isMallocInit = 0; - sqlite3PcacheShutdown(); if( sqlite3GlobalConfig.isInit ){ - sqlite3_os_end(); + sqlite3GlobalConfig.isMallocInit = 0; + sqlite3PcacheShutdown(); + if( sqlite3GlobalConfig.isInit ){ + sqlite3_os_end(); + } + sqlite3_reset_auto_extension(); + sqlite3MallocEnd(); + sqlite3MutexEnd(); + sqlite3GlobalConfig.isInit = 0; } - sqlite3_reset_auto_extension(); - sqlite3MallocEnd(); - sqlite3MutexEnd(); - sqlite3GlobalConfig.isInit = 0; return SQLITE_OK; } diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 9b5184c13..440bc5469 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -30,7 +30,7 @@ ** the version number) and changes its name to "sqlite3.h" as ** part of the build process. ** -** @(#) $Id: sqlite.h.in,v 1.441 2009/04/13 14:43:41 drh Exp $ +** @(#) $Id: sqlite.h.in,v 1.442 2009/04/19 12:23:58 drh Exp $ */ #ifndef _SQLITE3_H_ #define _SQLITE3_H_ @@ -791,6 +791,11 @@ struct sqlite3_vfs { ** of sqlite3_initialize() does any initialization. All other calls ** are harmless no-ops. ** +** A call to sqlite3_shutdown() is an "effective" call if it is the first +** call to sqlite3_shutdown() since the last sqlite3_initialize(). Only +** an effective call to sqlite3_shutdown() does any deinitialization. +** All other calls to sqlite3_shutdown() are harmless no-ops. +** ** Among other things, sqlite3_initialize() shall invoke ** sqlite3_os_init(). Similarly, sqlite3_shutdown() ** shall invoke sqlite3_os_end(). |