[asterisk-commits] branch oej/managerstuff r16827 - in
/team/oej/managerstuff: ./ channels/
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Fri Mar 31 17:36:01 MST 2006
Author: oej
Date: Fri Mar 31 18:35:59 2006
New Revision: 16827
URL: http://svn.digium.com/view/asterisk?rev=16827&view=rev
Log:
Reset automerge
Modified:
team/oej/managerstuff/ (props changed)
team/oej/managerstuff/channels/chan_iax2.c
team/oej/managerstuff/pbx.c
Propchange: team/oej/managerstuff/
------------------------------------------------------------------------------
automerge = http://edvina.net/training/
Propchange: team/oej/managerstuff/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Mar 31 18:35:59 2006
@@ -1,1 +1,1 @@
-/branches/1.2:1-7496,7498-16591
+/branches/1.2:1-7496,7498-16826
Modified: team/oej/managerstuff/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/oej/managerstuff/channels/chan_iax2.c?rev=16827&r1=16826&r2=16827&view=diff
==============================================================================
--- team/oej/managerstuff/channels/chan_iax2.c (original)
+++ team/oej/managerstuff/channels/chan_iax2.c Fri Mar 31 18:35:59 2006
@@ -1488,6 +1488,8 @@
int res;
char iabuf[INET_ADDRSTRLEN];
/* Called with iaxsl held */
+ if (!iaxs[f->callno])
+ return -1;
if (option_debug > 2 && iaxdebug)
ast_log(LOG_DEBUG, "Sending %d on %d/%d to %s:%d\n", f->ts, f->callno, iaxs[f->callno]->peercallno, ast_inet_ntoa(iabuf, sizeof(iabuf), iaxs[f->callno]->addr.sin_addr), ntohs(iaxs[f->callno]->addr.sin_port));
/* Don't send if there was an error, but return error instead */
@@ -1495,8 +1497,6 @@
ast_log(LOG_WARNING, "Call number = %d\n", f->callno);
return -1;
}
- if (!iaxs[f->callno])
- return -1;
if (iaxs[f->callno]->error)
return -1;
if (f->transfer) {
@@ -8784,6 +8784,18 @@
/* ast_log(LOG_WARNING, "Ignoring %s\n", v->name); */
v = v->next;
}
+
+ if (defaultsockfd < 0) {
+ if (!(ns = ast_netsock_bind(netsock, io, "0.0.0.0", portno, tos, socket_read, NULL))) {
+ ast_log(LOG_ERROR, "Unable to create network socket: %s\n", strerror(errno));
+ } else {
+ if (option_verbose > 1)
+ ast_verbose(VERBOSE_PREFIX_2 "Binding IAX2 to default address 0.0.0.0:%d\n", portno);
+ defaultsockfd = ast_netsock_sockfd(ns);
+ ast_netsock_unref(ns);
+ }
+ }
+
if (min_reg_expire > max_reg_expire) {
ast_log(LOG_WARNING, "Minimum registration interval of %d is more than maximum of %d, resetting minimum to %d\n",
min_reg_expire, max_reg_expire, max_reg_expire);
@@ -9544,9 +9556,6 @@
struct iax2_registry *reg;
struct iax2_peer *peer;
- struct ast_netsock *ns;
- struct sockaddr_in sin;
-
ast_custom_function_register(&iaxpeer_function);
iax_set_output(iax_debug_output);
@@ -9555,10 +9564,6 @@
jb_setoutput(jb_error_output, jb_warning_output, NULL);
#endif
- sin.sin_family = AF_INET;
- sin.sin_port = htons(IAX_DEFAULT_PORTNO);
- sin.sin_addr.s_addr = INADDR_ANY;
-
#ifdef IAX_TRUNKING
#ifdef ZT_TIMERACK
timingfd = open("/dev/zap/timer", O_RDWR);
@@ -9611,19 +9616,7 @@
if (ast_register_switch(&iax2_switch))
ast_log(LOG_ERROR, "Unable to register IAX switch\n");
-
- if (defaultsockfd < 0) {
- if (!(ns = ast_netsock_bindaddr(netsock, io, &sin, tos, socket_read, NULL))) {
- ast_log(LOG_ERROR, "Unable to create network socket: %s\n", strerror(errno));
- return -1;
- } else {
- if (option_verbose > 1)
- ast_verbose(VERBOSE_PREFIX_2 "Binding IAX2 to default address 0.0.0.0:%d\n", IAX_DEFAULT_PORTNO);
- defaultsockfd = ast_netsock_sockfd(ns);
- ast_netsock_unref(ns);
- }
- }
-
+
res = start_network_thread();
if (!res) {
if (option_verbose > 1)
Modified: team/oej/managerstuff/pbx.c
URL: http://svn.digium.com/view/asterisk/team/oej/managerstuff/pbx.c?rev=16827&r1=16826&r2=16827&view=diff
==============================================================================
--- team/oej/managerstuff/pbx.c (original)
+++ team/oej/managerstuff/pbx.c Fri Mar 31 18:35:59 2006
@@ -455,6 +455,12 @@
struct ast_switch *switches = NULL;
AST_MUTEX_DEFINE_STATIC(switchlock); /*!< Lock for switches */
+/* WARNING:
+ When holding this lock, do _not_ do anything that will cause conlock
+ to be taken, unless you _already_ hold it. The ast_merge_contexts_and_delete
+ function will take the locks in conlock/hintlock order, so any other
+ paths that require both locks must also take them in that order.
+*/
AST_MUTEX_DEFINE_STATIC(hintlock); /*!< Lock for extension state notifys */
static int stateid = 1;
struct ast_hint *hints = NULL;
@@ -3629,9 +3635,20 @@
int length;
struct ast_state_cb *thiscb, *prevcb;
+ AST_LIST_HEAD_INIT(&store);
+
+ /* it is very important that this function hold the hintlock _and_ the conlock
+ during its operation; not only do we need to ensure that the list of contexts
+ and extensions does not change, but also that no hint callbacks (watchers) are
+ added or removed during the merge/delete process
+
+ in addition, the locks _must_ be taken in this order, because there are already
+ other code paths that use this order
+ */
+ ast_mutex_lock(&conlock);
+ ast_mutex_lock(&hintlock);
+
/* preserve all watchers for hints associated with this registrar */
- AST_LIST_HEAD_INIT(&store);
- ast_mutex_lock(&hintlock);
for (hint = hints; hint; hint = hint->next) {
if (hint->callbacks && !strcmp(registrar, hint->exten->parent->registrar)) {
length = strlen(hint->exten->exten) + strlen(hint->exten->parent->name) + 2 + sizeof(*this);
@@ -3650,10 +3667,8 @@
AST_LIST_INSERT_HEAD(&store, this, list);
}
}
- ast_mutex_unlock(&hintlock);
tmp = *extcontexts;
- ast_mutex_lock(&conlock);
if (registrar) {
__ast_context_destroy(NULL,registrar);
while (tmp) {
@@ -3673,7 +3688,6 @@
*extcontexts = NULL;
} else
ast_log(LOG_WARNING, "Requested contexts didn't get merged\n");
- ast_mutex_unlock(&conlock);
/* restore the watchers for hints that can be found; notify those that
cannot be restored
@@ -3681,7 +3695,6 @@
while ((this = AST_LIST_REMOVE_HEAD(&store, list))) {
exten = ast_hint_extension(NULL, this->context, this->exten);
/* Find the hint in the list of hints */
- ast_mutex_lock(&hintlock);
for (hint = hints; hint; hint = hint->next) {
if (hint->exten == exten)
break;
@@ -3704,9 +3717,11 @@
hint->callbacks = this->callbacks;
hint->laststate = this->laststate;
}
- ast_mutex_unlock(&hintlock);
free(this);
}
+
+ ast_mutex_unlock(&hintlock);
+ ast_mutex_unlock(&conlock);
return;
}
More information about the asterisk-commits
mailing list