diff options
author | Corey Farrell <git@cfware.com> | 2015-03-13 01:12:35 +0000 |
---|---|---|
committer | Corey Farrell <git@cfware.com> | 2015-03-13 01:12:35 +0000 |
commit | c08fd275bf8c45dc09084f104521cbff04eab25b (patch) | |
tree | 09cc14b9a9190254980ec88b981d6f561ec8a9b5 /channels/sig_pri.c | |
parent | 38ee441ea7debef3ebf6b162fc290b121fa3588d (diff) |
Logger: Convert 'struct ast_callid' to unsigned int.
Switch logger callid's from AO2 objects to simple integers.
This helps in two ways. Copying integers is faster than
referencing AO2 objects, so this will result in a small
reduction in logger overhead. This also erases the possibility
of an infinate loop caused by an invalid callid in
threadstorage.
ASTERISK-24833 #comment Committed callid conversion to trunk.
Reported by: Corey Farrell
Review: https://reviewboard.asterisk.org/r/4466/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432834 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/sig_pri.c')
-rw-r--r-- | channels/sig_pri.c | 55 |
1 files changed, 21 insertions, 34 deletions
diff --git a/channels/sig_pri.c b/channels/sig_pri.c index 37d3e49c7..a7cc3d7a7 100644 --- a/channels/sig_pri.c +++ b/channels/sig_pri.c @@ -2030,11 +2030,10 @@ static void *do_idle_thread(void *v_pvt) int timeout_ms = 30000; int ms; struct timeval start; - struct ast_callid *callid; + ast_callid callid; if ((callid = ast_channel_callid(chan))) { ast_callid_threadassoc_add(callid); - callid = ast_callid_unref(callid); } ast_verb(3, "Initiating idle call on channel %s\n", ast_channel_name(chan)); @@ -2089,7 +2088,7 @@ static void *pri_ss_thread(void *data) int res; int len; int timeout; - struct ast_callid *callid; + ast_callid callid; if (!chan) { /* We lost the owner before we could get started. */ @@ -2098,7 +2097,6 @@ static void *pri_ss_thread(void *data) if ((callid = ast_channel_callid(chan))) { ast_callid_threadassoc_add(callid); - ast_callid_unref(callid); } /* @@ -5369,13 +5367,12 @@ static void sig_pri_moh_fsm_event(struct ast_channel *chan, struct sig_pri_chan * \internal * \brief Set callid threadstorage for the pri_dchannel thread when a new call is created * - * \return A new callid which has been bound to threadstorage. The return must be - * unreffed and the threadstorage should be unbound when the pri_dchannel - * primary loop wraps. + * \return A new callid which has been bound to threadstorage. The threadstorage + * should be unbound when the pri_dchannel primary loop wraps. */ -static struct ast_callid *func_pri_dchannel_new_callid(void) +static ast_callid func_pri_dchannel_new_callid(void) { - struct ast_callid *callid = ast_create_callid(); + ast_callid callid = ast_create_callid(); if (callid) { ast_callid_threadassoc_add(callid); @@ -5394,20 +5391,18 @@ static struct ast_callid *func_pri_dchannel_new_callid(void) * \note Assumes the pri->lock is already obtained. * \note Assumes the sig_pri_lock_private(pri->pvts[chanpos]) is already obtained. * - * \return a reference to the callid bound to the channel which has also - * been bound to threadstorage if it exists. If this returns non-NULL, - * the callid must be unreffed and the threadstorage should be unbound - * when the pri_dchannel primary loop wraps. + * \return The callid which has also been bound to threadstorage if it exists. + * The threadstorage should be unbound when the pri_dchannel primary loop wraps. */ -static struct ast_callid *func_pri_dchannel_chanpos_callid(struct sig_pri_span *pri, int chanpos) +static ast_callid func_pri_dchannel_chanpos_callid(struct sig_pri_span *pri, int chanpos) { if (chanpos < 0) { - return NULL; + return 0; } sig_pri_lock_owner(pri, chanpos); if (pri->pvts[chanpos]->owner) { - struct ast_callid *callid; + ast_callid callid; callid = ast_channel_callid(pri->pvts[chanpos]->owner); ast_channel_unlock(pri->pvts[chanpos]->owner); if (callid) { @@ -5416,7 +5411,7 @@ static struct ast_callid *func_pri_dchannel_chanpos_callid(struct sig_pri_span * } } - return NULL; + return 0; } #if defined(HAVE_PRI_CALL_HOLD) @@ -5439,7 +5434,7 @@ static int sig_pri_handle_hold(struct sig_pri_span *pri, pri_event *ev) int chanpos_old; int chanpos_new; struct ast_channel *owner; - struct ast_callid *callid = NULL; + ast_callid callid = 0; chanpos_old = pri_find_principle_by_call(pri, ev->hold.call); if (chanpos_old < 0) { @@ -5499,7 +5494,6 @@ done_with_private:; } if (callid) { - ast_callid_unref(callid); ast_callid_threadassoc_remove(); } @@ -5523,7 +5517,7 @@ done_with_private:; static void sig_pri_handle_hold_ack(struct sig_pri_span *pri, pri_event *ev) { int chanpos; - struct ast_callid *callid; + ast_callid callid; /* * We were successfully put on hold by the remote party @@ -5555,7 +5549,6 @@ static void sig_pri_handle_hold_ack(struct sig_pri_span *pri, pri_event *ev) sig_pri_span_devstate_changed(pri); if (callid) { - ast_callid_unref(callid); ast_callid_threadassoc_remove(); } } @@ -5577,7 +5570,7 @@ static void sig_pri_handle_hold_ack(struct sig_pri_span *pri, pri_event *ev) static void sig_pri_handle_hold_rej(struct sig_pri_span *pri, pri_event *ev) { int chanpos; - struct ast_callid *callid; + ast_callid callid; chanpos = pri_find_principle(pri, ev->hold_rej.channel, ev->hold_rej.call); if (chanpos < 0) { @@ -5605,7 +5598,6 @@ static void sig_pri_handle_hold_rej(struct sig_pri_span *pri, pri_event *ev) sig_pri_unlock_private(pri->pvts[chanpos]); if (callid) { - ast_callid_unref(callid); ast_callid_threadassoc_remove(); } } @@ -5627,7 +5619,7 @@ static void sig_pri_handle_hold_rej(struct sig_pri_span *pri, pri_event *ev) static void sig_pri_handle_retrieve(struct sig_pri_span *pri, pri_event *ev) { int chanpos; - struct ast_callid *callid; + ast_callid callid; if (!(ev->retrieve.channel & PRI_HELD_CALL)) { /* The call is not currently held. */ @@ -5680,7 +5672,6 @@ static void sig_pri_handle_retrieve(struct sig_pri_span *pri, pri_event *ev) sig_pri_span_devstate_changed(pri); if (callid) { - ast_callid_unref(callid); ast_callid_threadassoc_remove(); } } @@ -5702,7 +5693,7 @@ static void sig_pri_handle_retrieve(struct sig_pri_span *pri, pri_event *ev) static void sig_pri_handle_retrieve_ack(struct sig_pri_span *pri, pri_event *ev) { int chanpos; - struct ast_callid *callid; + ast_callid callid; chanpos = pri_find_fixup_principle(pri, ev->retrieve_ack.channel, ev->retrieve_ack.call); @@ -5721,7 +5712,6 @@ static void sig_pri_handle_retrieve_ack(struct sig_pri_span *pri, pri_event *ev) sig_pri_span_devstate_changed(pri); if (callid) { - ast_callid_unref(callid); ast_callid_threadassoc_remove(); } } @@ -5743,7 +5733,7 @@ static void sig_pri_handle_retrieve_ack(struct sig_pri_span *pri, pri_event *ev) static void sig_pri_handle_retrieve_rej(struct sig_pri_span *pri, pri_event *ev) { int chanpos; - struct ast_callid *callid; + ast_callid callid; chanpos = pri_find_principle(pri, ev->retrieve_rej.channel, ev->retrieve_rej.call); if (chanpos < 0) { @@ -5772,7 +5762,6 @@ static void sig_pri_handle_retrieve_rej(struct sig_pri_span *pri, pri_event *ev) sig_pri_unlock_private(pri->pvts[chanpos]); if (callid) { - ast_callid_unref(callid); ast_callid_threadassoc_remove(); } } @@ -5892,7 +5881,7 @@ static void sig_pri_handle_setup(struct sig_pri_span *pri, pri_event *e) int need_dialtone; enum sig_pri_law law; int chanpos = -1; - struct ast_callid *callid = NULL; + ast_callid callid = 0; struct ast_channel *c; char plancallingnum[AST_MAX_EXTENSION]; char plancallingani[AST_MAX_EXTENSION]; @@ -6246,7 +6235,6 @@ static void sig_pri_handle_setup(struct sig_pri_span *pri, pri_event *e) setup_exit:; if (callid) { - ast_callid_unref(callid); ast_callid_threadassoc_remove(); } } @@ -6294,7 +6282,7 @@ static void *pri_dchannel(void *vpri) ast_log(LOG_WARNING, "Idle dial string '%s' lacks '@context'\n", pri->idleext); } for (;;) { - struct ast_callid *callid = NULL; + ast_callid callid = 0; for (i = 0; i < SIG_PRI_NUM_DCHANS; i++) { if (!pri->dchans[i]) @@ -7651,9 +7639,8 @@ static void *pri_dchannel(void *vpri) break; } - /* If a callid was set, we need to deref it and remove it from thread storage. */ + /* If a callid was set, we need to remove it from thread storage. */ if (callid) { - callid = ast_callid_unref(callid); ast_callid_threadassoc_remove(); } } |