#define LOCAL_BRIDGE (1 << 3) /*!< Report back the "true" channel as being bridged to */
#define LOCAL_MOH_PASSTHRU (1 << 4) /*!< Pass through music on hold start/stop frames */
-/*
+/*!
* \brief Send a pvt in with no locks held and get all locks
*
* \note NO locks should be held prior to calling this function
struct ast_channel *chan = NULL;
struct ast_channel *owner = NULL;
+ ao2_lock(p);
for (;;) {
- ao2_lock(p);
if (p->chan) {
chan = p->chan;
ast_channel_ref(chan);
} else if(chan) {
ast_channel_lock(chan);
}
- ao2_lock(p);
} else {
/* lock both channels first, then get the pvt lock */
ast_channel_lock_both(chan, owner);
- ao2_lock(p);
}
+ ao2_lock(p);
/* Now that we have all the locks, validate that nothing changed */
if (p->owner != owner || p->chan != chan) {
ast_channel_unlock(chan);
chan = ast_channel_unref(chan);
}
- ao2_unlock(p);
continue;
}
static int local_setoption(struct ast_channel *ast, int option, void * data, int datalen)
{
int res = 0;
- struct local_pvt *p = NULL;
+ struct local_pvt *p;
struct ast_channel *otherchan = NULL;
ast_chan_write_info_t *write_info;
ast_channel_unlock(otherchan);
setoption_cleanup:
- if (p) {
- ao2_ref(p, -1);
- }
+ ao2_ref(p, -1);
if (otherchan) {
ast_channel_unref(otherchan);
}
return -1;
}
- ao2_lock(p);
ao2_ref(p, 1);
+ ao2_lock(p);
isoutbound = IS_OUTBOUND(ast, p);
if (isoutbound) {
/* Pass along answer since somebody answered us */
return -1;
}
- ao2_lock(p);
ao2_ref(p, 1); /* ref for local_queue_frame */
+ ao2_lock(p);
isoutbound = IS_OUTBOUND(ast, p);
f.data.ptr = (char *) text;
f.datalen = strlen(text) + 1;
return -1;
}
- ao2_lock(p);
ao2_ref(p, 1); /* ref for local_queue_frame */
+ ao2_lock(p);
isoutbound = IS_OUTBOUND(ast, p);
f.subclass.integer = subclass;
f.data.ptr = (char *)data;