[asterisk-commits] mmichelson: branch mmichelson/forward-loop r87041 - in /team/mmichelson/forwa...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Oct 25 14:13:03 CDT 2007
Author: mmichelson
Date: Thu Oct 25 14:13:02 2007
New Revision: 87041
URL: http://svn.digium.com/view/asterisk?view=rev&rev=87041
Log:
Fixed some more not-so-thread-safe behavior.
Implemented some suggestions from Kevin to hide implementation of the datastore from others
and to more efficiently allocate space for the ast_dialed_interface struct
Modified:
team/mmichelson/forward-loop/apps/app_dial.c
team/mmichelson/forward-loop/apps/app_queue.c
team/mmichelson/forward-loop/include/asterisk/global_datastores.h
team/mmichelson/forward-loop/main/global_datastores.c
Modified: team/mmichelson/forward-loop/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/forward-loop/apps/app_dial.c?view=diff&rev=87041&r1=87040&r2=87041
==============================================================================
--- team/mmichelson/forward-loop/apps/app_dial.c (original)
+++ team/mmichelson/forward-loop/apps/app_dial.c Thu Oct 25 14:13:02 2007
@@ -1159,13 +1159,14 @@
if ((blah = strchr(tech, '/')))
*blah = '\0';
if (strcasecmp(tech, "Local")) {
- if(!(di = ast_calloc(1, sizeof(*di))))
+ if(!(di = ast_calloc(1, sizeof(*di) + strlen(interface))))
goto out;
- ast_copy_string(di->interface, interface, sizeof(di->interface));
+ strcpy(di->interface, interface);
ast_log(LOG_DEBUG, "Adding interface '%s' to the list of dialed interfaces\n", di->interface);
AST_LIST_INSERT_TAIL(dialed_interfaces, di, list);
}
} else {
+ AST_LIST_UNLOCK(dialed_interfaces);
ast_log(LOG_DEBUG, "Skipping dialing interface '%s' since it has already been dialed\n", di->interface);
ast_hangup(tmp->chan);
tmp->chan = NULL;
Modified: team/mmichelson/forward-loop/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/forward-loop/apps/app_queue.c?view=diff&rev=87041&r1=87040&r2=87041
==============================================================================
--- team/mmichelson/forward-loop/apps/app_queue.c (original)
+++ team/mmichelson/forward-loop/apps/app_queue.c Thu Oct 25 14:13:02 2007
@@ -2582,16 +2582,17 @@
break;
}
}
- AST_LIST_UNLOCK(dialed_interfaces);
if (!dialed) {
di = ast_calloc(1, sizeof(*di));
ast_copy_string(di->interface, cur->interface, sizeof(di->interface));
AST_LIST_INSERT_TAIL(dialed_interfaces, di, list);
} else {
+ AST_LIST_UNLOCK(dialed_interfaces);
ast_log(LOG_DEBUG, "Skipping dialing interface '%s' since it has already been dialed\n", di->interface);
free(tmp);
continue;
}
+ AST_LIST_UNLOCK(dialed_interfaces);
tmp->stillgoing = -1;
tmp->member = cur;
tmp->oldstatus = cur->status;
Modified: team/mmichelson/forward-loop/include/asterisk/global_datastores.h
URL: http://svn.digium.com/view/asterisk/team/mmichelson/forward-loop/include/asterisk/global_datastores.h?view=diff&rev=87041&r1=87040&r2=87041
==============================================================================
--- team/mmichelson/forward-loop/include/asterisk/global_datastores.h (original)
+++ team/mmichelson/forward-loop/include/asterisk/global_datastores.h Thu Oct 25 14:13:02 2007
@@ -7,15 +7,11 @@
void dialed_interface_destroy(void *data);
void *dialed_interface_duplicate(void *data);
-const struct ast_datastore_info dialed_interface_info = {
- .type ="dialed-interface",
- .destroy = dialed_interface_destroy,
- .duplicate = dialed_interface_duplicate,
-};
+extern const struct ast_datastore_info dialed_interface_info;
struct ast_dialed_interface {
- char interface[80];
AST_LIST_ENTRY(ast_dialed_interface) list;
+ char interface[1];
};
#endif
Modified: team/mmichelson/forward-loop/main/global_datastores.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/forward-loop/main/global_datastores.c?view=diff&rev=87041&r1=87040&r2=87041
==============================================================================
--- team/mmichelson/forward-loop/main/global_datastores.c (original)
+++ team/mmichelson/forward-loop/main/global_datastores.c Thu Oct 25 14:13:02 2007
@@ -15,7 +15,7 @@
AST_LIST_UNLOCK(dialed_interface_list);
AST_LIST_HEAD_DESTROY(dialed_interface_list);
- ast_free(dialed_interface_list);
+ free(dialed_interface_list);
}
void *dialed_interface_duplicate(void *data)
@@ -33,11 +33,17 @@
AST_LIST_HEAD_INIT(new_list);
AST_LIST_LOCK(old_list);
AST_LIST_TRAVERSE(old_list, di, list) {
- struct ast_dialed_interface *di2 = ast_calloc(1, sizeof(*di2));
- ast_copy_string(di2->interface, di->interface, sizeof(di2->interface));
+ struct ast_dialed_interface *di2 = ast_calloc(1, sizeof(*di2) + strlen(di->interface));
+ strcpy(di2->interface, di->interface);
AST_LIST_INSERT_TAIL(new_list, di2, list);
}
AST_LIST_UNLOCK(old_list);
return new_list;
}
+
+const struct ast_datastore_info dialed_interface_info = {
+ .type ="dialed-interface",
+ .destroy = dialed_interface_destroy,
+ .duplicate = dialed_interface_duplicate,
+};
More information about the asterisk-commits
mailing list