summaryrefslogtreecommitdiff
path: root/channels
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
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')
-rw-r--r--channels/chan_bridge_media.c2
-rw-r--r--channels/chan_dahdi.c56
-rw-r--r--channels/chan_iax2.c37
-rw-r--r--channels/chan_motif.c8
-rw-r--r--channels/chan_sip.c61
-rw-r--r--channels/sig_analog.c7
-rw-r--r--channels/sig_pri.c55
-rw-r--r--channels/sig_ss7.c14
-rw-r--r--channels/sip/dialplan_functions.c2
-rw-r--r--channels/sip/include/dialog.h2
-rw-r--r--channels/sip/include/sip.h2
11 files changed, 88 insertions, 158 deletions
diff --git a/channels/chan_bridge_media.c b/channels/chan_bridge_media.c
index d7eeebf26..529fa2652 100644
--- a/channels/chan_bridge_media.c
+++ b/channels/chan_bridge_media.c
@@ -118,8 +118,8 @@ static struct ast_channel *media_request_helper(struct ast_format_cap *cap, cons
const struct ast_channel *requestor, const char *data, struct ast_channel_tech *tech, const char *role)
{
struct ast_channel *chan;
+ ast_callid callid;
- RAII_VAR(struct ast_callid *, callid, NULL, ast_callid_cleanup);
RAII_VAR(struct ast_unreal_pvt *, pvt, NULL, ao2_cleanup);
if (!(pvt = ast_unreal_alloc(sizeof(*pvt), ast_unreal_destructor, cap))) {
diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c
index 53899d869..e3f5c81ff 100644
--- a/channels/chan_dahdi.c
+++ b/channels/chan_dahdi.c
@@ -2232,13 +2232,13 @@ static void my_swap_subchannels(void *pvt, enum analog_sub a, struct ast_channel
*
* \param callid_created value returned from ast_callid_threadstorage_auto()
*/
-static struct ast_channel *dahdi_new_callid_clean(struct dahdi_pvt *i, int state, int startpbx, int idx, int law, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, struct ast_callid *callid, int callid_created);
+static struct ast_channel *dahdi_new_callid_clean(struct dahdi_pvt *i, int state, int startpbx, int idx, int law, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, ast_callid callid, int callid_created);
-static struct ast_channel *dahdi_new(struct dahdi_pvt *i, int state, int startpbx, int idx, int law, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, struct ast_callid *callid);
+static struct ast_channel *dahdi_new(struct dahdi_pvt *i, int state, int startpbx, int idx, int law, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, ast_callid callid);
static struct ast_channel *my_new_analog_ast_channel(void *pvt, int state, int startpbx, enum analog_sub sub, const struct ast_channel *requestor)
{
- struct ast_callid *callid = NULL;
+ ast_callid callid = 0;
int callid_created = ast_callid_threadstorage_auto(&callid);
struct dahdi_pvt *p = pvt;
int dsub = analogsub_to_dahdisub(sub);
@@ -2265,7 +2265,7 @@ static struct ast_channel *my_new_pri_ast_channel(void *pvt, int state,
struct dahdi_pvt *p = pvt;
int audio;
int newlaw = -1;
- struct ast_callid *callid = NULL;
+ ast_callid callid = 0;
int callid_created = ast_callid_threadstorage_auto(&callid);
switch (p->sig) {
@@ -3193,7 +3193,7 @@ static struct ast_channel *my_new_ss7_ast_channel(void *pvt, int state, enum sig
struct dahdi_pvt *p = pvt;
int audio;
int newlaw;
- struct ast_callid *callid = NULL;
+ ast_callid callid = 0;
int callid_created = ast_callid_threadstorage_auto(&callid);
/* Set to audio mode at this point */
@@ -3677,7 +3677,7 @@ static void dahdi_r2_on_call_offered(openr2_chan_t *r2chan, const char *ani, con
{
struct dahdi_pvt *p;
struct ast_channel *c;
- struct ast_callid *callid = NULL;
+ ast_callid callid = 0;
int callid_created = ast_callid_threadstorage_auto(&callid);
ast_verbose("MFC/R2 call offered on chan %d. ANI = %s, DNIS = %s, Category = %s\n",
openr2_chan_get_number(r2chan), ani ? ani : "(restricted)", dnis,
@@ -3746,7 +3746,7 @@ static void dahdi_r2_on_call_accepted(openr2_chan_t *r2chan, openr2_call_mode_t
{
struct dahdi_pvt *p = NULL;
struct ast_channel *c = NULL;
- struct ast_callid *callid = NULL;
+ ast_callid callid = 0;
int callid_created = ast_callid_threadstorage_auto(&callid);
p = openr2_chan_get_client_data(r2chan);
dahdi_ec_enable(p);
@@ -7901,7 +7901,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
p->subs[SUB_REAL].needflash = 1;
goto winkflashdone;
} else if (!check_for_conference(p)) {
- struct ast_callid *callid = NULL;
+ ast_callid callid = 0;
int callid_created;
char cid_num[256];
char cid_name[256];
@@ -9013,7 +9013,7 @@ static struct ast_str *create_channel_name(struct dahdi_pvt *i)
return chan_name;
}
-static struct ast_channel *dahdi_new_callid_clean(struct dahdi_pvt *i, int state, int startpbx, int idx, int law, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, struct ast_callid *callid, int callid_created)
+static struct ast_channel *dahdi_new_callid_clean(struct dahdi_pvt *i, int state, int startpbx, int idx, int law, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, ast_callid callid, int callid_created)
{
struct ast_channel *new_channel = dahdi_new(i, state, startpbx, idx, law, assignedids, requestor, callid);
@@ -9022,7 +9022,7 @@ static struct ast_channel *dahdi_new_callid_clean(struct dahdi_pvt *i, int state
return new_channel;
}
-static struct ast_channel *dahdi_new(struct dahdi_pvt *i, int state, int startpbx, int idx, int law, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, struct ast_callid *callid)
+static struct ast_channel *dahdi_new(struct dahdi_pvt *i, int state, int startpbx, int idx, int law, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, ast_callid callid)
{
struct ast_channel *tmp;
struct ast_format_cap *caps;
@@ -10620,7 +10620,7 @@ static void *mwi_thread(void *data)
if (i & DAHDI_IOMUX_SIGEVENT) {
struct ast_channel *chan;
- struct ast_callid *callid = NULL;
+ ast_callid callid = 0;
int callid_created;
/* If we get an event, screen out events that we do not act on.
@@ -11054,7 +11054,7 @@ static struct dahdi_pvt *handle_init_event(struct dahdi_pvt *i, int event)
int res;
pthread_t threadid;
struct ast_channel *chan;
- struct ast_callid *callid = NULL;
+ ast_callid callid = 0;
int callid_created;
/* Handle an event on a given channel for the monitor thread. */
@@ -11540,7 +11540,7 @@ static void *do_monitor(void *data)
doomed = analog_handle_init_event(i->sig_pvt, ANALOG_EVENT_DTMFCID);
i->dtmfcid_holdoff_state = 1;
} else {
- struct ast_callid *callid = NULL;
+ ast_callid callid = 0;
int callid_created = ast_callid_threadstorage_auto(&callid);
chan = dahdi_new(i, AST_STATE_PRERING, 0, SUB_REAL, 0, NULL, NULL, callid);
if (!chan) {
@@ -13342,7 +13342,7 @@ static struct ast_channel *dahdi_request(const char *type, struct ast_format_cap
int transcapdigital = 0;
#endif /* defined(HAVE_PRI) || defined(HAVE_SS7) */
struct dahdi_starting_point start;
- struct ast_callid *callid = NULL;
+ ast_callid callid = 0;
int callid_created = ast_callid_threadstorage_auto(&callid);
ast_mutex_lock(&iflock);
@@ -13664,12 +13664,12 @@ static void dahdi_ss7_message(struct ss7 *ss7, char *s)
if (ss7) {
for (i = 0; i < NUM_SPANS; i++) {
if (linksets[i].ss7.ss7 == ss7) {
- ast_verbose_callid(NULL, "[%d] %s", i + 1, s);
+ ast_verbose_callid(0, "[%d] %s", i + 1, s);
return;
}
}
}
- ast_verbose_callid(NULL, "%s", s);
+ ast_verbose_callid(0, "%s", s);
}
#endif /* defined(HAVE_SS7) */
@@ -13681,12 +13681,12 @@ static void dahdi_ss7_error(struct ss7 *ss7, char *s)
if (ss7) {
for (i = 0; i < NUM_SPANS; i++) {
if (linksets[i].ss7.ss7 == ss7) {
- ast_log_callid(LOG_ERROR, NULL, "[%d] %s", i + 1, s);
+ ast_log_callid(LOG_ERROR, 0, "[%d] %s", i + 1, s);
return;
}
}
}
- ast_log_callid(LOG_ERROR, NULL, "%s", s);
+ ast_log_callid(LOG_ERROR, 0, "%s", s);
}
#endif /* defined(HAVE_SS7) */
@@ -13796,22 +13796,22 @@ static void dahdi_pri_message(struct pri *pri, char *s)
}
if (-1 < span) {
if (1 < dchancount) {
- ast_verbose_callid(NULL, "[PRI Span: %d D-Channel: %d] %s", span + 1, dchan, s);
+ ast_verbose_callid(0, "[PRI Span: %d D-Channel: %d] %s", span + 1, dchan, s);
} else {
- ast_verbose_callid(NULL, "PRI Span: %d %s", span + 1, s);
+ ast_verbose_callid(0, "PRI Span: %d %s", span + 1, s);
}
} else {
- ast_verbose_callid(NULL, "PRI Span: ? %s", s);
+ ast_verbose_callid(0, "PRI Span: ? %s", s);
}
} else {
- ast_verbose_callid(NULL, "PRI Span: ? %s", s);
+ ast_verbose_callid(0, "PRI Span: ? %s", s);
}
ast_mutex_lock(&pridebugfdlock);
if (pridebugfd >= 0) {
if (write(pridebugfd, s, strlen(s)) < 0) {
- ast_log_callid(LOG_WARNING, NULL, "write() failed: %s\n", strerror(errno));
+ ast_log_callid(LOG_WARNING, 0, "write() failed: %s\n", strerror(errno));
}
}
@@ -13847,22 +13847,22 @@ static void dahdi_pri_error(struct pri *pri, char *s)
}
if (-1 < span) {
if (1 < dchancount) {
- ast_log_callid(LOG_ERROR, NULL, "[PRI Span: %d D-Channel: %d] %s", span + 1, dchan, s);
+ ast_log_callid(LOG_ERROR, 0, "[PRI Span: %d D-Channel: %d] %s", span + 1, dchan, s);
} else {
- ast_log_callid(LOG_ERROR, NULL, "PRI Span: %d %s", span + 1, s);
+ ast_log_callid(LOG_ERROR, 0, "PRI Span: %d %s", span + 1, s);
}
} else {
- ast_log_callid(LOG_ERROR, NULL, "PRI Span: ? %s", s);
+ ast_log_callid(LOG_ERROR, 0, "PRI Span: ? %s", s);
}
} else {
- ast_log_callid(LOG_ERROR, NULL, "PRI Span: ? %s", s);
+ ast_log_callid(LOG_ERROR, 0, "PRI Span: ? %s", s);
}
ast_mutex_lock(&pridebugfdlock);
if (pridebugfd >= 0) {
if (write(pridebugfd, s, strlen(s)) < 0) {
- ast_log_callid(LOG_WARNING, NULL, "write() failed: %s\n", strerror(errno));
+ ast_log_callid(LOG_WARNING, 0, "write() failed: %s\n", strerror(errno));
}
}
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;
}
diff --git a/channels/chan_motif.c b/channels/chan_motif.c
index 48f1b1fc7..13baa70eb 100644
--- a/channels/chan_motif.c
+++ b/channels/chan_motif.c
@@ -317,7 +317,7 @@ struct jingle_session {
struct ast_format_cap *peercap; /*!< Peer codec capabilities */
unsigned int outgoing:1; /*!< Whether this is an outgoing leg or not */
unsigned int gone:1; /*!< In the eyes of Jingle this session is already gone */
- struct ast_callid *callid; /*!< Bound session call-id */
+ ast_callid callid; /*!< Bound session call-id */
};
static const char desc[] = "Motif Jingle Channel";
@@ -585,10 +585,6 @@ static void jingle_session_destructor(void *obj)
ao2_cleanup(session->jointcap);
ao2_cleanup(session->peercap);
- if (session->callid) {
- ast_callid_unref(session->callid);
- }
-
ast_string_field_free_memory(session);
}
@@ -704,7 +700,7 @@ static void jingle_enable_video(struct jingle_session *session)
static struct jingle_session *jingle_alloc(struct jingle_endpoint *endpoint, const char *from, const char *sid)
{
struct jingle_session *session;
- struct ast_callid *callid;
+ ast_callid callid;
struct ast_sockaddr tmp;
if (!(session = ao2_alloc(sizeof(*session), jingle_session_destructor))) {
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 13c55462c..4ace51197 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -2039,7 +2039,7 @@ static int sip_cc_monitor_request_cc(struct ast_cc_monitor *monitor, int *availa
return -1;
}
- if (!(monitor_instance->subscription_pvt = sip_alloc(NULL, NULL, 0, SIP_SUBSCRIBE, NULL, NULL))) {
+ if (!(monitor_instance->subscription_pvt = sip_alloc(NULL, NULL, 0, SIP_SUBSCRIBE, NULL, 0))) {
return -1;
}
@@ -6575,11 +6575,6 @@ void __sip_destroy(struct sip_pvt *p, int lockowner, int lockdialoglist)
ao2_ref(p->last_device_state_info, -1);
p->last_device_state_info = NULL;
}
-
- /* Lastly, kill the callid associated with the pvt */
- if (p->logger_callid) {
- ast_callid_unref(p->logger_callid);
- }
}
/*! \brief update_call_counter: Handle call_limit for SIP devices
@@ -7886,7 +7881,7 @@ static int sip_indicate(struct ast_channel *ast, int condition, const void *data
*
* \return New ast_channel locked.
*/
-static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *title, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, struct ast_callid *callid)
+static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *title, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, ast_callid callid)
{
struct ast_format_cap *caps;
struct ast_channel *tmp;
@@ -8640,12 +8635,8 @@ static struct sip_st_dlg* sip_st_alloc(struct sip_pvt *const p)
return p->stimer;
}
-static void sip_pvt_callid_set(struct sip_pvt *pvt, struct ast_callid *callid)
+static void sip_pvt_callid_set(struct sip_pvt *pvt, ast_callid callid)
{
- if (pvt->logger_callid) {
- ast_callid_unref(pvt->logger_callid);
- }
- ast_callid_ref(callid);
pvt->logger_callid = callid;
}
@@ -8654,7 +8645,7 @@ static void sip_pvt_callid_set(struct sip_pvt *pvt, struct ast_callid *callid)
* remember to release the reference.
*/
struct sip_pvt *sip_alloc(ast_string_field callid, struct ast_sockaddr *addr,
- int useglobal_nat, const int intended_method, struct sip_request *req, struct ast_callid *logger_callid)
+ int useglobal_nat, const int intended_method, struct sip_request *req, ast_callid logger_callid)
{
struct sip_pvt *p;
@@ -9043,20 +9034,14 @@ static void forked_invite_init(struct sip_request *req, const char *new_theirtag
{
struct sip_pvt *p;
const char *callid;
- struct ast_callid *logger_callid;
+ ast_callid logger_callid;
sip_pvt_lock(original);
callid = ast_strdupa(original->callid);
logger_callid = original->logger_callid;
- if (logger_callid) {
- ast_callid_ref(logger_callid);
- }
sip_pvt_unlock(original);
p = sip_alloc(callid, addr, 1, SIP_INVITE, req, logger_callid);
- if (logger_callid) {
- ast_callid_unref(logger_callid);
- }
if (!p) {
return; /* alloc error */
}
@@ -9339,7 +9324,7 @@ static struct sip_pvt *find_call(struct sip_request *req, struct ast_sockaddr *a
/* See if the method is capable of creating a dialog */
if (sip_methods[intended_method].can_create == CAN_CREATE_DIALOG) {
struct sip_pvt *p = NULL;
- struct ast_callid *logger_callid = NULL;
+ ast_callid logger_callid = 0;
if (intended_method == SIP_INVITE) {
logger_callid = ast_create_callid();
@@ -9358,10 +9343,6 @@ static struct sip_pvt *find_call(struct sip_request *req, struct ast_sockaddr *a
transmit_response_using_temp(callid, addr, 1, intended_method, req, "500 Server internal error");
ast_debug(4, "Failed allocating SIP dialog, sending 500 Server internal error and giving up\n");
}
- /* If we created an ast_callid for an invite, we need to free it now. */
- if (logger_callid) {
- ast_callid_unref(logger_callid);
- }
return p; /* can be NULL */
} else if( sip_methods[intended_method].can_create == CAN_CREATE_DIALOG_UNSUPPORTED_METHOD) {
/* A method we do not support, let's take it on the volley */
@@ -14229,7 +14210,7 @@ static int transmit_publish(struct sip_epa_entry *epa_entry, enum sip_publish_ty
epa_entry->publish_type = publish_type;
- if (!(pvt = sip_alloc(NULL, NULL, 0, SIP_PUBLISH, NULL, NULL))) {
+ if (!(pvt = sip_alloc(NULL, NULL, 0, SIP_PUBLISH, NULL, 0))) {
return -1;
}
@@ -14532,7 +14513,7 @@ static int __sip_subscribe_mwi_do(struct sip_subscription_mwi *mwi)
}
/* Create a dialog that we will use for the subscription */
- if (!(mwi->call = sip_alloc(NULL, NULL, 0, SIP_SUBSCRIBE, NULL, NULL))) {
+ if (!(mwi->call = sip_alloc(NULL, NULL, 0, SIP_SUBSCRIBE, NULL, 0))) {
return -1;
}
@@ -15111,7 +15092,7 @@ static int manager_sipnotify(struct mansession *s, const struct message *m)
channame += 4;
}
- if (!(p = sip_alloc(NULL, NULL, 0, SIP_NOTIFY, NULL, NULL))) {
+ if (!(p = sip_alloc(NULL, NULL, 0, SIP_NOTIFY, NULL, 0))) {
astman_send_error(s, m, "Unable to build sip pvt data for notify (memory/socket error)");
return 0;
}
@@ -15436,7 +15417,7 @@ static int transmit_register(struct sip_registry *r, int sipmethod, const char *
r->callid_valid = TRUE;
}
/* Allocate SIP dialog for registration */
- if (!(p = sip_alloc( r->callid, NULL, 0, SIP_REGISTER, NULL, NULL))) {
+ if (!(p = sip_alloc( r->callid, NULL, 0, SIP_REGISTER, NULL, 0))) {
ast_log(LOG_WARNING, "Unable to allocate registration transaction (memory or socket error)\n");
return 0;
}
@@ -22018,7 +21999,7 @@ static char *sip_cli_notify(struct ast_cli_entry *e, int cmd, struct ast_cli_arg
char buf[512];
struct ast_variable *header, *var;
- if (!(p = sip_alloc(NULL, NULL, 0, SIP_NOTIFY, NULL, NULL))) {
+ if (!(p = sip_alloc(NULL, NULL, 0, SIP_NOTIFY, NULL, 0))) {
ast_log(LOG_WARNING, "Unable to build sip pvt data for notify (memory/socket error)\n");
return CLI_FAILURE;
}
@@ -26757,7 +26738,7 @@ static int sip_msg_send(const struct ast_msg *msg, const char *to, const char *f
struct ast_msg_var_iterator *iter;
struct sip_peer *peer_ptr;
- if (!(pvt = sip_alloc(NULL, NULL, 0, SIP_MESSAGE, NULL, NULL))) {
+ if (!(pvt = sip_alloc(NULL, NULL, 0, SIP_MESSAGE, NULL, 0))) {
return -1;
}
@@ -28658,7 +28639,7 @@ static int sip_send_mwi_to_peer(struct sip_peer *peer, int cache_only)
} else {
ao2_unlock(peer);
/* Build temporary dialog for this message */
- if (!(p = sip_alloc(NULL, NULL, 0, SIP_NOTIFY, NULL, NULL))) {
+ if (!(p = sip_alloc(NULL, NULL, 0, SIP_NOTIFY, NULL, 0))) {
update_peer_lastmsgssent(peer, -1, 0);
return -1;
}
@@ -29431,7 +29412,7 @@ static int sip_poke_peer(struct sip_peer *peer, int force)
peer->call = dialog_unref(peer->call, "unref dialog peer->call");
/* peer->call = sip_destroy(peer->call); */
}
- if (!(p = sip_alloc(NULL, NULL, 0, SIP_OPTIONS, NULL, NULL))) {
+ if (!(p = sip_alloc(NULL, NULL, 0, SIP_OPTIONS, NULL, 0))) {
return -1;
}
peer->call = dialog_ref(p, "copy sip alloc from p to peer->call");
@@ -29631,7 +29612,7 @@ static struct ast_channel *sip_request_call(const char *type, struct ast_format_
char dialstring[256];
char *remote_address;
enum ast_transport transport = 0;
- struct ast_callid *callid;
+ ast_callid callid;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(peerorhost);
AST_APP_ARG(exten);
@@ -29664,9 +29645,6 @@ static struct ast_channel *sip_request_call(const char *type, struct ast_format_
if (!(p = sip_alloc(NULL, NULL, 0, SIP_INVITE, NULL, callid))) {
ast_log(LOG_ERROR, "Unable to build sip pvt data for '%s' (Out of memory or socket error)\n", dest);
*cause = AST_CAUSE_SWITCH_CONGESTION;
- if (callid) {
- ast_callid_unref(callid);
- }
return NULL;
}
@@ -29681,9 +29659,6 @@ static struct ast_channel *sip_request_call(const char *type, struct ast_format_
/* sip_destroy(p); */
ast_log(LOG_ERROR, "Unable to build option SIP data structure - Out of memory\n");
*cause = AST_CAUSE_SWITCH_CONGESTION;
- if (callid) {
- ast_callid_unref(callid);
- }
return NULL;
}
@@ -29765,9 +29740,6 @@ static struct ast_channel *sip_request_call(const char *type, struct ast_format_
dialog_unlink_all(p);
dialog_unref(p, "unref dialog p UNREGISTERED");
/* sip_destroy(p); */
- if (callid) {
- ast_callid_unref(callid);
- }
return NULL;
}
if (ast_strlen_zero(p->peername) && ext)
@@ -29828,9 +29800,6 @@ static struct ast_channel *sip_request_call(const char *type, struct ast_format_
sip_pvt_lock(p);
tmpc = sip_new(p, AST_STATE_DOWN, host, assignedids, requestor, callid); /* Place the call */
- if (callid) {
- callid = ast_callid_unref(callid);
- }
sip_pvt_unlock(p);
if (!tmpc) {
diff --git a/channels/sig_analog.c b/channels/sig_analog.c
index 1d44a29b9..0608c3429 100644
--- a/channels/sig_analog.c
+++ b/channels/sig_analog.c
@@ -1715,7 +1715,7 @@ static void *__analog_ss_thread(void *data)
int len = 0;
int res;
int idx;
- struct ast_callid *callid;
+ ast_callid callid;
RAII_VAR(struct ast_features_pickup_config *, pickup_cfg, NULL, ao2_cleanup);
const char *pickupexten;
@@ -1730,7 +1730,6 @@ static void *__analog_ss_thread(void *data)
if ((callid = ast_channel_callid(chan))) {
ast_callid_threadassoc_add(callid);
- ast_callid_unref(callid);
}
/* in the bizarre case where the channel has become a zombie before we
@@ -3194,7 +3193,7 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
ast_queue_control(p->subs[ANALOG_SUB_REAL].owner, AST_CONTROL_FLASH);
goto winkflashdone;
} else if (!analog_check_for_conference(p)) {
- struct ast_callid *callid = NULL;
+ ast_callid callid = 0;
int callid_created;
char cid_num[256];
char cid_name[256];
@@ -3657,7 +3656,7 @@ void *analog_handle_init_event(struct analog_pvt *i, int event)
int res;
pthread_t threadid;
struct ast_channel *chan;
- struct ast_callid *callid = NULL;
+ ast_callid callid = 0;
int callid_created;
ast_debug(1, "channel (%d) - signaling (%d) - event (%s)\n",
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();
}
}
diff --git a/channels/sig_ss7.c b/channels/sig_ss7.c
index a7df9e9e0..98530da6b 100644
--- a/channels/sig_ss7.c
+++ b/channels/sig_ss7.c
@@ -976,7 +976,7 @@ static void ss7_start_call(struct sig_ss7_chan *p, struct sig_ss7_linkset *links
struct ast_channel *c;
char tmp[256];
char *strp;
- struct ast_callid *callid = NULL;
+ ast_callid callid = 0;
int callid_created = ast_callid_threadstorage_auto(&callid);
if (!(linkset->flags & LINKSET_FLAG_EXPLICITACM)) {
@@ -1315,14 +1315,13 @@ static int ss7_pres_scr2cid_pres(char presentation_ind, char screening_ind)
* \note Assumes the ss7->lock is already obtained.
* \note Assumes the sig_ss7_lock_private(ss7->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
+ * \return The callid bound to the channel which has also been bound to threadstorage
+ * if it exists. If this returns non-zero, the threadstorage should be unbound
* before the while loop wraps in ss7_linkset.
*/
-static struct ast_callid *func_ss7_linkset_callid(struct sig_ss7_linkset *linkset, int chanpos)
+static ast_callid func_ss7_linkset_callid(struct sig_ss7_linkset *linkset, int chanpos)
{
- struct ast_callid *callid = NULL;
+ ast_callid callid = 0;
sig_ss7_lock_owner(linkset, chanpos);
if (linkset->pvts[chanpos]->owner) {
callid = ast_channel_callid(linkset->pvts[chanpos]->owner);
@@ -1460,7 +1459,7 @@ void *ss7_linkset(void *data)
}
while ((e = ss7_check_event(ss7))) {
- struct ast_callid *callid = NULL;
+ ast_callid callid = 0;
int chanpos = -1;
char cause_str[30];
@@ -2342,7 +2341,6 @@ void *ss7_linkset(void *data)
/* Call ID stuff needs to be cleaned up here */
if (callid) {
- callid = ast_callid_unref(callid);
ast_callid_threadassoc_remove();
}
}
diff --git a/channels/sip/dialplan_functions.c b/channels/sip/dialplan_functions.c
index c3e113a83..03441aa72 100644
--- a/channels/sip/dialplan_functions.c
+++ b/channels/sip/dialplan_functions.c
@@ -340,7 +340,7 @@ AST_TEST_DEFINE(test_sip_rtpqos_1)
ast_rtp_engine_register2(&test_engine, NULL);
/* Have to associate this with a SIP pvt and an ast_channel */
- if (!(p = sip_alloc(NULL, NULL, 0, SIP_NOTIFY, NULL, NULL))) {
+ if (!(p = sip_alloc(0, NULL, 0, SIP_NOTIFY, NULL, 0))) {
res = AST_TEST_NOT_RUN;
goto done;
}
diff --git a/channels/sip/include/dialog.h b/channels/sip/include/dialog.h
index ea2fb457c..6b08109a1 100644
--- a/channels/sip/include/dialog.h
+++ b/channels/sip/include/dialog.h
@@ -35,7 +35,7 @@ struct sip_pvt *dialog_ref_debug(struct sip_pvt *p, const char *tag, char *file,
struct sip_pvt *dialog_unref_debug(struct sip_pvt *p, const char *tag, char *file, int line, const char *func);
struct sip_pvt *sip_alloc(ast_string_field callid, struct ast_sockaddr *sin,
- int useglobal_nat, const int intended_method, struct sip_request *req, struct ast_callid *logger_callid);
+ int useglobal_nat, const int intended_method, struct sip_request *req, ast_callid logger_callid);
void sip_scheddestroy_final(struct sip_pvt *p, int ms);
void sip_scheddestroy(struct sip_pvt *p, int ms);
int sip_cancel_destroy(struct sip_pvt *p);
diff --git a/channels/sip/include/sip.h b/channels/sip/include/sip.h
index 68c2ee860..ab682ebfa 100644
--- a/channels/sip/include/sip.h
+++ b/channels/sip/include/sip.h
@@ -991,7 +991,7 @@ struct sip_msg_hdr {
struct sip_pvt {
struct sip_pvt *next; /*!< Next dialog in chain */
enum invitestates invitestate; /*!< Track state of SIP_INVITEs */
- struct ast_callid *logger_callid; /*!< Identifier for call used in log messages */
+ ast_callid logger_callid; /*!< Identifier for call used in log messages */
int method; /*!< SIP method that opened this dialog */
AST_DECLARE_STRING_FIELDS(
AST_STRING_FIELD(callid); /*!< Global CallID */