[asterisk-commits] kharwell: trunk r404606 - in /trunk: ./ cel/cel_pgsql.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Dec 31 15:39:47 CST 2013


Author: kharwell
Date: Tue Dec 31 15:39:45 2013
New Revision: 404606

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=404606
Log:
cel_pgsql: deadlock on unload and core_event_dispatcher

A deadlock can happen between a thread unloading or reloading the cel_pgsql
module and the core_event_dispatcher taskprocessor thread. Description of
what is happening:

Thread 1 (for example, a netconsole thread):

    a "module reload cel_pgsql" is launched
    the thread enter the "my_unload_module" function (cel_pgsql.c)
    the thread acquire the write lock on psql_columns
    the thread enter the "ast_event_unsubscribe" function (event.c)
    the thread try to acquire the write lock on ast_event_subs[sub->type]

Thread 2 (core_event_dispatcher taskprocessor thread):

    the taskprocessor pop a CEL event
    the thread enter the "handle_event" function (event.c)
    the thread acquire the read lock on ast_event_subs[sub->type]
    the thread callback the "pgsql_log" function (cel_pgsql.c), since it's a subscriber of CEL events
    the thread try to acquire a read lock on psql_columns

(closes issue ASTERISK-22854)
Reported by: Etienne Lessard
Patches:
     cel_pgsql_fix_deadlock_event.patch uploaded by hexanol (license 6394)
........

Merged revisions 404603 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 404604 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 404605 from http://svn.asterisk.org/svn/asterisk/branches/12

Modified:
    trunk/   (props changed)
    trunk/cel/cel_pgsql.c

Propchange: trunk/
------------------------------------------------------------------------------
--- branch-12-merged (original)
+++ branch-12-merged Tue Dec 31 15:39:45 2013
@@ -1,1 +1,1 @@
-/branches/12:1-398558,398560-398577,398579-399305,399307-401390,401392-403290,403292-403778,403781-404568,404581,404592
+/branches/12:1-398558,398560-398577,398579-399305,399307-401390,401392-403290,403292-403778,403781-404568,404581,404592,404605

Modified: trunk/cel/cel_pgsql.c
URL: http://svnview.digium.com/svn/asterisk/trunk/cel/cel_pgsql.c?view=diff&rev=404606&r1=404605&r2=404606
==============================================================================
--- trunk/cel/cel_pgsql.c (original)
+++ trunk/cel/cel_pgsql.c Tue Dec 31 15:39:45 2013
@@ -346,8 +346,9 @@
 static int my_unload_module(void)
 {
 	struct columns *current;
+
+	ast_cel_backend_unregister(PGSQL_BACKEND_NAME);
 	AST_RWLIST_WRLOCK(&psql_columns);
-	ast_cel_backend_unregister(PGSQL_BACKEND_NAME);
 	if (conn) {
 		PQfinish(conn);
 		conn = NULL;




More information about the asterisk-commits mailing list