[asterisk-commits] sgriepentrog: branch 12 r404345 - in /branches/12: ./ main/db.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Dec 19 10:31:59 CST 2013
Author: sgriepentrog
Date: Thu Dec 19 10:31:57 2013
New Revision: 404345
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=404345
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/
........
Merged revisions 404344 from http://svn.asterisk.org/svn/asterisk/branches/11
Modified:
branches/12/ (props changed)
branches/12/main/db.c
Propchange: branches/12/
------------------------------------------------------------------------------
Binary property 'branch-11-merged' - no diff available.
Modified: branches/12/main/db.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/main/db.c?view=diff&rev=404345&r1=404344&r2=404345
==============================================================================
--- branches/12/main/db.c (original)
+++ branches/12/main/db.c Thu Dec 19 10:31:57 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