[asterisk-commits] qwell: branch qwell/ari_channel_dial r392271 - /team/qwell/ari_channel_dial/r...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Jun 19 13:53:16 CDT 2013
Author: qwell
Date: Wed Jun 19 13:53:15 2013
New Revision: 392271
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=392271
Log:
Add some error handling.
Modified:
team/qwell/ari_channel_dial/res/stasis/control.c
Modified: team/qwell/ari_channel_dial/res/stasis/control.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/ari_channel_dial/res/stasis/control.c?view=diff&rev=392271&r1=392270&r2=392271
==============================================================================
--- team/qwell/ari_channel_dial/res/stasis/control.c (original)
+++ team/qwell/ari_channel_dial/res/stasis/control.c Wed Jun 19 13:53:15 2013
@@ -90,32 +90,42 @@
static void *app_control_dial(struct stasis_app_control *control,
struct ast_channel *chan, void *data)
{
+ RAII_VAR(struct ast_dial *, dial, ast_dial_create(), ast_dial_destroy);
const char *endpoint = data;
enum ast_dial_result res;
- struct ast_dial *dial;
char *tech, *resource;
struct ast_channel *new_chan;
struct ast_bridge *bridge;
tech = ast_strdupa(endpoint);
- resource = strchr(tech, '/');
+ if (!(resource = strchr(tech, '/'))) {
+ return NULL;
+ }
*resource++ = '\0';
- dial = ast_dial_create();
- ast_dial_append(dial, tech, resource);
+ if (!dial) {
+ ast_log(LOG_ERROR, "Failed to create dialing structure.\n");
+ return NULL;
+ }
+
+ if (ast_dial_append(dial, tech, resource) < 0) {
+ ast_log(LOG_ERROR, "Failed to add %s/%s to dialing structure.\n", tech, resource);
+ return NULL;
+ }
res = ast_dial_run(dial, chan, 0);
if (res != AST_DIAL_RESULT_ANSWERED || !(new_chan = ast_dial_answered_steal(dial))) {
return NULL;
}
- bridge = ast_bridge_basic_new();
+ if (!(bridge = ast_bridge_basic_new())) {
+ ast_log(LOG_ERROR, "Failed to create basic bridge.\n");
+ return NULL;
+ }
ast_bridge_impart(bridge, new_chan, NULL, NULL, 1);
stasis_app_control_add_channel_to_bridge(control, bridge);
-
- ast_dial_destroy(dial);
return NULL;
}
More information about the asterisk-commits
mailing list