[asterisk-commits] file: branch file/astdb-sqlite3 r78699 - in /team/file/astdb-sqlite3: include...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Aug 8 19:52:56 CDT 2007


Author: file
Date: Wed Aug  8 19:52:54 2007
New Revision: 78699

URL: http://svn.digium.com/view/asterisk?view=rev&rev=78699
Log:
Close the database out when Asterisk shuts down so it does not become corrupted.

Modified:
    team/file/astdb-sqlite3/include/asterisk.h
    team/file/astdb-sqlite3/main/asterisk.c
    team/file/astdb-sqlite3/main/db.c

Modified: team/file/astdb-sqlite3/include/asterisk.h
URL: http://svn.digium.com/view/asterisk/team/file/astdb-sqlite3/include/asterisk.h?view=diff&rev=78699&r1=78698&r2=78699
==============================================================================
--- team/file/astdb-sqlite3/include/asterisk.h (original)
+++ team/file/astdb-sqlite3/include/asterisk.h Wed Aug  8 19:52:54 2007
@@ -80,6 +80,7 @@
 int init_framer(void);				/*!< Provided by frame.c */
 int ast_term_init(void);			/*!< Provided by term.c */
 int astdb_init(void);				/*!< Provided by db.c */
+int astdb_close(void);                          /*!< Provided by db.c */
 void ast_channels_init(void);			/*!< Provided by channel.c */
 void ast_builtins_init(void);			/*!< Provided by cli.c */
 int dnsmgr_init(void);				/*!< Provided by dnsmgr.c */ 

Modified: team/file/astdb-sqlite3/main/asterisk.c
URL: http://svn.digium.com/view/asterisk/team/file/astdb-sqlite3/main/asterisk.c?view=diff&rev=78699&r1=78698&r2=78699
==============================================================================
--- team/file/astdb-sqlite3/main/asterisk.c (original)
+++ team/file/astdb-sqlite3/main/asterisk.c Wed Aug  8 19:52:54 2007
@@ -1304,6 +1304,7 @@
 		/* close logger */
 		close_logger();
 	}
+	astdb_close();
 	exit(0);
 }
 

Modified: team/file/astdb-sqlite3/main/db.c
URL: http://svn.digium.com/view/asterisk/team/file/astdb-sqlite3/main/db.c?view=diff&rev=78699&r1=78698&r2=78699
==============================================================================
--- team/file/astdb-sqlite3/main/db.c (original)
+++ team/file/astdb-sqlite3/main/db.c Wed Aug  8 19:52:54 2007
@@ -83,6 +83,19 @@
 	return -1;
 }
 
+static int dbclose(void)
+{
+	ast_mutex_lock(&dblock);
+
+	/* This is pretty simple, just close the database */
+	sqlite3_close(db);
+	db = NULL;
+
+	ast_mutex_unlock(&dblock);
+
+	return 0;
+}
+
 int ast_db_deltree(const char *family, const char *keytree)
 {
 	int res = SQLITE_OK;
@@ -715,3 +728,9 @@
 	ast_manager_register("DBDelTree", EVENT_FLAG_SYSTEM, manager_dbdeltree, "Delete DB Tree");
 	return 0;
 }
+
+int astdb_close(void)
+{
+	dbclose();
+	return 0;
+}




More information about the asterisk-commits mailing list