summaryrefslogtreecommitdiff
path: root/res/res_fax.c
diff options
context:
space:
mode:
authorMatthew Jordan <mjordan@digium.com>2013-05-27 01:33:12 +0000
committerMatthew Jordan <mjordan@digium.com>2013-05-27 01:33:12 +0000
commit2d2a47fae380a78ef9a2f14cb8dcb84d58ef58c5 (patch)
tree831214d29098f37a481f7b315f8aea64e2808203 /res/res_fax.c
parenta0f6d1848bd42e7379b46c7952460f1711e4d0fb (diff)
Fix some more fax test errors due to needing the peer in a bridge
In r389799, a number of fax errors in gateway mode were fixed by using the appropriate function to get a channel's peer while in a bridge. This patch does two things: (1) It uses the same function in res_fax_spandsp while starting the fax gateway. Without this, the fax gateway will not actually start up, as res_fax_spandsp also must inspect the channel's peer in a two-party bridge (2) It refactors some ao2 objects in sendfax_exec to use RAII_VAR. This was reverted in r389799 as some off nominal paths were getting hit without the fix in (1) that indicated an ao2 object issue; this turned out to be a red herring (which is an odd phrase) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@389827 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_fax.c')
-rw-r--r--res/res_fax.c26
1 files changed, 3 insertions, 23 deletions
diff --git a/res/res_fax.c b/res/res_fax.c
index 1886a32a1..1a9f4f749 100644
--- a/res/res_fax.c
+++ b/res/res_fax.c
@@ -2285,8 +2285,8 @@ static int sendfax_exec(struct ast_channel *chan, const char *data)
{
char *parse, *filenames, *c, modems[128] = "";
int channel_alive, file_count;
- struct ast_fax_session_details *details;
- struct ast_fax_session *s;
+ RAII_VAR(struct ast_fax_session_details *, details, NULL, ao2_cleanup);
+ RAII_VAR(struct ast_fax_session *, s, NULL, ao2_cleanup);
struct ast_fax_tech_token *token = NULL;
struct ast_fax_document *doc;
AST_DECLARE_APP_ARGS(args,
@@ -2321,7 +2321,6 @@ static int sendfax_exec(struct ast_channel *chan, const char *data)
ast_string_field_set(details, resultstr, "can't send a fax on a channel with a T.38 gateway");
set_channel_variables(chan, details);
ast_log(LOG_ERROR, "executing SendFAX on a channel with a T.38 Gateway is not supported\n");
- ao2_ref(details, -1);
return -1;
}
@@ -2330,7 +2329,6 @@ static int sendfax_exec(struct ast_channel *chan, const char *data)
ast_string_field_set(details, resultstr, "maxrate is less than minrate");
set_channel_variables(chan, details);
ast_log(LOG_ERROR, "maxrate %d is less than minrate %d\n", details->maxrate, details->minrate);
- ao2_ref(details, -1);
return -1;
}
@@ -2340,7 +2338,6 @@ static int sendfax_exec(struct ast_channel *chan, const char *data)
ast_string_field_set(details, error, "INVALID_ARGUMENTS");
ast_string_field_set(details, resultstr, "incompatible 'modems' and 'minrate' settings");
set_channel_variables(chan, details);
- ao2_ref(details, -1);
return -1;
}
@@ -2350,7 +2347,6 @@ static int sendfax_exec(struct ast_channel *chan, const char *data)
ast_string_field_set(details, error, "INVALID_ARGUMENTS");
ast_string_field_set(details, resultstr, "incompatible 'modems' and 'maxrate' settings");
set_channel_variables(chan, details);
- ao2_ref(details, -1);
return -1;
}
@@ -2359,7 +2355,6 @@ static int sendfax_exec(struct ast_channel *chan, const char *data)
ast_string_field_set(details, resultstr, "invalid arguments");
set_channel_variables(chan, details);
ast_log(LOG_WARNING, "%s requires an argument (filename[&filename[&filename]][,options])\n", app_sendfax);
- ao2_ref(details, -1);
return -1;
}
parse = ast_strdupa(data);
@@ -2367,11 +2362,10 @@ static int sendfax_exec(struct ast_channel *chan, const char *data)
if (!ast_strlen_zero(args.options) &&
- ast_app_parse_options(fax_exec_options, &opts, NULL, args.options)) {
+ ast_app_parse_options(fax_exec_options, &opts, NULL, args.options)) {
ast_string_field_set(details, error, "INVALID_ARGUMENTS");
ast_string_field_set(details, resultstr, "invalid arguments");
set_channel_variables(chan, details);
- ao2_ref(details, -1);
return -1;
}
if (ast_strlen_zero(args.filenames)) {
@@ -2379,7 +2373,6 @@ static int sendfax_exec(struct ast_channel *chan, const char *data)
ast_string_field_set(details, resultstr, "invalid arguments");
set_channel_variables(chan, details);
ast_log(LOG_WARNING, "%s requires an argument (filename[&filename[&filename]],options])\n", app_sendfax);
- ao2_ref(details, -1);
return -1;
}
@@ -2389,7 +2382,6 @@ static int sendfax_exec(struct ast_channel *chan, const char *data)
ast_string_field_set(details, resultstr, "invalid arguments");
set_channel_variables(chan, details);
ast_log(LOG_WARNING, "%s does not support polling\n", app_sendfax);
- ao2_ref(details, -1);
return -1;
}
@@ -2403,7 +2395,6 @@ static int sendfax_exec(struct ast_channel *chan, const char *data)
ast_string_field_set(details, resultstr, "error reading file");
set_channel_variables(chan, details);
ast_log(LOG_ERROR, "access failure. Verify '%s' exists and check permissions.\n", args.filenames);
- ao2_ref(details, -1);
return -1;
}
@@ -2412,7 +2403,6 @@ static int sendfax_exec(struct ast_channel *chan, const char *data)
ast_string_field_set(details, resultstr, "error allocating memory");
set_channel_variables(chan, details);
ast_log(LOG_ERROR, "System cannot provide memory for session requirements.\n");
- ao2_ref(details, -1);
return -1;
}
@@ -2457,7 +2447,6 @@ static int sendfax_exec(struct ast_channel *chan, const char *data)
ast_string_field_set(details, resultstr, "error reserving fax session");
set_channel_variables(chan, details);
ast_log(LOG_ERROR, "Unable to reserve FAX session.\n");
- ao2_ref(details, -1);
return -1;
}
@@ -2468,8 +2457,6 @@ static int sendfax_exec(struct ast_channel *chan, const char *data)
set_channel_variables(chan, details);
ast_log(LOG_WARNING, "Channel '%s' failed answer attempt.\n", ast_channel_name(chan));
fax_session_release(s, token);
- ao2_ref(s, -1);
- ao2_ref(details, -1);
return -1;
}
}
@@ -2480,8 +2467,6 @@ static int sendfax_exec(struct ast_channel *chan, const char *data)
ast_string_field_set(details, resultstr, "error negotiating T.38");
set_channel_variables(chan, details);
fax_session_release(s, token);
- ao2_ref(s, -1);
- ao2_ref(details, -1);
return -1;
}
} else {
@@ -2494,8 +2479,6 @@ static int sendfax_exec(struct ast_channel *chan, const char *data)
ast_string_field_set(details, resultstr, "error negotiating T.38");
set_channel_variables(chan, details);
fax_session_release(s, token);
- ao2_ref(s, -1);
- ao2_ref(details, -1);
ast_log(LOG_ERROR, "error initializing channel '%s' in T.38 mode\n", ast_channel_name(chan));
return -1;
}
@@ -2523,9 +2506,6 @@ static int sendfax_exec(struct ast_channel *chan, const char *data)
ast_log(AST_LOG_ERROR, "Error publishing SendFAX status message\n");
}
- ao2_ref(s, -1);
- ao2_ref(details, -1);
-
/* If the channel hungup return -1; otherwise, return 0 to continue in the dialplan */
return (!channel_alive) ? -1 : 0;
}