........
r368721 | kmoore | 2012-06-11 09:11:14 -0500 (Mon, 11 Jun 2012) | 8 lines
Fix compilation in dev-mode
Backport a compilation fix in md5.c from trunk that only showed up in
dev-mode under certain compiler versions.
........
Merged revisions 368719 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
r368739 | kmoore | 2012-06-11 10:15:07 -0500 (Mon, 11 Jun 2012) | 10 lines
Fix coverity UNUSED_VALUE findings in core support level files
Most of these were just saving returned values without using them and
in some cases the variable being saved to could be removed as well.
(issue ASTERISK-19672)
........
Merged revisions 368738 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
r368760 | rmudgett | 2012-06-11 12:08:50 -0500 (Mon, 11 Jun 2012) | 17 lines
Fix deadlock potential with ast_set_hangupsource() calls.
Calling ast_set_hangupsource() with the channel lock held can result in a
deadlock because the function also locks the bridged channel.
(issue ASTERISK-19537)
(closes issue AST-891)
Reported by: Guenther Kelleter
Tested by: Guenther Kelleter
(closes issue ASTERISK-19801)
Reported by: Alec Davis
........
Merged revisions 368759 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
r368808 | mmichelson | 2012-06-12 10:37:38 -0500 (Tue, 12 Jun 2012) | 15 lines
Set the Caller ID "tag" on peers even if remote party information is present.
On incoming calls, we were setting the cid_tag on the dialog only if there was
no remote party information (Remote-Party-ID or P-Asserted-Identity) present.
The Caller ID tag is an invented parameter, though, and should be set no matter
the circumstance.
(closes issue ASTERISK-19859)
Reported by Thomas Arimont
(closes issue AST-884)
Reported by Trey Blancher
........
Merged revisions 368807 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
Merged revisions 368721,368739,368760,368808 from http://svn.asterisk.org/svn/asterisk/branches/10
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/10-digiumphones@368823
65c4cc65-6c06-0410-ace0-
fbb531ad65f3
const char *context = ast_variable_retrieve(rtdata, mailbox, "context");
fullname = ast_variable_retrieve(rtdata, mailbox, "fullname");
- if (ast_true((hidefromdir = ast_variable_retrieve(rtdata, mailbox, "hidefromdir")))) {
+ hidefromdir = ast_variable_retrieve(rtdata, mailbox, "hidefromdir");
+ if (ast_true(hidefromdir)) {
/* Skip hidden */
continue;
}
memset(tmpbuf, 0, sizeof(tmpbuf));
for (v = queue_vars; v; v = v->next) {
/* Convert to dashes `-' from underscores `_' as the latter are more SQL friendly. */
- if ((tmp = strchr(v->name, '_'))) {
+ if (strchr(v->name, '_')) {
ast_copy_string(tmpbuf, v->name, sizeof(tmpbuf));
tmp_name = tmpbuf;
tmp = tmpbuf;
/* Begin Monitoring */
if (qe->parent->monfmt && *qe->parent->monfmt) {
if (!qe->parent->montype) {
- const char *monexec, *monargs;
+ const char *monexec;
ast_debug(1, "Starting Monitor as requested.\n");
ast_channel_lock(qe->chan);
- if ((monexec = pbx_builtin_getvar_helper(qe->chan, "MONITOR_EXEC")) || (monargs = pbx_builtin_getvar_helper(qe->chan, "MONITOR_EXEC_ARGS"))) {
+ if ((monexec = pbx_builtin_getvar_helper(qe->chan, "MONITOR_EXEC")) || pbx_builtin_getvar_helper(qe->chan, "MONITOR_EXEC_ARGS")) {
which = qe->chan;
monexec = monexec ? ast_strdupa(monexec) : NULL;
}
for (category = ast_category_browse(cfg, NULL); category; category = ast_category_browse(cfg, category)) {
ast_debug(4, "users.conf: %s\n", category);
if (!strcasecmp(category, vmu->mailbox)) {
- if (!(tmp = ast_variable_retrieve(cfg, category, "vmsecret"))) {
+ if (!ast_variable_retrieve(cfg, category, "vmsecret")) {
ast_debug(3, "looks like we need to make vmsecret!\n");
var = ast_variable_new("vmsecret", newpassword, "");
} else {
f = &p->subs[idx].f;
return f;
}
+
f = dahdi_handle_event(ast);
+ if (!f) {
+ const char *name = ast_strdupa(ast->name);
- /* tell the cdr this zap device hung up */
- if (f == NULL) {
- ast_set_hangupsource(ast, ast->name, 0);
+ /* Tell the CDR this DAHDI device hung up */
+ ast_mutex_unlock(&p->lock);
+ ast_channel_unlock(ast);
+ ast_set_hangupsource(ast, name, 0);
+ ast_channel_lock(ast);
+ ast_mutex_lock(&p->lock);
}
-
return f;
}
int trunkgroup;
int x, y, fd = a->fd;
int interfaceid = 0;
- char *c;
char db_chan_name[20], db_answer[5];
struct dahdi_pvt *tmp;
struct dahdi_pri *pri;
if (a->argc < 5 || a->argc > 6)
return CLI_SHOWUSAGE;
- if ((c = strchr(a->argv[4], ':'))) {
+ if (strchr(a->argv[4], ':')) {
if (sscanf(a->argv[4], "%30d:%30d", &trunkgroup, &channel) != 2)
return CLI_SHOWUSAGE;
if ((trunkgroup < 1) || (channel < 1))
{
iax2_lock_owner(callno);
if (iaxs[callno] && iaxs[callno]->owner) {
+ struct ast_channel *owner;
+ const char *name;
+
+ owner = iaxs[callno]->owner;
if (causecode) {
- iaxs[callno]->owner->hangupcause = causecode;
+ owner->hangupcause = causecode;
}
- ast_set_hangupsource(iaxs[callno]->owner, iaxs[callno]->owner->name, 0);
- ast_channel_unlock(iaxs[callno]->owner);
+ name = ast_strdupa(owner->name);
+ ast_channel_ref(owner);
+ ast_channel_unlock(owner);
+ ast_mutex_unlock(&iaxsl[callno]);
+ ast_set_hangupsource(owner, name, 0);
+ ast_channel_unref(owner);
+ ast_mutex_lock(&iaxsl[callno]);
}
}
ast_log(LOG_NOTICE, "From address missing 'sip(s):', assuming sip:\n");
}
/* Get just the username part */
- if ((c = strchr(dest, '@'))) {
+ if (strchr(dest, '@')) {
c = NULL;
} else if ((c = strchr(of, '@'))) {
*c++ = '\0';
}
if (!ast_strlen_zero(peer->cid_name))
ast_string_field_set(p, cid_name, peer->cid_name);
- if (!ast_strlen_zero(peer->cid_tag))
- ast_string_field_set(p, cid_tag, peer->cid_tag);
if (peer->callingpres)
p->callingpres = peer->callingpres;
}
+ if (!ast_strlen_zero(peer->cid_tag)) {
+ ast_string_field_set(p, cid_tag, peer->cid_tag);
+ }
ast_string_field_set(p, fullcontact, peer->fullcontact);
if (!ast_strlen_zero(peer->context)) {
ast_string_field_set(p, context, peer->context);
}
}
+/*!
+ * \internal
+ * \brief Set hangup source and cause.
+ *
+ * \param p SIP private.
+ * \param cause Hangup cause to queue. Zero if no cause.
+ *
+ * \pre p and p->owner are locked.
+ *
+ * \return Nothing
+ */
+static void sip_queue_hangup_cause(struct sip_pvt *p, int cause)
+{
+ struct ast_channel *owner = p->owner;
+ const char *name = ast_strdupa(owner->name);
+
+ /* Cannot hold any channel/private locks when calling. */
+ ast_channel_ref(owner);
+ ast_channel_unlock(owner);
+ sip_pvt_unlock(p);
+ ast_set_hangupsource(owner, name, 0);
+ if (cause) {
+ ast_queue_hangup_with_cause(owner, cause);
+ } else {
+ ast_queue_hangup(owner);
+ }
+ ast_channel_unref(owner);
+
+ /* Relock things. */
+ owner = sip_pvt_lock_full(p);
+ if (owner) {
+ ast_channel_unref(owner);
+ }
+}
+
/*! \brief Handle SIP response to INVITE dialogue */
static void handle_response_invite(struct sip_pvt *p, int resp, const char *rest, struct sip_request *req, uint32_t seqno)
{
xmitres = transmit_request(p, SIP_ACK, seqno, XMIT_UNRELIABLE, FALSE);
ast_log(LOG_WARNING, "Received response: \"Forbidden\" from '%s'\n", sip_get_header(&p->initreq, "From"));
if (!req->ignore && p->owner) {
- ast_set_hangupsource(p->owner, p->owner->name, 0);
- ast_queue_hangup_with_cause(p->owner, hangup_sip2cause(resp));
+ sip_queue_hangup_cause(p, hangup_sip2cause(resp));
}
break;
case 404: /* Not found */
xmitres = transmit_request(p, SIP_ACK, seqno, XMIT_UNRELIABLE, FALSE);
if (p->owner && !req->ignore) {
- ast_set_hangupsource(p->owner, p->owner->name, 0);
- ast_queue_hangup_with_cause(p->owner, hangup_sip2cause(resp));
+ sip_queue_hangup_cause(p, hangup_sip2cause(resp));
}
break;
stop_media_flows(p); /* Immediately stop RTP, VRTP and UDPTL as applicable */
if (p->owner) {
- ast_set_hangupsource(p->owner, p->owner->name, 0);
- ast_queue_hangup(p->owner);
- }
- else
+ sip_queue_hangup_cause(p, 0);
+ } else {
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
+ }
if (ast_str_strlen(p->initreq.data) > 0) {
struct sip_pkt *pkt, *prev_pkt;
/* If the CANCEL we are receiving is a retransmission, and we already have scheduled
ast_queue_hangup_with_cause(p->owner, AST_CAUSE_PROTOCOL_ERROR);
}
} else if (p->owner) {
- ast_set_hangupsource(p->owner, p->owner->name, 0);
- ast_queue_hangup(p->owner);
+ sip_queue_hangup_cause(p, 0);
sip_scheddestroy_final(p, DEFAULT_TRANS_TIMEOUT);
ast_debug(3, "Received bye, issuing owner hangup\n");
} else {
f = &p->subs[idx].f;
return f;
}
+
f = __analog_handle_event(p, ast);
+ if (!f) {
+ const char *name = ast_strdupa(ast->name);
+
+ /* Tell the CDR this DAHDI device hung up */
+ analog_unlock_private(p);
+ ast_channel_unlock(ast);
+ ast_set_hangupsource(ast, name, 0);
+ ast_channel_lock(ast);
+ analog_lock_private(p);
+ }
return f;
}
}
if (ast_strlen_zero(args.field) || !strcasecmp(args.field, "all")) {
- char quality_buf[AST_MAX_USER_FIELD], *quality;
+ char quality_buf[AST_MAX_USER_FIELD];
- if (!(quality = ast_rtp_instance_get_quality(rtp, AST_RTP_INSTANCE_STAT_FIELD_QUALITY, quality_buf, sizeof(quality_buf)))) {
+ if (!ast_rtp_instance_get_quality(rtp, AST_RTP_INSTANCE_STAT_FIELD_QUALITY, quality_buf, sizeof(quality_buf))) {
return -1;
}
}
/* Test 6, NULL input */
- if ((uri = get_in_brackets(NULL))) {
+ if (get_in_brackets(NULL)) {
ast_test_status_update(test, "Test 6, NULL input failed.\n");
res = AST_TEST_FAIL;
}
static struct sdp_crypto *sdp_crypto_alloc(void)
{
- struct sdp_crypto *crypto;
-
- return crypto = ast_calloc(1, sizeof(*crypto));
+ return ast_calloc(1, sizeof(struct sdp_crypto));
}
void sdp_crypto_destroy(struct sdp_crypto *crypto)
AST_APP_ARG(delimiter);
AST_APP_ARG(fieldvalue);
);
- const char *ptr;
struct ast_str *orig_list = ast_str_thread_get(&tmp_buf, 16);
const char *begin, *cur, *next;
int dlen, flen, first = 1;
}
/* If the string isn't there, just copy out the string and be done with it. */
- if (!(ptr = strstr(ast_str_buffer(orig_list), args.fieldvalue))) {
+ if (!strstr(ast_str_buffer(orig_list), args.fieldvalue)) {
if (buf) {
ast_copy_string(buf, ast_str_buffer(orig_list), len);
} else {
* \param source a string describing the source of the hangup for this channel
* \param force
*
+ * \note Absolutely _NO_ channel locks should be held before calling this function.
+ *
* \since 1.8
*
* Hangupsource is generally the channel name that caused the bridge to be
ast_string_field_set(chan, hangupsource, source);
}
bridge = ast_bridged_channel(chan);
+ if (bridge) {
+ ast_channel_ref(bridge);
+ }
ast_channel_unlock(chan);
- if (bridge && (force || ast_strlen_zero(bridge->hangupsource))) {
+ if (bridge) {
ast_channel_lock(bridge);
- ast_string_field_set(chan, hangupsource, source);
+ if (force || ast_strlen_zero(bridge->hangupsource)) {
+ ast_string_field_set(bridge, hangupsource, source);
+ }
ast_channel_unlock(bridge);
+ ast_channel_unref(bridge);
}
}
if (mod->flags.running)
continue;
- order = add_to_load_order(mod->resource, &load_order, 0);
+ add_to_load_order(mod->resource, &load_order, 0);
}
#ifdef LOADABLE_MODULES
/* if we are allowed to load dynamic modules, scan the directory for
for all available modules and add them as well */
- if ((dir = opendir(ast_config_AST_MODULE_DIR))) {
+ if ((dir = opendir(ast_config_AST_MODULE_DIR))) {
while ((dirent = readdir(dir))) {
int ld = strlen(dirent->d_name);
{
unsigned count;
unsigned char *p;
+ uint32_t *in_buf;
/* Compute number of bytes mod 64 */
count = (ctx->bits[0] >> 3) & 0x3F;
byteReverse(ctx->in, 14);
/* Append length in bits and transform */
- ((uint32_t *) ctx->in)[14] = ctx->bits[0];
- ((uint32_t *) ctx->in)[15] = ctx->bits[1];
+ in_buf = (uint32_t *) ctx->in;
+ in_buf[14] = ctx->bits[0];
+ in_buf[15] = ctx->bits[1];
MD5Transform(ctx->buf, (uint32_t *) ctx->in);
byteReverse((unsigned char *) ctx->buf, 4);
char *b = buf;
b = pl_append(b, odm->dziesiatki[m100 / 10]);
b = pl_append(b, odm->separator_dziesiatek);
- b = pl_append(b, odm->cyfry2[m100 % 10]);
+ pl_append(b, odm->cyfry2[m100 % 10]);
pl_odtworz_plik(chan, language, audiofd, ctrlfd, ints, buf);
}
}
ast_log(LOG_WARNING, "Disabling UDPTL checksums is not supported on this operating system!\n");
#endif
}
- if ((s = ast_variable_retrieve(cfg, "general", "T38FaxUdpEC"))) {
+ if (ast_variable_retrieve(cfg, "general", "T38FaxUdpEC")) {
ast_log(LOG_WARNING, "T38FaxUdpEC in udptl.conf is no longer supported; use the t38pt_udptl configuration option in sip.conf instead.\n");
}
- if ((s = ast_variable_retrieve(cfg, "general", "T38FaxMaxDatagram"))) {
+ if (ast_variable_retrieve(cfg, "general", "T38FaxMaxDatagram")) {
ast_log(LOG_WARNING, "T38FaxMaxDatagram in udptl.conf is no longer supported; value is now supplied by T.38 applications.\n");
}
if ((s = ast_variable_retrieve(cfg, "general", "UDPTLFECEntries"))) {
}
} else if (!strcasecmp(v->name, "exten")) {
int ipri;
- char *plus, *firstp;
+ char *plus;
char *pri, *appl, *data, *cidmatch;
if (!(stringp = tc = ast_strdup(v->value))) {
}
appl = S_OR(stringp, "");
/* Find the first occurrence of '(' */
- if (!(firstp = strchr(appl, '('))) {
+ if (!strchr(appl, '(')) {
/* No arguments */
data = "";
} else {
}
va_arg(aq, const char *);
- if (tableptr && !(column = ast_odbc_find_column(tableptr, newparam))) {
+ if (tableptr && !ast_odbc_find_column(tableptr, newparam)) {
ast_log(LOG_WARNING, "Key field '%s' does not exist in table '%s@%s'. Update will fail\n", newparam, table, database);
}
SQLHSTMT stmt;
va_list ap;
struct odbc_cache_tables *tableptr = ast_odbc_find_table(ups->database, ups->table);
- struct odbc_cache_columns *column;
if (!sql) {
if (tableptr) {
while ((newparam = va_arg(ap, const char *))) {
newval = va_arg(ap, const char *);
- if ((column = ast_odbc_find_column(tableptr, newparam))) {
+ if (ast_odbc_find_column(tableptr, newparam)) {
ast_str_append(&sql, 0, "%s%s=? ", first ? "" : ", ", newparam);
SQLBindParameter(stmt, x++, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(newval), 0, (void *)newval, 0, NULL);
first = 0;
while ((newparam = va_arg(ap, const char *))) {
newval = va_arg(ap, const char *);
- if (!(column = ast_odbc_find_column(tableptr, newparam))) {
+ if (!ast_odbc_find_column(tableptr, newparam)) {
va_end(ap);
ast_log(LOG_ERROR, "One or more of the criteria columns '%s' on '%s@%s' for this update does not exist!\n", newparam, ups->table, ups->database);
ast_odbc_release_table(tableptr);
char *m[5], *tok, *v = (char *)value;
int i = 0, j;
- if (!(tok = strchr(v, ','))) {
+ if (!strchr(v, ',')) {
m[i++] = v;
m[i] = NULL;
} else {
pbx_builtin_setvar_helper(chan, "ODBC_RESULT", "INVALID_DB");
return -1;
}
- if (!(tx = find_transaction(chan, obj, value, 0))) {
+ if (!find_transaction(chan, obj, value, 0)) {
pbx_builtin_setvar_helper(chan, "ODBC_RESULT", "FAILED_TO_CREATE");
return -1;
}
/*! \brief Register a speech recognition engine */
int ast_speech_register(struct ast_speech_engine *engine)
{
- struct ast_speech_engine *existing_engine = NULL;
int res = 0;
/* Confirm the engine meets the minimum API requirements */
}
/* If an engine is already loaded with this name, error out */
- if ((existing_engine = find_engine(engine->name))) {
+ if (find_engine(engine->name)) {
ast_log(LOG_WARNING, "Speech recognition engine '%s' already exists.\n", engine->name);
return -1;
}