aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-10-31 15:34:11 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-10-31 15:34:11 +0000
commit3b5ed22f129ad87a256092965b6537c8bb86cede (patch)
treee17cabde9991f5c9bc212138afd5b7b1206e8c03
parent8615ded129565bd250218b36451f154e0c14ecec (diff)
fix various bugs related to list handling of channel variables (issue #5548)
use nolock lists for channel variables, since no locks are needed (these lists are either temporary or protected by the channel's own lock) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6900 f38db490-d61c-443f-a65b-d21fe96a405b
-rwxr-xr-xchannel.c4
-rwxr-xr-xinclude/asterisk/cdr.h1
-rwxr-xr-xinclude/asterisk/chanvars.h2
-rwxr-xr-xinclude/asterisk/linkedlists.h2
-rwxr-xr-xpbx.c2
-rwxr-xr-xpbx/pbx_dundi.c2
-rwxr-xr-xpbx/pbx_loopback.c2
7 files changed, 9 insertions, 6 deletions
diff --git a/channel.c b/channel.c
index c3f3d0384..6aa64e495 100755
--- a/channel.c
+++ b/channel.c
@@ -585,7 +585,7 @@ struct ast_channel *ast_channel_alloc(int needqueue)
snprintf(tmp->uniqueid, sizeof(tmp->uniqueid), "%li.%d", (long) time(NULL), uniqueint++);
headp = &tmp->varshead;
ast_mutex_init(&tmp->lock);
- AST_LIST_HEAD_INIT(headp);
+ AST_LIST_HEAD_INIT_NOLOCK(headp);
strcpy(tmp->context, "default");
ast_copy_string(tmp->language, defaultlanguage, sizeof(tmp->language));
strcpy(tmp->exten, "s");
@@ -2976,7 +2976,7 @@ int ast_do_masquerade(struct ast_channel *original)
original->fds[x] = clone->fds[x];
}
clone_variables(original, clone);
- clone->varshead.first = NULL;
+ AST_LIST_HEAD_INIT_NOLOCK(&clone->varshead);
/* Presense of ADSI capable CPE follows clone */
original->adsicpe = clone->adsicpe;
/* Bridge remains the same */
diff --git a/include/asterisk/cdr.h b/include/asterisk/cdr.h
index e14b7c653..2ca567134 100755
--- a/include/asterisk/cdr.h
+++ b/include/asterisk/cdr.h
@@ -47,7 +47,6 @@
#include "asterisk/channel.h"
struct ast_channel;
-AST_LIST_HEAD(varshead,ast_var_t);
/*! Responsible for call detail data */
struct ast_cdr {
diff --git a/include/asterisk/chanvars.h b/include/asterisk/chanvars.h
index 32cccf334..d31c05e86 100755
--- a/include/asterisk/chanvars.h
+++ b/include/asterisk/chanvars.h
@@ -31,6 +31,8 @@ struct ast_var_t {
char name[0];
};
+AST_LIST_HEAD_NOLOCK(varshead, ast_var_t);
+
struct ast_var_t *ast_var_assign(const char *name, const char *value);
void ast_var_delete(struct ast_var_t *var);
char *ast_var_name(struct ast_var_t *var);
diff --git a/include/asterisk/linkedlists.h b/include/asterisk/linkedlists.h
index 3dcd9a563..fd2203cd7 100755
--- a/include/asterisk/linkedlists.h
+++ b/include/asterisk/linkedlists.h
@@ -369,6 +369,8 @@ struct { \
#define AST_LIST_INSERT_HEAD(head, elm, field) do { \
(elm)->field.next = (head)->first; \
(head)->first = (elm); \
+ if (!(head)->last) \
+ (head)->last = (elm); \
} while (0)
/*!
diff --git a/pbx.c b/pbx.c
index 98250d1ce..c5459886f 100755
--- a/pbx.c
+++ b/pbx.c
@@ -6150,7 +6150,7 @@ int load_pbx(void)
ast_verbose( "Asterisk PBX Core Initializing\n");
ast_verbose( "Registering builtin applications:\n");
}
- AST_LIST_HEAD_INIT(&globals);
+ AST_LIST_HEAD_INIT_NOLOCK(&globals);
ast_cli_register_multiple(pbx_cli, sizeof(pbx_cli) / sizeof(pbx_cli[0]));
/* Register builtin applications */
diff --git a/pbx/pbx_dundi.c b/pbx/pbx_dundi.c
index 0dce9670f..c0165d962 100755
--- a/pbx/pbx_dundi.c
+++ b/pbx/pbx_dundi.c
@@ -559,7 +559,7 @@ static int dundi_lookup_local(struct dundi_result *dr, struct dundi_mapping *map
dr[anscnt].eid = *us_eid;
dundi_eid_to_str(dr[anscnt].eid_str, sizeof(dr[anscnt].eid_str), &dr[anscnt].eid);
if (ast_test_flag(&flags, DUNDI_FLAG_EXISTS)) {
- AST_LIST_HEAD_INIT(&headp);
+ AST_LIST_HEAD_INIT_NOLOCK(&headp);
newvariable = ast_var_assign("NUMBER", called_number);
AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
newvariable = ast_var_assign("EID", dr[anscnt].eid_str);
diff --git a/pbx/pbx_loopback.c b/pbx/pbx_loopback.c
index aeba07dcb..6fa35f2db 100755
--- a/pbx/pbx_loopback.c
+++ b/pbx/pbx_loopback.c
@@ -88,7 +88,7 @@ static char *loopback_helper(char *buf, int buflen, const char *exten, const cha
snprintf(tmp, sizeof(tmp), "%d", priority);
memset(buf, 0, buflen);
- AST_LIST_HEAD_INIT(&headp);
+ AST_LIST_HEAD_INIT_NOLOCK(&headp);
newvariable = ast_var_assign("EXTEN", exten);
AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
newvariable = ast_var_assign("CONTEXT", context);