summaryrefslogtreecommitdiff
path: root/channels/chan_iax2.c
diff options
context:
space:
mode:
authorCorey Farrell <git@cfware.com>2015-03-13 01:12:35 +0000
committerCorey Farrell <git@cfware.com>2015-03-13 01:12:35 +0000
commitc08fd275bf8c45dc09084f104521cbff04eab25b (patch)
tree09cc14b9a9190254980ec88b981d6f561ec8a9b5 /channels/chan_iax2.c
parent38ee441ea7debef3ebf6b162fc290b121fa3588d (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/chan_iax2.c')
-rw-r--r--channels/chan_iax2.c37
1 files changed, 9 insertions, 28 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index dbc1bb05c..93c56e676 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -683,7 +683,7 @@ struct chan_iax2_pvt {
/*! Socket to send/receive on for this call */
int sockfd;
/*! ast_callid bound to dialog */
- struct ast_callid *callid;
+ ast_callid callid;
/*! Last received voice format */
iax2_format voiceformat;
/*! Last received video format */
@@ -1107,30 +1107,22 @@ static void signal_condition(ast_mutex_t *lock, ast_cond_t *cond)
*/
static struct chan_iax2_pvt *iaxs[IAX_MAX_CALLS];
-static struct ast_callid *iax_pvt_callid_get(int callno)
+static ast_callid iax_pvt_callid_get(int callno)
{
- if (iaxs[callno]->callid) {
- return ast_callid_ref(iaxs[callno]->callid);
- }
- return NULL;
+ return iaxs[callno]->callid;
}
-static void iax_pvt_callid_set(int callno, struct ast_callid *callid)
+static void iax_pvt_callid_set(int callno, ast_callid callid)
{
- if (iaxs[callno]->callid) {
- ast_callid_unref(iaxs[callno]->callid);
- }
- ast_callid_ref(callid);
iaxs[callno]->callid = callid;
}
static void iax_pvt_callid_new(int callno)
{
- struct ast_callid *callid = ast_create_callid();
+ ast_callid callid = ast_create_callid();
char buffer[AST_CALLID_BUFFER_LENGTH];
ast_callid_strnprint(buffer, sizeof(buffer), callid);
iax_pvt_callid_set(callno, callid);
- ast_callid_unref(callid);
}
/*!
@@ -2204,11 +2196,6 @@ static void pvt_destructor(void *obj)
jb_destroy(pvt->jb);
ast_string_field_free_memory(pvt);
}
-
- if (pvt->callid) {
- ast_callid_unref(pvt->callid);
- }
-
}
static struct chan_iax2_pvt *new_iax(struct ast_sockaddr *addr, const char *host)
@@ -5797,7 +5784,7 @@ static struct ast_channel *ast_iax2_new(int callno, int state, iax2_format capab
struct ast_variable *v = NULL;
struct ast_format_cap *native;
struct ast_format *tmpfmt;
- struct ast_callid *callid;
+ ast_callid callid;
char *peer_name = NULL;
if (!(i = iaxs[callno])) {
@@ -10218,12 +10205,11 @@ static int socket_process_helper(struct iax2_thread *thread)
}
if (fr->callno > 0) {
- struct ast_callid *mount_callid;
+ ast_callid mount_callid;
ast_mutex_lock(&iaxsl[fr->callno]);
if (iaxs[fr->callno] && ((mount_callid = iax_pvt_callid_get(fr->callno)))) {
/* Bind to thread */
ast_callid_threadassoc_add(mount_callid);
- ast_callid_unref(mount_callid);
}
}
@@ -11920,11 +11906,9 @@ immediatedial:
static int socket_process(struct iax2_thread *thread)
{
- struct ast_callid *callid;
int res = socket_process_helper(thread);
- if ((callid = ast_read_threadstorage_callid())) {
+ if (ast_read_threadstorage_callid()) {
ast_callid_threadassoc_remove();
- callid = ast_callid_unref(callid);
}
return res;
}
@@ -12405,7 +12389,7 @@ static struct ast_channel *iax2_request(const char *type, struct ast_format_cap
struct parsed_dial_string pds;
struct create_addr_info cai;
char *tmpstr;
- struct ast_callid *callid;
+ ast_callid callid;
memset(&pds, 0, sizeof(pds));
tmpstr = ast_strdupa(data);
@@ -12508,9 +12492,6 @@ static struct ast_channel *iax2_request(const char *type, struct ast_format_cap
ao2_ref(format, -1);
}
- if (callid) {
- ast_callid_unref(callid);
- }
return c;
}