summaryrefslogtreecommitdiff
path: root/main/db.c
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2012-03-20 17:31:28 +0000
committerRichard Mudgett <rmudgett@digium.com>2012-03-20 17:31:28 +0000
commit334f13d8b8ea94f388af20c144f24097089e5e1c (patch)
tree61918aebd949a7f4675e79e847e91d7bc4414477 /main/db.c
parent3714e8b1e528fd3d19ac169ef689160f4bfad2eb (diff)
Allow AMI action callback to be reentrant.
Fix AMI module reload deadlock regression from ASTERISK-18479 when it tried to fix the race between calling an AMI action callback and unregistering that action. Refixes ASTERISK-13784 broken by ASTERISK-17785 change. Locking the ao2 object guaranteed that there were no active callbacks that mattered when ast_manager_unregister() was called. Unfortunately, this causes the deadlock situation. The patch stops locking the ao2 object to allow multiple threads to invoke the callback re-entrantly. There is no way to guarantee a module unload will not crash because of an active callback. The code attempts to minimize the chance with the registered flag and the maximum 5 second delay before ast_manager_unregister() returns. The trunk version of the patch changes the API to fix the race condition correctly to prevent the module code from unloading from memory while an action callback is active. * Don't hold the lock while calling the AMI action callback. (closes issue ASTERISK-19487) Reported by: Philippe Lindheimer Review: https://reviewboard.asterisk.org/r/1818/ Review: https://reviewboard.asterisk.org/r/1820/ ........ Merged revisions 359979 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 359980 from http://svn.asterisk.org/svn/asterisk/branches/10 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@359981 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/db.c')
-rw-r--r--main/db.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/main/db.c b/main/db.c
index 8778554ed..c3e89dcb6 100644
--- a/main/db.c
+++ b/main/db.c
@@ -933,9 +933,9 @@ int astdb_init(void)
ast_register_atexit(astdb_atexit);
ast_cli_register_multiple(cli_database, ARRAY_LEN(cli_database));
- ast_manager_register_xml("DBGet", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, manager_dbget);
- ast_manager_register_xml("DBPut", EVENT_FLAG_SYSTEM, manager_dbput);
- ast_manager_register_xml("DBDel", EVENT_FLAG_SYSTEM, manager_dbdel);
- ast_manager_register_xml("DBDelTree", EVENT_FLAG_SYSTEM, manager_dbdeltree);
+ ast_manager_register_xml_core("DBGet", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, manager_dbget);
+ ast_manager_register_xml_core("DBPut", EVENT_FLAG_SYSTEM, manager_dbput);
+ ast_manager_register_xml_core("DBDel", EVENT_FLAG_SYSTEM, manager_dbdel);
+ ast_manager_register_xml_core("DBDelTree", EVENT_FLAG_SYSTEM, manager_dbdeltree);
return 0;
}