[asterisk-commits] qwell: branch qwell/fun_with_transports r385269 - in /team/qwell/fun_with_tra...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Apr 10 16:25:25 CDT 2013
Author: qwell
Date: Wed Apr 10 16:25:21 2013
New Revision: 385269
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=385269
Log:
Multiple revisions 385125,385144,385176,385216,385239
........
r385125 | root | 2013-04-09 14:17:40 -0500 (Tue, 09 Apr 2013) | 9 lines
Backported app_stasis fix from stasis-http branch.
The hash and compare functions for the control container was reusing
the wrong ones, causing some problems. I fixed it, but in the wrong
branch. Oh well, it happens.
........
Merged revisions 385116 from file:///srv/subversion/repos/asterisk/trunk
........
r385144 | root | 2013-04-09 15:17:38 -0500 (Tue, 09 Apr 2013) | 7 lines
Rename struct feature_ds to struct feature_datastore.
Because "struct feature_ds *feature_ds" is not a good thing.
........
Merged revisions 385142 from file:///srv/subversion/repos/asterisk/trunk
........
r385176 | root | 2013-04-10 09:18:23 -0500 (Wed, 10 Apr 2013) | 35 lines
Fix crash in chan_sip when a core initiated op occurs at the same time as a BYE
When a BYE request is processed in chan_sip, the current SIP dialog is detached
from its associated Asterisk channel structure. The tech_pvt pointer in the
channel object is set to NULL, and the dialog persists for an RFC mandated
period of time to handle re-transmits.
While this process occurs, the channel is locked (which is good).
Unfortunately, operations that are initiated externally have no way of knowing
that the channel they've just obtained (which is still valid) and that they are
attempting to lock is about to have its tech_pvt pointer removed. By the time
they obtain the channel lock and call the channel technology callback, the
tech_pvt is NULL.
This patch adds a few checks to some channel callbacks that make sure the
tech_pvt isn't NULL before using it. Prime offenders were the DTMF digit
callbacks, which would crash if AMI initiated a DTMF on the channel at the
same time as a BYE was received from the UA. This patch also adds checks on
sip_transfer (as AMI can also cause a callback into this function), as well
as sip_indicate (as lots of things can queue an indication onto a channel).
Review: https://reviewboard.asterisk.org/r/2434/
(closes issue ASTERISK-20225)
Reported by: Jeff Hoppe
........
Merged revisions 385170 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
Merged revisions 385173 from http://svn.asterisk.org/svn/asterisk/branches/11
........
Merged revisions 385174 from file:///srv/subversion/repos/asterisk/trunk
........
r385216 | root | 2013-04-10 10:17:36 -0500 (Wed, 10 Apr 2013) | 28 lines
Use LDAP memory management functions instead of Asterisk's
When MALLOC_DEBUG is enabled with res_config_ldap, issues (munmap_chunk:
invalid pointer errors) can occur as the memory is being allocated with
Asterisk's wrappers around malloc/calloc/free/strdup, as opposed to the
LDAP library's wrappers.
This patch uses the LDAP library's wrappers where appropriate, so that
compiling with MALLOC_DEBUG doesn't cause more problems than it solves.
Note that the patch listed below was modified slightly for this commit
to account for some additional memory allocation/deallocations.
(closes issue ASTERISK-17386)
Reported by: John Covert
Tested by: Andrew Latham
patches:
issue18789-1.8-r316873.patch uploaded by seanbright (License 5060)
........
Merged revisions 385190 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
Merged revisions 385199 from http://svn.asterisk.org/svn/asterisk/branches/11
........
Merged revisions 385202 from file:///srv/subversion/repos/asterisk/trunk
........
r385239 | root | 2013-04-10 11:17:38 -0500 (Wed, 10 Apr 2013) | 8 lines
Fixed manager channelvars support.
For the events that have been ported to Stasis, this was broken in
r384910, when a couple of lines of code was lost in a merge.
........
Merged revisions 385236 from file:///srv/subversion/repos/asterisk/trunk
........
Merged revisions 385125,385144,385176,385216,385239 from http://svn.asterisk.org/svn/asterisk/team/group/pimp_my_sip
Modified:
team/qwell/fun_with_transports/ (props changed)
team/qwell/fun_with_transports/apps/app_stasis.c
team/qwell/fun_with_transports/channels/chan_sip.c
team/qwell/fun_with_transports/main/features.c
team/qwell/fun_with_transports/main/stasis_channels.c
team/qwell/fun_with_transports/res/res_config_ldap.c
Propchange: team/qwell/fun_with_transports/
------------------------------------------------------------------------------
Binary property 'branch-11-merged' - no diff available.
Propchange: team/qwell/fun_with_transports/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Apr 10 16:25:21 2013
@@ -1,1 +1,1 @@
-/team/group/pimp_my_sip:1-385110 /trunk:1-383466
+/team/group/pimp_my_sip:1-385268 /trunk:1-383466
Modified: team/qwell/fun_with_transports/apps/app_stasis.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/apps/app_stasis.c?view=diff&rev=385269&r1=385268&r2=385269
==============================================================================
--- team/qwell/fun_with_transports/apps/app_stasis.c (original)
+++ team/qwell/fun_with_transports/apps/app_stasis.c Wed Apr 10 16:25:21 2013
@@ -35,6 +35,7 @@
#include "asterisk/app_stasis.h"
#include "asterisk/astobj2.h"
#include "asterisk/channel.h"
+#include "asterisk/lock.h"
#include "asterisk/module.h"
#include "asterisk/stasis.h"
#include "asterisk/strings.h"
@@ -48,7 +49,8 @@
<para>Name of the application to invoke.</para>
</parameter>
<parameter name="args">
- <para>Optional comma-delimited arguments for the application invocation.</para>
+ <para>Optional comma-delimited arguments for the
+ application invocation.</para>
</parameter>
</syntax>
<description>
@@ -178,7 +180,7 @@
*/
int continue_to_dialplan:1;
/*! Uniqueid of the associated channel */
- char channel_uniqueid[];
+ char channel_id[];
};
static struct stasis_app_control *control_create(const char *uniqueid)
@@ -192,9 +194,33 @@
return NULL;
}
- strncpy(control->channel_uniqueid, uniqueid, size - sizeof(*control));
+ strncpy(control->channel_id, uniqueid, size - sizeof(*control));
return control;
+}
+
+/*! AO2 hash function for \ref stasis_app_control */
+static int control_hash(const void *obj, const int flags)
+{
+ const struct stasis_app_control *control = obj;
+ const char *id = flags & OBJ_KEY ? obj : control->channel_id;
+
+ return ast_str_hash(id);
+}
+
+/*! AO2 comparison function for \ref stasis_app_control */
+static int control_compare(void *lhs, void *rhs, int flags)
+{
+ const struct stasis_app_control *lhs_control = lhs;
+ const struct stasis_app_control *rhs_control = rhs;
+ const char *rhs_name =
+ flags & OBJ_KEY ? rhs : rhs_control->channel_id;
+
+ if (strcmp(lhs_control->channel_id, rhs_name) == 0) {
+ return CMP_MATCH | CMP_STOP;
+ } else {
+ return 0;
+ }
}
struct stasis_app_control *stasis_app_control_find_by_channel(
@@ -366,7 +392,8 @@
}
controls = app_controls();
- ao2_unlink_flags(controls, control, OBJ_POINTER | OBJ_UNLINK | OBJ_NODATA);
+ ao2_unlink_flags(controls, control,
+ OBJ_POINTER | OBJ_UNLINK | OBJ_NODATA);
ao2_cleanup(control);
}
@@ -376,7 +403,8 @@
RAII_VAR(struct ao2_container *, apps, apps_registry(), ao2_cleanup);
RAII_VAR(struct app *, app, NULL, ao2_cleanup);
RAII_VAR(struct stasis_app_control *, control, NULL, control_unlink);
- RAII_VAR(struct stasis_subscription *, subscription, NULL, stasis_unsubscribe);
+ RAII_VAR(struct stasis_subscription *, subscription, NULL,
+ stasis_unsubscribe);
int res = 0;
char *parse = NULL;
int hungup = 0;
@@ -400,7 +428,8 @@
app = ao2_find(apps, args.app_name, OBJ_KEY);
if (!app) {
- ast_log(LOG_ERROR, "Stasis app '%s' not registered\n", args.app_name);
+ ast_log(LOG_ERROR,
+ "Stasis app '%s' not registered\n", args.app_name);
return -1;
}
@@ -416,30 +445,35 @@
ao2_link(controls, control);
}
- subscription = stasis_subscribe(ast_channel_topic(chan), sub_handler, app);
+ subscription =
+ stasis_subscribe(ast_channel_topic(chan), sub_handler, app);
if (subscription == NULL) {
- ast_log(LOG_ERROR, "Error subscribing app %s to channel %s\n", args.app_name, ast_channel_name(chan));
+ ast_log(LOG_ERROR, "Error subscribing app %s to channel %s\n",
+ args.app_name, ast_channel_name(chan));
return -1;
}
ao2_ref(app, +1); /* subscription now has a reference */
res = send_start_msg(app, chan, args.argc - 1, args.app_argv);
if (res != 0) {
- ast_log(LOG_ERROR, "Error sending start message to %s\n", args.app_name);
+ ast_log(LOG_ERROR,
+ "Error sending start message to %s\n", args.app_name);
return res;
}
while (!hungup && !control_continue_test_and_reset(control) && ast_waitfor(chan, -1) > -1) {
RAII_VAR(struct ast_frame *, f, ast_read(chan), ast_frame_dtor);
if (!f) {
- ast_debug(3, "%s: No more frames. Must be done, I guess.\n", ast_channel_uniqueid(chan));
+ ast_debug(3, "%s: No more frames. Must be done, I guess.\n",
+ ast_channel_uniqueid(chan));
break;
}
switch (f->frametype) {
case AST_FRAME_CONTROL:
if (f->subclass.integer == AST_CONTROL_HANGUP) {
- ast_debug(3, "%s: Received hangup\n", ast_channel_uniqueid(chan));
+ ast_debug(3, "%s: Received hangup\n",
+ ast_channel_uniqueid(chan));
hungup = 1;
}
break;
@@ -451,7 +485,8 @@
res = send_end_msg(app, chan);
if (res != 0) {
- ast_log(LOG_ERROR, "Error sending end message to %s\n", args.app_name);
+ ast_log(LOG_ERROR,
+ "Error sending end message to %s\n", args.app_name);
return res;
}
@@ -466,10 +501,11 @@
app = ao2_find(apps, app_name, OBJ_KEY);
if (!app) {
- /* XXX We can do a better job handling late binding, queueing up the call for a few seconds
- * to wait for the app to register.
+ /* XXX We can do a better job handling late binding, queueing up
+ * the call for a few seconds to wait for the app to register.
*/
- ast_log(LOG_WARNING, "Stasis app '%s' not registered\n", app_name);
+ ast_log(LOG_WARNING,
+ "Stasis app '%s' not registered\n", app_name);
return -1;
}
@@ -523,12 +559,14 @@
{
int r = 0;
- __apps_registry = ao2_container_alloc(APPS_NUM_BUCKETS, app_hash, app_compare);
+ __apps_registry =
+ ao2_container_alloc(APPS_NUM_BUCKETS, app_hash, app_compare);
if (__apps_registry == NULL) {
return AST_MODULE_LOAD_FAILURE;
}
- __app_controls = ao2_container_alloc(CONTROLS_NUM_BUCKETS, app_hash, app_compare);
+ __app_controls = ao2_container_alloc(CONTROLS_NUM_BUCKETS,
+ control_hash, control_compare);
if (__app_controls == NULL) {
return AST_MODULE_LOAD_FAILURE;
}
@@ -551,6 +589,7 @@
return r;
}
-AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS, "Stasis dialplan application",
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS,
+ "Stasis dialplan application",
.load = load_module,
.unload = unload_module);
Modified: team/qwell/fun_with_transports/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/channels/chan_sip.c?view=diff&rev=385269&r1=385268&r2=385269
==============================================================================
--- team/qwell/fun_with_transports/channels/chan_sip.c (original)
+++ team/qwell/fun_with_transports/channels/chan_sip.c Wed Apr 10 16:25:21 2013
@@ -7352,6 +7352,11 @@
int res = 0;
struct sip_pvt *p = ast_channel_tech_pvt(ast);
+ if (!p) {
+ ast_debug(1, "Asked to answer channel %s without tech pvt; ignoring\n",
+ ast_channel_name(ast));
+ return res;
+ }
sip_pvt_lock(p);
if (ast_channel_state(ast) != AST_STATE_UP) {
try_suggested_sip_codec(p);
@@ -7521,6 +7526,12 @@
struct sip_pvt *p = ast_channel_tech_pvt(ast);
int res = 0;
+ if (!p) {
+ ast_debug(1, "Asked to begin DTMF digit on channel %s with no pvt; ignoring\n",
+ ast_channel_name(ast));
+ return res;
+ }
+
sip_pvt_lock(p);
switch (ast_test_flag(&p->flags[0], SIP_DTMF)) {
case SIP_DTMF_INBAND:
@@ -7544,6 +7555,12 @@
{
struct sip_pvt *p = ast_channel_tech_pvt(ast);
int res = 0;
+
+ if (!p) {
+ ast_debug(1, "Asked to end DTMF digit on channel %s with no pvt; ignoring\n",
+ ast_channel_name(ast));
+ return res;
+ }
sip_pvt_lock(p);
switch (ast_test_flag(&p->flags[0], SIP_DTMF)) {
@@ -7570,6 +7587,12 @@
struct sip_pvt *p = ast_channel_tech_pvt(ast);
int res;
+ if (!p) {
+ ast_debug(1, "Asked to transfer channel %s with no pvt; ignoring\n",
+ ast_channel_name(ast));
+ return -1;
+ }
+
if (dest == NULL) /* functions below do not take a NULL */
dest = "";
sip_pvt_lock(p);
@@ -7764,6 +7787,12 @@
{
struct sip_pvt *p = ast_channel_tech_pvt(ast);
int res = 0;
+
+ if (!p) {
+ ast_debug(1, "Asked to indicate condition on channel %s with no pvt; ignoring\n",
+ ast_channel_name(ast));
+ return res;
+ }
sip_pvt_lock(p);
switch(condition) {
Modified: team/qwell/fun_with_transports/main/features.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/main/features.c?view=diff&rev=385269&r1=385268&r2=385269
==============================================================================
--- team/qwell/fun_with_transports/main/features.c (original)
+++ team/qwell/fun_with_transports/main/features.c Wed Apr 10 16:25:21 2013
@@ -3325,7 +3325,7 @@
char exten[FEATURE_MAX_LEN];
};
-struct feature_ds {
+struct feature_datastore {
struct ao2_container *feature_map;
/*!
@@ -3361,7 +3361,7 @@
static void feature_ds_destroy(void *data)
{
- struct feature_ds *feature_ds = data;
+ struct feature_datastore *feature_ds = data;
if (feature_ds->feature_map) {
ao2_ref(feature_ds->feature_map, -1);
@@ -3373,8 +3373,8 @@
static void *feature_ds_duplicate(void *data)
{
- struct feature_ds *old_ds = data;
- struct feature_ds *new_ds;
+ struct feature_datastore *old_ds = data;
+ struct feature_datastore *new_ds;
if (!(new_ds = ast_calloc(1, sizeof(*new_ds)))) {
return NULL;
@@ -3405,9 +3405,9 @@
*
* \return the data on the FEATURE datastore, or NULL on error
*/
-static struct feature_ds *get_feature_ds(struct ast_channel *chan)
-{
- struct feature_ds *feature_ds;
+static struct feature_datastore *get_feature_ds(struct ast_channel *chan)
+{
+ struct feature_datastore *feature_ds;
struct ast_datastore *ds;
if ((ds = ast_channel_datastore_find(chan, &feature_ds_info, NULL))) {
@@ -3462,7 +3462,7 @@
char *buf, size_t len)
{
struct ast_call_feature *feature;
- struct feature_ds *feature_ds;
+ struct feature_datastore *feature_ds;
struct feature_exten *fe = NULL;
*buf = '\0';
@@ -8959,7 +8959,7 @@
static unsigned int get_parkingtime(struct ast_channel *chan, struct ast_parkinglot *parkinglot)
{
const char *parkinglot_name;
- struct feature_ds *feature_ds;
+ struct feature_datastore *feature_ds;
unsigned int parkingtime;
ast_channel_lock(chan);
@@ -9024,7 +9024,7 @@
const char *value)
{
int res = 0;
- struct feature_ds *feature_ds;
+ struct feature_datastore *feature_ds;
ast_channel_lock(chan);
@@ -9077,7 +9077,7 @@
static int featuremap_write(struct ast_channel *chan, const char *cmd, char *data,
const char *value)
{
- struct feature_ds *feature_ds;
+ struct feature_datastore *feature_ds;
struct feature_exten *fe;
if (!ast_find_call_feature(data)) {
Modified: team/qwell/fun_with_transports/main/stasis_channels.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/main/stasis_channels.c?view=diff&rev=385269&r1=385268&r2=385269
==============================================================================
--- team/qwell/fun_with_transports/main/stasis_channels.c (original)
+++ team/qwell/fun_with_transports/main/stasis_channels.c Wed Apr 10 16:25:21 2013
@@ -153,6 +153,9 @@
snapshot->amaflags = ast_channel_amaflags(chan);
snapshot->hangupcause = ast_channel_hangupcause(chan);
snapshot->flags = *ast_channel_flags(chan);
+ snapshot->caller_pres = ast_party_id_presentation(&ast_channel_caller(chan)->id);
+
+ snapshot->manager_vars = ast_channel_get_manager_vars(chan);
ao2_ref(snapshot, +1);
return snapshot;
Modified: team/qwell/fun_with_transports/res/res_config_ldap.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/res/res_config_ldap.c?view=diff&rev=385269&r1=385268&r2=385269
==============================================================================
--- team/qwell/fun_with_transports/res/res_config_ldap.c (original)
+++ team/qwell/fun_with_transports/res/res_config_ldap.c Wed Apr 10 16:25:21 2013
@@ -1279,14 +1279,14 @@
}
mods_size = 2; /* one for the first param/value pair and one for the the terminating NULL */
- ldap_mods = ast_calloc(sizeof(LDAPMod *), mods_size);
- ldap_mods[0] = ast_calloc(1, sizeof(LDAPMod));
+ ldap_mods = ldap_memcalloc(sizeof(LDAPMod *), mods_size);
+ ldap_mods[0] = ldap_memcalloc(1, sizeof(LDAPMod));
ldap_mods[0]->mod_op = LDAP_MOD_REPLACE;
- ldap_mods[0]->mod_type = ast_strdup(newparam);
+ ldap_mods[0]->mod_type = ldap_strdup(newparam);
ldap_mods[0]->mod_values = ast_calloc(sizeof(char *), 2);
- ldap_mods[0]->mod_values[0] = ast_strdup(newval);
+ ldap_mods[0]->mod_values[0] = ldap_strdup(newval);
while ((newparam = va_arg(ap, const char *))) {
newparam = convert_attribute_name_to_ldap(table_config, newparam);
@@ -1296,7 +1296,7 @@
for (i = 0; i < mods_size - 1; i++) {
if (ldap_mods[i]&& !strcmp(ldap_mods[i]->mod_type, newparam)) {
/* We have the parameter allready, adding the value as a semicolon delimited value */
- ldap_mods[i]->mod_values[0] = ast_realloc(ldap_mods[i]->mod_values[0], sizeof(char) * (strlen(ldap_mods[i]->mod_values[0]) + strlen(newval) + 2));
+ ldap_mods[i]->mod_values[0] = ldap_memrealloc(ldap_mods[i]->mod_values[0], sizeof(char) * (strlen(ldap_mods[i]->mod_values[0]) + strlen(newval) + 2));
strcat(ldap_mods[i]->mod_values[0], ";");
strcat(ldap_mods[i]->mod_values[0], newval);
mod_exists = 1;
@@ -1307,12 +1307,12 @@
/* create new mod */
if (!mod_exists) {
mods_size++;
- ldap_mods = ast_realloc(ldap_mods, sizeof(LDAPMod *) * mods_size);
+ ldap_mods = ldap_memrealloc(ldap_mods, sizeof(LDAPMod *) * mods_size);
ldap_mods[mods_size - 1] = NULL;
- ldap_mods[mods_size - 2] = ast_calloc(1, sizeof(LDAPMod));
-
- ldap_mods[mods_size - 2]->mod_type = ast_calloc(sizeof(char), strlen(newparam) + 1);
+ ldap_mods[mods_size - 2] = ldap_memcalloc(1, sizeof(LDAPMod));
+
+ ldap_mods[mods_size - 2]->mod_type = ldap_memcalloc(sizeof(char), strlen(newparam) + 1);
strcpy(ldap_mods[mods_size - 2]->mod_type, newparam);
if (strlen(newval) == 0) {
@@ -1320,8 +1320,8 @@
} else {
ldap_mods[mods_size - 2]->mod_op = LDAP_MOD_REPLACE;
- ldap_mods[mods_size - 2]->mod_values = ast_calloc(sizeof(char *), 2);
- ldap_mods[mods_size - 2]->mod_values[0] = ast_calloc(sizeof(char), strlen(newval) + 1);
+ ldap_mods[mods_size - 2]->mod_values = ldap_memcalloc(sizeof(char *), 2);
+ ldap_mods[mods_size - 2]->mod_values[0] = ldap_memcalloc(sizeof(char), strlen(newval) + 1);
strcpy(ldap_mods[mods_size - 2]->mod_values[0], newval);
}
}
More information about the asterisk-commits
mailing list