summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--UPGRADE.txt6
-rw-r--r--apps/app_mixmonitor.c5
-rw-r--r--apps/confbridge/conf_chan_announce.c2
-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
-rw-r--r--include/asterisk/bridge.h2
-rw-r--r--include/asterisk/bridge_channel.h2
-rw-r--r--include/asterisk/channel.h4
-rw-r--r--include/asterisk/core_unreal.h3
-rw-r--r--include/asterisk/logger.h62
-rw-r--r--main/autoservice.c7
-rw-r--r--main/bridge.c4
-rw-r--r--main/bridge_basic.c6
-rw-r--r--main/bridge_channel.c2
-rw-r--r--main/channel.c8
-rw-r--r--main/channel_internal_api.c20
-rw-r--r--main/cli.c3
-rw-r--r--main/core_local.c5
-rw-r--r--main/core_unreal.c13
-rw-r--r--main/dial.c7
-rw-r--r--main/features.c1
-rw-r--r--main/logger.c137
-rw-r--r--main/pbx.c7
-rw-r--r--res/ari/resource_bridges.c3
33 files changed, 182 insertions, 373 deletions
diff --git a/UPGRADE.txt b/UPGRADE.txt
index af77d85f2..3514f5fae 100644
--- a/UPGRADE.txt
+++ b/UPGRADE.txt
@@ -31,5 +31,11 @@ chan_dahdi:
ring-ring-ring pattern would exceed the pattern limits and stop
Caller-ID detection.
+Core:
+
+Logging:
+ - The first callid created is now 1 instead of 0. The value 0
+ is now reserved to represent a lack of callid.
+
===========================================================
===========================================================
diff --git a/apps/app_mixmonitor.c b/apps/app_mixmonitor.c
index e6f4053c0..35df01433 100644
--- a/apps/app_mixmonitor.c
+++ b/apps/app_mixmonitor.c
@@ -295,12 +295,12 @@ struct vm_recipient {
struct mixmonitor {
struct ast_audiohook audiohook;
- struct ast_callid *callid;
char *filename;
char *filename_read;
char *filename_write;
char *post_process;
char *name;
+ ast_callid callid;
unsigned int flags;
struct ast_autochan *autochan;
struct mixmonitor_ds *mixmonitor_ds;
@@ -545,9 +545,6 @@ static void mixmonitor_free(struct mixmonitor *mixmonitor)
/* clean stringfields */
ast_string_field_free_memory(mixmonitor);
- if (mixmonitor->callid) {
- ast_callid_unref(mixmonitor->callid);
- }
ast_free(mixmonitor);
}
}
diff --git a/apps/confbridge/conf_chan_announce.c b/apps/confbridge/conf_chan_announce.c
index 6596a8537..b850e27f7 100644
--- a/apps/confbridge/conf_chan_announce.c
+++ b/apps/confbridge/conf_chan_announce.c
@@ -103,7 +103,7 @@ static struct ast_channel *announce_request(const char *type, struct ast_format_
ao2_ref(pvt->bridge, +1);
chan = ast_unreal_new_channels(&pvt->base, conf_announce_get_tech(),
- AST_STATE_UP, AST_STATE_UP, NULL, NULL, assignedids, requestor, NULL);
+ AST_STATE_UP, AST_STATE_UP, NULL, NULL, assignedids, requestor, 0);
if (chan) {
ast_answer(pvt->base.owner);
ast_answer(pvt->base.chan);
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 */
diff --git a/include/asterisk/bridge.h b/include/asterisk/bridge.h
index 8fa0f36ed..8243a1ddb 100644
--- a/include/asterisk/bridge.h
+++ b/include/asterisk/bridge.h
@@ -280,7 +280,7 @@ struct ast_bridge {
/*! Per-bridge topics */
struct stasis_cp_single *topics;
/*! Call ID associated with the bridge */
- struct ast_callid *callid;
+ ast_callid callid;
/*! Linked list of channels participating in the bridge */
AST_LIST_HEAD_NOLOCK(, ast_bridge_channel) channels;
/*! Queue of actions to perform on the bridge. */
diff --git a/include/asterisk/bridge_channel.h b/include/asterisk/bridge_channel.h
index 1d071a014..c53848511 100644
--- a/include/asterisk/bridge_channel.h
+++ b/include/asterisk/bridge_channel.h
@@ -138,7 +138,7 @@ struct ast_bridge_channel {
/*! Copy of write format used by chan before join */
struct ast_format *write_format;
/*! Call ID associated with bridge channel */
- struct ast_callid *callid;
+ ast_callid callid;
/*! A clone of the roles living on chan when the bridge channel joins the bridge. This may require some opacification */
struct bridge_roles_datastore *bridge_roles;
/*! Linked list information */
diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h
index b6755e256..6dd3ac49c 100644
--- a/include/asterisk/channel.h
+++ b/include/asterisk/channel.h
@@ -4046,12 +4046,12 @@ void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tec
enum ast_channel_adsicpe ast_channel_adsicpe(const struct ast_channel *chan);
void ast_channel_adsicpe_set(struct ast_channel *chan, enum ast_channel_adsicpe value);
enum ast_channel_state ast_channel_state(const struct ast_channel *chan);
-struct ast_callid *ast_channel_callid(const struct ast_channel *chan);
+ast_callid ast_channel_callid(const struct ast_channel *chan);
/*!
* \pre chan is locked
*/
-void ast_channel_callid_set(struct ast_channel *chan, struct ast_callid *value);
+void ast_channel_callid_set(struct ast_channel *chan, ast_callid value);
/* XXX Internal use only, make sure to move later */
void ast_channel_state_set(struct ast_channel *chan, enum ast_channel_state);
diff --git a/include/asterisk/core_unreal.h b/include/asterisk/core_unreal.h
index e118c74bd..45045e0a9 100644
--- a/include/asterisk/core_unreal.h
+++ b/include/asterisk/core_unreal.h
@@ -40,7 +40,6 @@ extern "C" {
/* Forward declare some struct names */
struct ast_format_cap;
-struct ast_callid;
/* ------------------------------------------------------------------- */
@@ -207,7 +206,7 @@ struct ast_unreal_pvt *ast_unreal_alloc(size_t size, ao2_destructor_fn destructo
struct ast_channel *ast_unreal_new_channels(struct ast_unreal_pvt *p,
const struct ast_channel_tech *tech, int semi1_state, int semi2_state,
const char *exten, const char *context, const struct ast_assigned_ids *assignedids,
- const struct ast_channel *requestor, struct ast_callid *callid);
+ const struct ast_channel *requestor, ast_callid callid);
/*!
* \brief Setup unreal owner and chan channels before initiating call.
diff --git a/include/asterisk/logger.h b/include/asterisk/logger.h
index 84e6991f0..feb9c7eda 100644
--- a/include/asterisk/logger.h
+++ b/include/asterisk/logger.h
@@ -63,7 +63,7 @@ void ast_log(int level, const char *file, int line, const char *function, const
__attribute__((format(printf, 5, 6)));
/* XXX needs documentation */
-struct ast_callid;
+typedef unsigned int ast_callid;
/*! \brief Used for sending a log message with a known call_id
This is a modified logger function which is functionally identical to the above logger function,
@@ -77,7 +77,7 @@ struct ast_callid;
\param callid This is the ast_callid that is associated with the log message. May be NULL.
\param fmt This is what is important. The format is the same as your favorite breed of printf. You know how that works, right? :-)
*/
-void ast_log_callid(int level, const char *file, int line, const char *function, struct ast_callid *callid, const char *fmt, ...)
+void ast_log_callid(int level, const char *file, int line, const char *function, ast_callid callid, const char *fmt, ...)
__attribute__((format(printf, 6, 7)));
/*!
@@ -117,12 +117,12 @@ void __attribute__((format(printf, 5, 6))) __ast_verbose(const char *file, int l
* allow you to specify that a log will never display a call id even when there is a call id bound to the
* thread.
*/
-void __attribute__((format(printf, 6, 7))) __ast_verbose_callid(const char *file, int line, const char *func, int level, struct ast_callid *callid, const char *fmt, ...);
+void __attribute__((format(printf, 6, 7))) __ast_verbose_callid(const char *file, int line, const char *func, int level, ast_callid callid, const char *fmt, ...);
#define ast_verbose(...) __ast_verbose(__FILE__, __LINE__, __PRETTY_FUNCTION__, -1, __VA_ARGS__)
#define ast_verbose_callid(callid, ...) __ast_verbose_callid(__FILE__, __LINE__, __PRETTY_FUNCTION__, -1, callid, __VA_ARGS__)
-void __attribute__((format(printf, 6, 0))) __ast_verbose_ap(const char *file, int line, const char *func, int level, struct ast_callid *callid, const char *fmt, va_list ap);
+void __attribute__((format(printf, 6, 0))) __ast_verbose_ap(const char *file, int line, const char *func, int level, ast_callid callid, const char *fmt, va_list ap);
void __attribute__((format(printf, 2, 3))) ast_child_verbose(int level, const char *fmt, ...);
@@ -277,49 +277,17 @@ const char *ast_logger_get_dateformat(void);
/*!
* \brief factory function to create a new uniquely identifying callid.
*
- * \retval ast_callid struct pointer containing the call id
- *
- * \note The newly created callid will be referenced upon creation and this function should be
- * paired with a call to ast_callid_unref()
+ * \retval The call id
*/
-struct ast_callid *ast_create_callid(void);
+ast_callid ast_create_callid(void);
/*!
* \brief extracts the callerid from the thread
*
- * \retval ast_callid reference to call_id related to the thread
- * \retval NULL if no call_id is present in the thread
- *
- * This reference must be unreffed before it loses scope to prevent memory leaks.
- */
-struct ast_callid *ast_read_threadstorage_callid(void);
-
-/*!
- * \brief Increase callid reference count
- *
- * \param c the ast_callid
- *
- * \retval c always
- */
-#define ast_callid_ref(c) ({ ao2_ref(c, +1); (c); })
-
-/*!
- * \brief Decrease callid reference count
- *
- * \param c the ast_callid
- *
- * \retval NULL always
- */
-#define ast_callid_unref(c) ({ ao2_ref(c, -1); (struct ast_callid *) (NULL); })
-
-/*!
- * \brief Cleanup a callid reference (NULL safe ao2 unreference)
- *
- * \param c the ast_callid
- *
- * \retval NULL always
+ * \retval Non-zero Call id related to the thread
+ * \retval 0 if no call_id is present in the thread
*/
-#define ast_callid_cleanup(c) ({ ao2_cleanup(c); (struct ast_callid *) (NULL); })
+ast_callid ast_read_threadstorage_callid(void);
/*!
* \brief Sets what is stored in the thread storage to the given
@@ -328,7 +296,7 @@ struct ast_callid *ast_read_threadstorage_callid(void);
* \retval 0 - success
* \retval non-zero - failure
*/
-int ast_callid_threadassoc_change(struct ast_callid *callid);
+int ast_callid_threadassoc_change(ast_callid callid);
/*!
* \brief Adds a known callid to thread storage of the calling thread
@@ -336,7 +304,7 @@ int ast_callid_threadassoc_change(struct ast_callid *callid);
* \retval 0 - success
* \retval non-zero - failure
*/
-int ast_callid_threadassoc_add(struct ast_callid *callid);
+int ast_callid_threadassoc_add(ast_callid callid);
/*!
* \brief Removes callid from thread storage of the calling thread
@@ -351,12 +319,12 @@ int ast_callid_threadassoc_remove(void);
* If not, then a new one will be created, bound to the thread, and a reference
* to it will be stored.
*
- * \param callid pointer to struct pointer used to store the referenced callid
+ * \param callid pointer to store the callid
* \retval 0 - callid was found
* \retval 1 - callid was created
* \retval -1 - the function failed somehow (presumably memory problems)
*/
-int ast_callid_threadstorage_auto(struct ast_callid **callid);
+int ast_callid_threadstorage_auto(ast_callid *callid);
/*!
* \brief Use in conjunction with ast_callid_threadstorage_auto. Cleans up the
@@ -365,7 +333,7 @@ int ast_callid_threadstorage_auto(struct ast_callid **callid);
* \param callid The callid set by ast_callid_threadstorage_auto
* \param callid_created The integer returned through ast_callid_threadstorage_auto
*/
-void ast_callid_threadstorage_auto_clean(struct ast_callid *callid, int callid_created);
+void ast_callid_threadstorage_auto_clean(ast_callid callid, int callid_created);
/*!
* \brief copy a string representation of the callid into a target string
@@ -374,7 +342,7 @@ void ast_callid_threadstorage_auto_clean(struct ast_callid *callid, int callid_c
* \param buffer_size maximum writable length of the string (Less than 13 will result in truncation)
* \param callid Callid for which string is being requested
*/
-void ast_callid_strnprint(char *buffer, size_t buffer_size, struct ast_callid *callid);
+void ast_callid_strnprint(char *buffer, size_t buffer_size, ast_callid callid);
/*!
* \brief Send a log message to a dynamically registered log level
diff --git a/main/autoservice.c b/main/autoservice.c
index 371464398..9630990d1 100644
--- a/main/autoservice.c
+++ b/main/autoservice.c
@@ -78,7 +78,7 @@ static int as_chan_list_state;
static void *autoservice_run(void *ign)
{
- struct ast_callid *callid = NULL;
+ ast_callid callid = 0;
struct ast_frame hangup_frame = {
.frametype = AST_FRAME_CONTROL,
.subclass.integer = AST_CONTROL_HANGUP,
@@ -132,9 +132,6 @@ static void *autoservice_run(void *ign)
callid = ast_channel_callid(chan);
ast_callid_threadassoc_change(callid);
- if (callid) {
- callid = ast_callid_unref(callid);
- }
f = ast_read(chan);
@@ -184,7 +181,7 @@ static void *autoservice_run(void *ign)
* If we did, we'd need to ast_frfree(f) if (f). */
}
- ast_callid_threadassoc_change(NULL);
+ ast_callid_threadassoc_change(0);
asthread = AST_PTHREADT_NULL;
return NULL;
diff --git a/main/bridge.c b/main/bridge.c
index 6737fa62f..4bfd58377 100644
--- a/main/bridge.c
+++ b/main/bridge.c
@@ -681,9 +681,7 @@ static void destroy_bridge(void *obj)
bridge->technology = NULL;
}
- if (bridge->callid) {
- bridge->callid = ast_callid_unref(bridge->callid);
- }
+ bridge->callid = 0;
cleanup_video_mode(bridge);
diff --git a/main/bridge_basic.c b/main/bridge_basic.c
index e3318b9f2..522a7d40c 100644
--- a/main/bridge_basic.c
+++ b/main/bridge_basic.c
@@ -2367,12 +2367,11 @@ static void recall_callback(struct ast_dial *dial)
*/
static void common_recall_channel_setup(struct ast_channel *recall, struct ast_channel *transferer)
{
- struct ast_callid *callid;
+ ast_callid callid;
callid = ast_read_threadstorage_callid();
if (callid) {
ast_channel_callid_set(recall, callid);
- ast_callid_unref(callid);
}
ast_channel_inherit_variables(transferer, recall);
@@ -2973,7 +2972,7 @@ static enum attended_transfer_stimulus wait_for_stimulus(struct attended_transfe
static void *attended_transfer_monitor_thread(void *data)
{
struct attended_transfer_properties *props = data;
- struct ast_callid *callid;
+ ast_callid callid;
/*
* Set thread callid to the transferer's callid because we
@@ -3018,7 +3017,6 @@ static void *attended_transfer_monitor_thread(void *data)
attended_transfer_properties_shutdown(props);
if (callid) {
- ast_callid_unref(callid);
ast_callid_threadassoc_remove();
}
diff --git a/main/bridge_channel.c b/main/bridge_channel.c
index ac72c8bc2..e9f1ca0bd 100644
--- a/main/bridge_channel.c
+++ b/main/bridge_channel.c
@@ -2755,7 +2755,7 @@ static void bridge_channel_destroy(void *obj)
struct ast_frame *fr;
if (bridge_channel->callid) {
- bridge_channel->callid = ast_callid_unref(bridge_channel->callid);
+ bridge_channel->callid = 0;
}
if (bridge_channel->bridge) {
diff --git a/main/channel.c b/main/channel.c
index 76b6d524a..58daf5732 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -2174,7 +2174,7 @@ static void ast_channel_destructor(void *obj)
struct varshead *headp;
struct ast_datastore *datastore;
char device_name[AST_CHANNEL_NAME];
- struct ast_callid *callid;
+ ast_callid callid;
/* Stop monitoring */
if (ast_channel_monitor(chan)) {
@@ -2311,9 +2311,6 @@ static void ast_channel_destructor(void *obj)
}
ast_channel_nativeformats_set(chan, NULL);
- if (callid) {
- ast_callid_unref(callid);
- }
ast_channel_named_callgroups_set(chan, NULL);
ast_channel_named_pickupgroups_set(chan, NULL);
@@ -5904,7 +5901,7 @@ struct ast_channel *ast_request(const char *type, struct ast_format_cap *request
}
if (requestor) {
- struct ast_callid *callid;
+ ast_callid callid;
ast_channel_lock_both(c, (struct ast_channel *) requestor);
@@ -5912,7 +5909,6 @@ struct ast_channel *ast_request(const char *type, struct ast_format_cap *request
callid = ast_channel_callid(requestor);
if (callid) {
ast_channel_callid_set(c, callid);
- callid = ast_callid_unref(callid);
}
ast_channel_unlock(c);
diff --git a/main/channel_internal_api.c b/main/channel_internal_api.c
index 624bdd1cb..0ff844440 100644
--- a/main/channel_internal_api.c
+++ b/main/channel_internal_api.c
@@ -96,7 +96,7 @@ struct ast_channel {
struct ast_tone_zone *zone; /*!< Tone zone as set in indications.conf or
* in the CHANNEL dialplan function */
struct ast_channel_monitor *monitor; /*!< Channel monitoring */
- struct ast_callid *callid; /*!< Bound call identifier pointer */
+ ast_callid callid; /*!< Bound call identifier pointer */
#ifdef HAVE_EPOLL
struct ast_epoll_data *epfd_data[AST_MAX_FDS];
#endif
@@ -914,15 +914,11 @@ enum ast_channel_state ast_channel_state(const struct ast_channel *chan)
{
return chan->state;
}
-struct ast_callid *ast_channel_callid(const struct ast_channel *chan)
+ast_callid ast_channel_callid(const struct ast_channel *chan)
{
- if (chan->callid) {
- ast_callid_ref(chan->callid);
- return chan->callid;
- }
- return NULL;
+ return chan->callid;
}
-void ast_channel_callid_set(struct ast_channel *chan, struct ast_callid *callid)
+void ast_channel_callid_set(struct ast_channel *chan, ast_callid callid)
{
char call_identifier_from[AST_CALLID_BUFFER_LENGTH];
char call_identifier_to[AST_CALLID_BUFFER_LENGTH];
@@ -931,11 +927,9 @@ void ast_channel_callid_set(struct ast_channel *chan, struct ast_callid *callid)
if (chan->callid) {
ast_callid_strnprint(call_identifier_from, sizeof(call_identifier_from), chan->callid);
ast_debug(3, "Channel Call ID changing from %s to %s\n", call_identifier_from, call_identifier_to);
- /* unbind if already set */
- ast_callid_unref(chan->callid);
}
- chan->callid = ast_callid_ref(callid);
+ chan->callid = callid;
ast_test_suite_event_notify("CallIDChange",
"State: CallIDChange\r\n"
@@ -1165,9 +1159,7 @@ void ast_channel_set_unbridged(struct ast_channel *chan, int value)
void ast_channel_callid_cleanup(struct ast_channel *chan)
{
- if (chan->callid) {
- chan->callid = ast_callid_unref(chan->callid);
- }
+ chan->callid = 0;
}
/* Typedef accessors */
diff --git a/main/cli.c b/main/cli.c
index f0eb30e33..c30ad5ed6 100644
--- a/main/cli.c
+++ b/main/cli.c
@@ -1528,7 +1528,7 @@ static char *handle_showchan(struct ast_cli_entry *e, int cmd, struct ast_cli_ar
struct ast_str *read_transpath = ast_str_alloca(256);
struct ast_str *codec_buf = ast_str_alloca(64);
struct ast_bridge *bridge;
- struct ast_callid *callid;
+ ast_callid callid;
char callid_buf[32];
switch (cmd) {
@@ -1583,7 +1583,6 @@ static char *handle_showchan(struct ast_cli_entry *e, int cmd, struct ast_cli_ar
callid = ast_channel_callid(chan);
if (callid) {
ast_callid_strnprint(callid_buf, sizeof(callid_buf), callid);
- ast_callid_unref(callid);
}
ast_str_append(&output, 0,
diff --git a/main/core_local.c b/main/core_local.c
index 54915ecfe..934cf86bf 100644
--- a/main/core_local.c
+++ b/main/core_local.c
@@ -885,7 +885,7 @@ static struct ast_channel *local_request(const char *type, struct ast_format_cap
{
struct local_pvt *p;
struct ast_channel *chan;
- struct ast_callid *callid;
+ ast_callid callid;
/* Allocate a new private structure and then Asterisk channels */
p = local_alloc(data, cap);
@@ -898,9 +898,6 @@ static struct ast_channel *local_request(const char *type, struct ast_format_cap
if (chan) {
ao2_link(locals, p);
}
- if (callid) {
- ast_callid_unref(callid);
- }
ao2_ref(p, -1); /* kill the ref from the alloc */
return chan;
diff --git a/main/core_unreal.c b/main/core_unreal.c
index 23d80328c..f26642429 100644
--- a/main/core_unreal.c
+++ b/main/core_unreal.c
@@ -717,12 +717,11 @@ int ast_unreal_channel_push_to_bridge(struct ast_channel *ast, struct ast_bridge
struct ast_bridge_features *features;
struct ast_channel *chan;
struct ast_channel *owner;
+ ast_callid bridge_callid;
RAII_VAR(struct ast_unreal_pvt *, p, NULL, ao2_cleanup);
- RAII_VAR(struct ast_callid *, bridge_callid, NULL, ast_callid_cleanup);
-
ast_bridge_lock(bridge);
- bridge_callid = bridge->callid ? ast_callid_ref(bridge->callid) : NULL;
+ bridge_callid = bridge->callid;
ast_bridge_unlock(bridge);
{
@@ -751,8 +750,8 @@ int ast_unreal_channel_push_to_bridge(struct ast_channel *ast, struct ast_bridge
}
if (bridge_callid) {
- struct ast_callid *chan_callid;
- struct ast_callid *owner_callid;
+ ast_callid chan_callid;
+ ast_callid owner_callid;
/* chan side call ID setting */
ast_channel_lock(chan);
@@ -762,7 +761,6 @@ int ast_unreal_channel_push_to_bridge(struct ast_channel *ast, struct ast_bridge
ast_channel_callid_set(chan, bridge_callid);
}
ast_channel_unlock(chan);
- ast_callid_cleanup(chan_callid);
/* owner side call ID setting */
ast_channel_lock(owner);
@@ -773,7 +771,6 @@ int ast_unreal_channel_push_to_bridge(struct ast_channel *ast, struct ast_bridge
}
ast_channel_unlock(owner);
- ast_callid_cleanup(owner_callid);
}
/* We are done with the owner now that its call ID matches the bridge */
@@ -923,7 +920,7 @@ struct ast_unreal_pvt *ast_unreal_alloc(size_t size, ao2_destructor_fn destructo
struct ast_channel *ast_unreal_new_channels(struct ast_unreal_pvt *p,
const struct ast_channel_tech *tech, int semi1_state, int semi2_state,
const char *exten, const char *context, const struct ast_assigned_ids *assignedids,
- const struct ast_channel *requestor, struct ast_callid *callid)
+ const struct ast_channel *requestor, ast_callid callid)
{
struct ast_channel *owner;
struct ast_channel *chan;
diff --git a/main/dial.c b/main/dial.c
index 827b5ef23..210715556 100644
--- a/main/dial.c
+++ b/main/dial.c
@@ -56,7 +56,7 @@ struct ast_dial {
void *user_data; /*!< Attached user data */
AST_LIST_HEAD(, ast_dial_channel) channels; /*!< Channels being dialed */
pthread_t thread; /*!< Thread (if running in async) */
- struct ast_callid *callid; /*!< callid pointer (if running in async) */
+ ast_callid callid; /*!< callid (if running in async) */
ast_mutex_t lock; /*! Lock to protect the thread information above */
};
@@ -1118,11 +1118,6 @@ int ast_dial_destroy(struct ast_dial *dial)
/* Lock be gone! */
ast_mutex_destroy(&dial->lock);
- /* Get rid of the reference to the ast_callid */
- if (dial->callid) {
- ast_callid_unref(dial->callid);
- }
-
/* Free structure */
ast_free(dial);
diff --git a/main/features.c b/main/features.c
index 870c57f1a..f5993d3f7 100644
--- a/main/features.c
+++ b/main/features.c
@@ -314,7 +314,6 @@ struct ast_bridge_thread_obj
struct ast_bridge_config bconfig;
struct ast_channel *chan;
struct ast_channel *peer;
- struct ast_callid *callid; /*<! callid pointer (Only used to bind thread) */
unsigned int return_to_pbx:1;
};
diff --git a/main/logger.c b/main/logger.c
index c59c7ce6d..ad489f492 100644
--- a/main/logger.c
+++ b/main/logger.c
@@ -82,15 +82,10 @@ static int filesize_reload_needed;
static unsigned int global_logmask = 0xFFFF;
static int queuelog_init;
static int logger_initialized;
-static volatile int next_unique_callid; /* Used to assign unique call_ids to calls */
+static volatile int next_unique_callid = 1; /* Used to assign unique call_ids to calls */
static int display_callids;
-static void unique_callid_cleanup(void *data);
-struct ast_callid {
- int call_identifier; /* Numerical value of the call displayed in the logs */
-};
-
-AST_THREADSTORAGE_CUSTOM(unique_callid, NULL, unique_callid_cleanup);
+AST_THREADSTORAGE_CUSTOM(unique_callid, NULL, ast_free);
static enum rotatestrategy {
NONE = 0, /* Do not rotate log files at all, instead rely on external mechanisms */
@@ -151,7 +146,7 @@ struct logmsg {
int level;
int line;
int lwp;
- struct ast_callid *callid;
+ ast_callid callid;
AST_DECLARE_STRING_FIELDS(
AST_STRING_FIELD(date);
AST_STRING_FIELD(file);
@@ -164,9 +159,6 @@ struct logmsg {
static void logmsg_free(struct logmsg *msg)
{
- if (msg->callid) {
- ast_callid_unref(msg->callid);
- }
ast_free(msg);
}
@@ -1145,7 +1137,7 @@ static void ast_log_vsyslog(struct logmsg *msg)
char call_identifier_str[13];
if (msg->callid) {
- snprintf(call_identifier_str, sizeof(call_identifier_str), "[C-%08x]", (unsigned)msg->callid->call_identifier);
+ snprintf(call_identifier_str, sizeof(call_identifier_str), "[C-%08x]", msg->callid);
} else {
call_identifier_str[0] = '\0';
}
@@ -1224,7 +1216,7 @@ static void logger_print_normal(struct logmsg *logmsg)
char call_identifier_str[13];
if (logmsg->callid) {
- snprintf(call_identifier_str, sizeof(call_identifier_str), "[C-%08x]", (unsigned)logmsg->callid->call_identifier);
+ snprintf(call_identifier_str, sizeof(call_identifier_str), "[C-%08x]", logmsg->callid);
} else {
call_identifier_str[0] = '\0';
}
@@ -1485,45 +1477,35 @@ void close_logger(void)
AST_RWLIST_UNLOCK(&logchannels);
}
-void ast_callid_strnprint(char *buffer, size_t buffer_size, struct ast_callid *callid)
+void ast_callid_strnprint(char *buffer, size_t buffer_size, ast_callid callid)
{
- snprintf(buffer, buffer_size, "[C-%08x]", (unsigned)callid->call_identifier);
+ snprintf(buffer, buffer_size, "[C-%08x]", callid);
}
-struct ast_callid *ast_create_callid(void)
+ast_callid ast_create_callid(void)
{
- struct ast_callid *call;
+ ast_callid call;
- call = ao2_alloc_options(sizeof(*call), NULL, AO2_ALLOC_OPT_LOCK_NOLOCK);
- if (!call) {
- ast_log(LOG_ERROR, "Could not allocate callid struct.\n");
- return NULL;
- }
-
- call->call_identifier = ast_atomic_fetchadd_int(&next_unique_callid, +1);
+ call = ast_atomic_fetchadd_int(&next_unique_callid, +1);
#ifdef TEST_FRAMEWORK
- ast_debug(3, "CALL_ID [C-%08x] created by thread.\n", (unsigned)call->call_identifier);
+ ast_debug(3, "CALL_ID [C-%08x] created by thread.\n", call);
#endif
return call;
}
-struct ast_callid *ast_read_threadstorage_callid(void)
+ast_callid ast_read_threadstorage_callid(void)
{
- struct ast_callid **callid;
+ ast_callid *callid;
callid = ast_threadstorage_get(&unique_callid, sizeof(*callid));
- if (callid && *callid) {
- ast_callid_ref(*callid);
- return *callid;
- }
- return NULL;
+ return callid ? *callid : 0;
}
-int ast_callid_threadassoc_change(struct ast_callid *callid)
+int ast_callid_threadassoc_change(ast_callid callid)
{
- struct ast_callid **id = ast_threadstorage_get(&unique_callid, sizeof(*id));
+ ast_callid *id = ast_threadstorage_get(&unique_callid, sizeof(*id));
if (!id) {
ast_log(LOG_ERROR, "Failed to allocate thread storage.\n");
@@ -1532,27 +1514,24 @@ int ast_callid_threadassoc_change(struct ast_callid *callid)
if (*id && (*id != callid)) {
#ifdef TEST_FRAMEWORK
- ast_debug(3, "CALL_ID [C-%08x] being removed from thread.\n", (unsigned)(*id)->call_identifier);
+ ast_debug(3, "CALL_ID [C-%08x] being removed from thread.\n", *id);
#endif
- *id = ast_callid_unref(*id);
- *id = NULL;
+ *id = 0;
}
if (!(*id) && callid) {
- /* callid will be unreffed at thread destruction */
- ast_callid_ref(callid);
*id = callid;
#ifdef TEST_FRAMEWORK
- ast_debug(3, "CALL_ID [C-%08x] bound to thread.\n", (unsigned)callid->call_identifier);
+ ast_debug(3, "CALL_ID [C-%08x] bound to thread.\n", callid);
#endif
}
return 0;
}
-int ast_callid_threadassoc_add(struct ast_callid *callid)
+int ast_callid_threadassoc_add(ast_callid callid)
{
- struct ast_callid **pointing;
+ ast_callid *pointing;
pointing = ast_threadstorage_get(&unique_callid, sizeof(*pointing));
if (!(pointing)) {
@@ -1561,11 +1540,9 @@ int ast_callid_threadassoc_add(struct ast_callid *callid)
}
if (!(*pointing)) {
- /* callid will be unreffed at thread destruction */
- ast_callid_ref(callid);
*pointing = callid;
#ifdef TEST_FRAMEWORK
- ast_debug(3, "CALL_ID [C-%08x] bound to thread.\n", (unsigned)callid->call_identifier);
+ ast_debug(3, "CALL_ID [C-%08x] bound to thread.\n", callid);
#endif
} else {
ast_log(LOG_WARNING, "Attempted to ast_callid_threadassoc_add on thread already associated with a callid.\n");
@@ -1577,7 +1554,7 @@ int ast_callid_threadassoc_add(struct ast_callid *callid)
int ast_callid_threadassoc_remove(void)
{
- struct ast_callid **pointing;
+ ast_callid *pointing;
pointing = ast_threadstorage_get(&unique_callid, sizeof(*pointing));
if (!(pointing)) {
@@ -1590,16 +1567,16 @@ int ast_callid_threadassoc_remove(void)
return -1;
} else {
#ifdef TEST_FRAMEWORK
- ast_debug(3, "CALL_ID [C-%08x] being removed from thread.\n", (unsigned)(*pointing)->call_identifier);
+ ast_debug(3, "CALL_ID [C-%08x] being removed from thread.\n", *pointing);
#endif
- *pointing = ast_callid_unref(*pointing);
+ *pointing = 0;
return 0;
}
}
-int ast_callid_threadstorage_auto(struct ast_callid **callid)
+int ast_callid_threadstorage_auto(ast_callid *callid)
{
- struct ast_callid *tmp;
+ ast_callid tmp;
/* Start by trying to see if a callid is available from thread storage */
tmp = ast_read_threadstorage_callid();
@@ -1609,10 +1586,9 @@ int ast_callid_threadstorage_auto(struct ast_callid **callid)
}
/* If that failed, try to create a new one and bind it. */
- tmp = ast_create_callid();
- if (tmp) {
- ast_callid_threadassoc_add(tmp);
- *callid = tmp;
+ *callid = ast_create_callid();
+ if (*callid) {
+ ast_callid_threadassoc_add(*callid);
return 1;
}
@@ -1620,36 +1596,18 @@ int ast_callid_threadstorage_auto(struct ast_callid **callid)
return -1;
}
-void ast_callid_threadstorage_auto_clean(struct ast_callid *callid, int callid_created)
+void ast_callid_threadstorage_auto_clean(ast_callid callid, int callid_created)
{
- if (callid) {
+ if (callid && callid_created) {
/* If the callid was created rather than simply grabbed from the thread storage, we need to unbind here. */
- if (callid_created == 1) {
- ast_callid_threadassoc_remove();
- }
- callid = ast_callid_unref(callid);
+ ast_callid_threadassoc_remove();
}
}
/*!
- * \internal
- * \brief thread storage cleanup function for unique_callid
- */
-static void unique_callid_cleanup(void *data)
-{
- struct ast_callid **callid = data;
-
- if (*callid) {
- ast_callid_unref(*callid);
- }
-
- ast_free(data);
-}
-
-/*!
* \brief send log messages to syslog and/or the console
*/
-static void __attribute__((format(printf, 6, 0))) ast_log_full(int level, const char *file, int line, const char *function, struct ast_callid *callid, const char *fmt, va_list ap)
+static void __attribute__((format(printf, 6, 0))) ast_log_full(int level, const char *file, int line, const char *function, ast_callid callid, const char *fmt, va_list ap)
{
struct logmsg *logmsg = NULL;
struct ast_str *buf = NULL;
@@ -1701,8 +1659,7 @@ static void __attribute__((format(printf, 6, 0))) ast_log_full(int level, const
}
if (display_callids && callid) {
- logmsg->callid = ast_callid_ref(callid);
- /* callid will be unreffed at logmsg destruction */
+ logmsg->callid = callid;
}
/* Create our date/time */
@@ -1737,7 +1694,7 @@ static void __attribute__((format(printf, 6, 0))) ast_log_full(int level, const
void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...)
{
- struct ast_callid *callid;
+ ast_callid callid;
va_list ap;
callid = ast_read_threadstorage_callid();
@@ -1749,13 +1706,9 @@ void ast_log(int level, const char *file, int line, const char *function, const
ast_log_full(level, file, line, function, callid, fmt, ap);
}
va_end(ap);
-
- if (callid) {
- ast_callid_unref(callid);
- }
}
-void ast_log_callid(int level, const char *file, int line, const char *function, struct ast_callid *callid, const char *fmt, ...)
+void ast_log_callid(int level, const char *file, int line, const char *function, ast_callid callid, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
@@ -1792,7 +1745,7 @@ void ast_log_backtrace(void)
#endif /* defined(HAVE_BKTR) */
}
-void __ast_verbose_ap(const char *file, int line, const char *func, int level, struct ast_callid *callid, const char *fmt, va_list ap)
+void __ast_verbose_ap(const char *file, int line, const char *func, int level, ast_callid callid, const char *fmt, va_list ap)
{
const char *p;
struct ast_str *prefixed, *buf;
@@ -1845,7 +1798,7 @@ void __ast_verbose_ap(const char *file, int line, const char *func, int level, s
void __ast_verbose(const char *file, int line, const char *func, int level, const char *fmt, ...)
{
- struct ast_callid *callid;
+ ast_callid callid;
va_list ap;
callid = ast_read_threadstorage_callid();
@@ -1853,13 +1806,9 @@ void __ast_verbose(const char *file, int line, const char *func, int level, cons
va_start(ap, fmt);
__ast_verbose_ap(file, line, func, level, callid, fmt, ap);
va_end(ap);
-
- if (callid) {
- ast_callid_unref(callid);
- }
}
-void __ast_verbose_callid(const char *file, int line, const char *func, int level, struct ast_callid *callid, const char *fmt, ...)
+void __ast_verbose_callid(const char *file, int line, const char *func, int level, ast_callid callid, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
@@ -1872,7 +1821,7 @@ void __ast_verbose_callid(const char *file, int line, const char *func, int leve
void __attribute__((format(printf, 1,2))) ast_verbose(const char *fmt, ...);
void ast_verbose(const char *fmt, ...)
{
- struct ast_callid *callid;
+ ast_callid callid;
va_list ap;
callid = ast_read_threadstorage_callid();
@@ -1880,10 +1829,6 @@ void ast_verbose(const char *fmt, ...)
va_start(ap, fmt);
__ast_verbose_ap("", 0, "", 0, callid, fmt, ap);
va_end(ap);
-
- if (callid) {
- ast_callid_unref(callid);
- }
}
/*! Console verbosity level node. */
diff --git a/main/pbx.c b/main/pbx.c
index 08a1e5fa1..498acf79b 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -6318,7 +6318,7 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
int autoloopflag;
int error = 0; /* set an error conditions */
struct ast_pbx *pbx;
- struct ast_callid *callid;
+ ast_callid callid;
/* A little initial setup here */
if (ast_channel_pbx(c)) {
@@ -6346,10 +6346,7 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
}
}
ast_callid_threadassoc_add(callid);
- callid = ast_callid_unref(callid);
- } else {
- /* Nothing to do here, The thread is already bound to a callid. Let's just get rid of the reference. */
- ast_callid_unref(callid);
+ callid = 0;
}
ast_channel_pbx_set(c, pbx);
diff --git a/res/ari/resource_bridges.c b/res/ari/resource_bridges.c
index 9ae0e9386..bcd27af14 100644
--- a/res/ari/resource_bridges.c
+++ b/res/ari/resource_bridges.c
@@ -284,8 +284,7 @@ static void *bridge_channel_control_thread(void *data)
struct ast_channel *bridge_channel = thread_data->bridge_channel;
struct stasis_app_control *control = thread_data->control;
struct stasis_forward *forward = thread_data->forward;
-
- RAII_VAR(struct ast_callid *, callid, ast_channel_callid(bridge_channel), ast_callid_cleanup);
+ ast_callid callid = ast_channel_callid(bridge_channel);
if (callid) {
ast_callid_threadassoc_add(callid);