From dcbb83ac1fb63bb335fb038fc6b951a19fc69129 Mon Sep 17 00:00:00 2001 From: MelwareDE Date: Wed, 5 Oct 2011 09:09:23 +0000 Subject: [PATCH] Called from capi thread context 'ast_set_callerid' updates CDR. At same time CDR is updated from context of pbx thread (__ast_pbx_run). Pbx thread doen not uses channel lock. As resut memory blocks greed multiple times. --- chan_capi.c | 23 +++++++++++++++++++++-- chan_capi_qsig_ecma.c | 11 ++++++++++- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/chan_capi.c b/chan_capi.c index 5ee979c..c40f1fe 100644 --- a/chan_capi.c +++ b/chan_capi.c @@ -4907,7 +4907,16 @@ static void capidev_handle_diva_signaling_manufacturer_infications(struct capi_p if (length != 0) { capidev_read_name_from_diva_manufacturer_infications (data, &data[length], buffer, sizeof(buffer), &octet3a, i->vname, "Calling Party"); #ifdef CC_AST_HAS_VERSION_1_8 - ast_set_callerid(i->owner, NULL, buffer, NULL); + /* ast_set_callerid updates CDR, but __ast_pbx_run updates CDR too. + __ast_pbx_run does not uses the channel lock and this results in destruction + of CDR list + Do notcall this function until problem resolved + ast_set_callerid(i->owner, NULL, buffer, NULL); + Use code from ast_set_callerid but do not update CDR + */ + i->owner->caller.id.name.valid = 1; + ast_free(i->owner->caller.id.name.str); + i->owner->caller.id.name.str = ast_strdup(buffer); #else ast_free (i->owner->cid.cid_name); i->owner->cid.cid_name = ast_strdup(buffer); /* Save name to callerid */ @@ -5430,7 +5439,17 @@ static void capidev_handle_connect_indication( } i->owner->caller.id.number.presentation = callpres; - ast_set_callerid(i->owner, effective_cid, NULL, effective_cid); + /* Don't use ast_set_callerid() here because it will + generate a needless NewCallerID event + ast_set_callerid(i->owner, effective_cid, NULL, effective_cid); + */ + i->owner->caller.id.number.valid = 1; + ast_free(i->owner->caller.id.number.str); + i->owner->caller.id.number.str = ast_strdup(effective_cid); + + i->owner->caller.ani.number.valid = 1; + ast_free(i->owner->caller.ani.number.str); + i->owner->caller.ani.number.str = ast_strdup(effective_cid); } #else i->owner->cid.cid_pres = callpres; diff --git a/chan_capi_qsig_ecma.c b/chan_capi_qsig_ecma.c index af95cb4..1a3aded 100644 --- a/chan_capi_qsig_ecma.c +++ b/chan_capi_qsig_ecma.c @@ -76,7 +76,16 @@ void cc_qsig_op_ecma_isdn_namepres(struct cc_qsig_invokedata *invoke, struct cap switch (invoke->type) { case 0: /* Calling Name */ #ifdef CC_AST_HAS_VERSION_1_8 - ast_set_callerid(i->owner, NULL, callername, NULL); + /* ast_set_callerid updates CDR, but __ast_pbx_run updates CDR too. + __ast_pbx_run does not uses the channel lock and this results in destruction + of CDR list + Do notcall this function until problem resolved + ast_set_callerid(i->owner, NULL, callername, NULL); + Use code from ast_set_callerid but do not update CDR + */ + i->owner->caller.id.name.valid = 1; + ast_free(i->owner->caller.id.name.str); + i->owner->caller.id.name.str = ast_strdup(callername); #else i->owner->cid.cid_name = ast_strdup(callername); /* Save name to callerid */ #endif