diff --git a/UPGRADE.txt b/UPGRADE.txt index af77d85f2568b390a67137043bb9805abb73d588..3514f5fae9acf12e0ef75360ff80506c0f8685c0 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 e6f4053c0fc6ce6a54e24ee547aba7974ca01024..35df01433b9bc54fd985f79357ff7356192385ff 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 6596a853777773bdb56d46c9f15c13fd2f3db87d..b850e27f79584774a154bd0a62be95c2099224af 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 d7eeebf261c01bb9c4fdbbfdc6ee1a27f01cf8f5..529fa2652649eb57a23f0a4e0b53a116c3c1e035 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 53899d8699b3acb65a351c06895f95a0cb66ed53..e3f5c81ff1f9dcae1a4538c9631d1ead6da3f55c 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 dbc1bb05cc211624b07e3d3be6c79534866af050..93c56e676cda911ce0d70dee919a700ea82ceff8 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 48f1b1fc716808973a24b3e5c07b4db8edf4797f..13baa70eb96ddb1bd3d7b6159cb6244ea1cf60c1 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 13c55462c6ef30ea08f4eccbd3e7d1f2063e7844..4ace511973025301bbdb0b1effd477d124f592e8 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 1d44a29b9b99cae4457619b78364e8823ea0ac0f..0608c3429fb4fc4bf639edac3e7168424482412c 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 37d3e49c77ffd9f855f37ffa849664a520bdf9dd..a7cc3d7a74295c543dba4356ac2e91471ee4678a 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 a7df9e9e08b59a14495eb9c714d09266853385ac..98530da6b06d4ece8093935ae65989faf37f7cf8 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 c3e113a8325914b1508c8e82042b4db39e43c93c..03441aa72eb7ae276c16ef1d6d1074f88f30f640 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 ea2fb457cc35784ef9c8151e27259339086a8cbf..6b08109a19cc9ff5770061da96f4bfc3cf239a32 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 68c2ee860587d814f6f1360009dd5082032c2b76..ab682ebfa46b89be011b8337f7e5bf0ce3ea9e58 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 8fa0f36ede92ce4fd586915a014983883eb03423..8243a1ddb6b6829c634963a348f89548c3632a40 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 1d071a014f45458e4958f49a2e7bad16abed46cf..c53848511d982286926b1df212461ea54da377ae 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 b6755e256fb40ab0fa2c88186de3ae708926a287..6dd3ac49c974d6dc2eb125d54042783376834c2e 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 e118c74bdbe55b0ec2ae9f6dc09d2dbc16f57f0d..45045e0a9563b5eb9e1930818ce83d485977293f 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 84e6991f0708cab00d3dd57aec1bde7b149537b2..feb9c7eda31cea5ebc75121dafbfc108e029b053 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 371464398c04941803d7271bec197988801566ca..9630990d1b250b371aedb95f5455b0e19add7305 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 6737fa62f53a0e1aa5d19def4e4c0db996a38cbf..4bfd58377496fe275fd0ee5184265fde908f355d 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 e3318b9f2b46c8a185faf3d2f2a086af5c7eb652..522a7d40cb323df94dadb8d022094263f0435aac 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 ac72c8bc2822d7622f233d9862eb4300297e3a49..e9f1ca0bdab120a7918f868efa997d2138cb71ca 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 76b6d524ac790ab6b2b6e6c37345deffb239af8d..58daf5732d9fd8872dec79790fe6b2c6971fc754 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 624bdd1cb167bc26dc2424e555ca0724ea6f32e7..0ff8444405a9550d80fc52209949cc3e85f56ae2 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 f0eb30e33a70c466637bbcc650a38121824aa32c..c30ad5ed62a3f3bab03fd81d8df95b77e7cd14e8 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 54915ecfe2fecd0437bb1a2c7e1db5d6382633a3..934cf86bf163bf5e92d5a09cd78aaa60a79ffe62 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 23d80328c06b5feb5cf4b96e0037c1c0be56c6d9..f26642429b1f98259648a710fd66df6d669b8713 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 827b5ef2348f9d75d64452f8859488c57a28f89f..210715556bfd87026667644ebbe0ccb6bcf5d226 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 870c57f1a89c920bbc1a8f4b01d4cae4b15428af..f5993d3f762e02400e097b670fd9cc9a7f3f23f5 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 c59c7ce6d33ee059085f4daf0f78d2571f5a690d..ad489f492fa73d970c172e6c2c5798cabd83af91 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 08a1e5fa12cbb224e92da3d77c7b88a8b639e3b8..498acf79b60ccb79de422cc7d8aefea6be8604dd 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 9ae0e938609bc8eb3f2af413c9c2a3c911c3784c..bcd27af146d2ad4a4d1ea9f8e4ed507b5abcbc3e 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);