From: Richard Mudgett Date: Mon, 16 May 2011 20:33:37 +0000 (+0000) Subject: Deadlock between generic CCSS agent and native ISDN CCSS. X-Git-Tag: 1.8.5-rc1~11^2~110 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=933cf293cd99037fe62d329ad40797a4137b61ea;p=thirdparty%2Fasterisk.git Deadlock between generic CCSS agent and native ISDN CCSS. Deadlock can occur when the generic CCSS agent is deleting duplicate CC offers and the native ISDN CC driver is processing an incoming CC message. The cc_core_instances container lock cannot be held when an agent or monitor callback is invoked without the possibility of a deadlock. * Make kill_duplicate_offers() remove the reference in cc_core_instances outside of the container lock. JIRA AST-566 JIRA SWP-3469 git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@319259 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/main/ccss.c b/main/ccss.c index c3383fba2d..b292771e08 100644 --- a/main/ccss.c +++ b/main/ccss.c @@ -2226,7 +2226,18 @@ static long count_agents(const char * const caller, const int core_id_exception) static void kill_duplicate_offers(char *caller) { unsigned long match_flags = MATCH_NO_REQUEST; - ao2_t_callback_data(cc_core_instances, OBJ_UNLINK | OBJ_NODATA, match_agent, caller, &match_flags, "Killing duplicate offers"); + struct ao2_iterator *dups_iter; + + /* + * Must remove the ref that was in cc_core_instances outside of + * the container lock to prevent deadlock. + */ + dups_iter = ao2_t_callback_data(cc_core_instances, OBJ_MULTIPLE | OBJ_UNLINK, + match_agent, caller, &match_flags, "Killing duplicate offers"); + if (dups_iter) { + /* Now actually unref any duplicate offers by simply destroying the iterator. */ + ao2_iterator_destroy(dups_iter); + } } static void check_callback_sanity(const struct ast_cc_agent_callbacks *callbacks)