[asterisk-commits] sgriepentrog: branch 11 r404344 - /branches/11/main/db.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Dec 19 10:30:39 CST 2013
Author: sgriepentrog
Date: Thu Dec 19 10:30:33 2013
New Revision: 404344
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=404344
Log:
astdb: crash in sqlite3 during shutdown
When Asterisk is shut down, the astdb_atexit() function releases
(finalize) the previously initiated (prepared) SQL statements in
sqlite3. Another thread making a subsequent request can cause a
crash in sqlite3. This patch eliminates that issue by resetting
the statement pointer after it is released/cleared. The sqlite3
code detects the null pointer, and aborts the operation cleanly.
(closes issue AST-1265)
Reported by: Alexander Hömig
(closes issue ASTERISK-22350)
Reported by: Birger "WIMPy" Harzenetter
Review: https://reviewboard.asterisk.org/r/3078/
Modified:
branches/11/main/db.c
Modified: branches/11/main/db.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/db.c?view=diff&rev=404344&r1=404343&r2=404344
==============================================================================
--- branches/11/main/db.c (original)
+++ branches/11/main/db.c Thu Dec 19 10:30:33 2013
@@ -145,12 +145,14 @@
* \brief Clean up the prepared SQLite3 statement
* \note dblock should already be locked prior to calling this method
*/
-static int clean_stmt(sqlite3_stmt *stmt, const char *sql)
-{
- if (sqlite3_finalize(stmt) != SQLITE_OK) {
+static int clean_stmt(sqlite3_stmt **stmt, const char *sql)
+{
+ if (sqlite3_finalize(*stmt) != SQLITE_OK) {
ast_log(LOG_WARNING, "Couldn't finalize statement '%s': %s\n", sql, sqlite3_errmsg(astdb));
+ *stmt = NULL;
return -1;
}
+ *stmt = NULL;
return 0;
}
@@ -160,15 +162,15 @@
*/
static void clean_statements(void)
{
- clean_stmt(get_stmt, get_stmt_sql);
- clean_stmt(del_stmt, del_stmt_sql);
- clean_stmt(deltree_stmt, deltree_stmt_sql);
- clean_stmt(deltree_all_stmt, deltree_all_stmt_sql);
- clean_stmt(gettree_stmt, gettree_stmt_sql);
- clean_stmt(gettree_all_stmt, gettree_all_stmt_sql);
- clean_stmt(showkey_stmt, showkey_stmt_sql);
- clean_stmt(put_stmt, put_stmt_sql);
- clean_stmt(create_astdb_stmt, create_astdb_stmt_sql);
+ clean_stmt(&get_stmt, get_stmt_sql);
+ clean_stmt(&del_stmt, del_stmt_sql);
+ clean_stmt(&deltree_stmt, deltree_stmt_sql);
+ clean_stmt(&deltree_all_stmt, deltree_all_stmt_sql);
+ clean_stmt(&gettree_stmt, gettree_stmt_sql);
+ clean_stmt(&gettree_all_stmt, gettree_all_stmt_sql);
+ clean_stmt(&showkey_stmt, showkey_stmt_sql);
+ clean_stmt(&put_stmt, put_stmt_sql);
+ clean_stmt(&create_astdb_stmt, create_astdb_stmt_sql);
}
static int init_statements(void)
More information about the asterisk-commits
mailing list