mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 12:16:00 +00:00
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
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
@@ -761,7 +761,7 @@ static int spandsp_fax_gateway_start(struct ast_fax_session *s) {
|
||||
struct spandsp_pvt *p = s->tech_pvt;
|
||||
struct ast_fax_t38_parameters *t38_param;
|
||||
int i;
|
||||
struct ast_channel *peer;
|
||||
RAII_VAR(struct ast_channel *, peer, NULL, ao2_cleanup);
|
||||
static struct ast_generator t30_gen = {
|
||||
.alloc = spandsp_fax_gw_gen_alloc,
|
||||
.release = spandsp_fax_gw_gen_release,
|
||||
@@ -782,7 +782,7 @@ static int spandsp_fax_gateway_start(struct ast_fax_session *s) {
|
||||
|
||||
p->ist38 = 1;
|
||||
p->ast_t38_state = ast_channel_get_t38_state(s->chan);
|
||||
if (!(peer = ast_bridged_channel(s->chan))) {
|
||||
if (!(peer = ast_channel_bridge_peer(s->chan))) {
|
||||
ast_channel_unlock(s->chan);
|
||||
return -1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user