Make extra calls to sqlite3_shutdown() be harmless no-ops. (CVS 6520)
FossilOrigin-Name: d80822953c2d2f2fd7f6acdd3caa403c0decacc4
diff --git a/src/main.c b/src/main.c
index 6edaeee..a6cdefb 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 @@
** 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;
}