aboutsummaryrefslogtreecommitdiffstats
path: root/funcs
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-11-29 00:20:34 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-11-29 00:20:34 +0000
commite6b05a47d78d8e21498ea0e1955561a6da6036ff (patch)
tree91e05719d450db0b2d67928e8a4efe6d10070e4a /funcs
parent31f04e79318a9865796c88a8957d996e9d6fbf45 (diff)
This set of changes is to make some callerID handling thread-safe.
The ast_set_callerid() function needed to lock the channel. Also, the handlers for the CALLERID() dialplan function needed to lock the channel when reading or writing callerid values directly on the channel structure. git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@90145 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'funcs')
-rw-r--r--funcs/func_callerid.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/funcs/func_callerid.c b/funcs/func_callerid.c
index be3026325..9809f4d08 100644
--- a/funcs/func_callerid.c
+++ b/funcs/func_callerid.c
@@ -64,6 +64,8 @@ static int callerid_read(struct ast_channel *chan, char *cmd, char *data,
ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
}
} else {
+ ast_channel_lock(chan);
+
if (!strncasecmp("all", data, 3)) {
snprintf(buf, len, "\"%s\" <%s>",
S_OR(chan->cid.cid_name, ""),
@@ -92,6 +94,8 @@ static int callerid_read(struct ast_channel *chan, char *cmd, char *data,
} else {
ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
}
+
+ ast_channel_unlock(chan);
}
return 0;
@@ -107,8 +111,8 @@ static int callerid_write(struct ast_channel *chan, char *cmd, char *data,
char name[256];
char num[256];
- if (!ast_callerid_split(value, name, sizeof(name), num, sizeof(num)))
- ast_set_callerid(chan, num, name, num);
+ if (!ast_callerid_split(value, name, sizeof(name), num, sizeof(num)))
+ ast_set_callerid(chan, num, name, num);
} else if (!strncasecmp("name", data, 4)) {
ast_set_callerid(chan, NULL, value, NULL);
} else if (!strncasecmp("num", data, 3) ||
@@ -117,15 +121,17 @@ static int callerid_write(struct ast_channel *chan, char *cmd, char *data,
} else if (!strncasecmp("ani", data, 3)) {
ast_set_callerid(chan, NULL, NULL, value);
} else if (!strncasecmp("dnid", data, 4)) {
- /* do we need to lock chan here? */
+ ast_channel_lock(chan);
if (chan->cid.cid_dnid)
free(chan->cid.cid_dnid);
chan->cid.cid_dnid = ast_strdup(value);
+ ast_channel_unlock(chan);
} else if (!strncasecmp("rdnis", data, 5)) {
- /* do we need to lock chan here? */
+ ast_channel_lock(chan);
if (chan->cid.cid_rdnis)
free(chan->cid.cid_rdnis);
chan->cid.cid_rdnis = ast_strdup(value);
+ ast_channel_unlock(chan);
} else {
ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
}