mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-11 23:28:59 +00:00
res_parking: Misc fixes.
res/parking/parking_applications.c: * Add malloc fail checks in setup_park_common_datastore(). * Fix playing parking failed announcement to only happen on non-blind transfers in park_app_exec(). It could never go out before because a test was provedly always false. res/parking/parking_bridge.c: * Fix NULL tolerance in generate_parked_user() because bridge_parking_push() can theoretically pass a NULL parker channel if the parker channel went away for some reason. * Clarify some weird code dealing with blind_transfer in bridge_parking_push(). res/parking/parking_bridge_features.c: * Made park_local_transfer() set BLINDTRANSFER on the Local;1 channel which will be bulk copied to the Local;2 channel on the subsequent ast_call(). The additional advantage is if the parker channel has the BLINDTRANSFER and ATTENDEDTRANSFER variables set they are now guaranteed to be overridden. res/parking/parking_manager.c: * Fix AMI Park action input range checking of the Timeout header in manager_park(). * Reduced locking scope to where needed in manager_park(). res/res_parking.c: * Fix some off nominal missing unlocks by eliminating the returns. Change-Id: Ib64945bc285acb05a306dc12e6f16854898915ca
This commit is contained in:
@@ -339,16 +339,17 @@ static int setup_park_common_datastore(struct ast_channel *parkee, const char *p
|
||||
ast_datastore_free(datastore);
|
||||
return -1;
|
||||
}
|
||||
datastore->data = park_datastore;
|
||||
|
||||
if (parker_uuid) {
|
||||
park_datastore->parker_uuid = ast_strdup(parker_uuid);
|
||||
park_datastore->parker_uuid = ast_strdup(parker_uuid);
|
||||
if (!park_datastore->parker_uuid) {
|
||||
ast_datastore_free(datastore);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ast_channel_lock(parkee);
|
||||
|
||||
attended_transfer = pbx_builtin_getvar_helper(parkee, "ATTENDEDTRANSFER");
|
||||
blind_transfer = pbx_builtin_getvar_helper(parkee, "BLINDTRANSFER");
|
||||
|
||||
if (!ast_strlen_zero(attended_transfer)) {
|
||||
parker_dial_string = ast_strdupa(attended_transfer);
|
||||
} else if (!ast_strlen_zero(blind_transfer)) {
|
||||
@@ -356,7 +357,6 @@ static int setup_park_common_datastore(struct ast_channel *parkee, const char *p
|
||||
/* Ensure that attended_transfer is NULL and not an empty string. */
|
||||
attended_transfer = NULL;
|
||||
}
|
||||
|
||||
ast_channel_unlock(parkee);
|
||||
|
||||
if (!ast_strlen_zero(parker_dial_string)) {
|
||||
@@ -365,6 +365,10 @@ static int setup_park_common_datastore(struct ast_channel *parkee, const char *p
|
||||
parker_dial_string,
|
||||
attended_transfer ? "ATTENDEDTRANSFER" : "BLINDTRANSFER");
|
||||
park_datastore->parker_dial_string = ast_strdup(parker_dial_string);
|
||||
if (!park_datastore->parker_dial_string) {
|
||||
ast_datastore_free(datastore);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
park_datastore->randomize = randomize;
|
||||
@@ -373,10 +377,13 @@ static int setup_park_common_datastore(struct ast_channel *parkee, const char *p
|
||||
|
||||
if (comeback_override) {
|
||||
park_datastore->comeback_override = ast_strdup(comeback_override);
|
||||
if (!park_datastore->comeback_override) {
|
||||
ast_datastore_free(datastore);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
datastore->data = park_datastore;
|
||||
ast_channel_lock(parkee);
|
||||
ast_channel_datastore_add(parkee, datastore);
|
||||
ast_channel_unlock(parkee);
|
||||
@@ -391,23 +398,23 @@ struct park_common_datastore *get_park_common_datastore_copy(struct ast_channel
|
||||
struct park_common_datastore *data_copy;
|
||||
|
||||
SCOPED_CHANNELLOCK(lock, parkee);
|
||||
|
||||
if (!(datastore = ast_channel_datastore_find(parkee, &park_common_info, NULL))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data = datastore->data;
|
||||
|
||||
if (!data) {
|
||||
/* This data should always be populated if this datastore was appended to the channel */
|
||||
ast_assert(0);
|
||||
}
|
||||
/* This data should always be populated if this datastore was appended to the channel */
|
||||
ast_assert(data != NULL);
|
||||
|
||||
data_copy = ast_calloc(1, sizeof(*data_copy));
|
||||
if (!data_copy) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(data_copy->parker_uuid = ast_strdup(data->parker_uuid))) {
|
||||
data_copy->parker_uuid = ast_strdup(data->parker_uuid);
|
||||
if (!data_copy->parker_uuid) {
|
||||
park_common_datastore_free(data_copy);
|
||||
return NULL;
|
||||
}
|
||||
@@ -457,7 +464,6 @@ struct ast_bridge *park_common_setup(struct ast_channel *parkee, struct ast_chan
|
||||
if (!lot) {
|
||||
lot = parking_create_dynamic_lot(lot_name, parkee);
|
||||
}
|
||||
|
||||
if (!lot) {
|
||||
ast_log(LOG_ERROR, "Could not find parking lot: '%s'\n", lot_name);
|
||||
return NULL;
|
||||
@@ -504,7 +510,7 @@ static int park_app_exec(struct ast_channel *chan, const char *data)
|
||||
struct ast_bridge_features chan_features;
|
||||
int res;
|
||||
int silence_announcements = 0;
|
||||
const char *transferer;
|
||||
int blind_transfer;
|
||||
|
||||
/* Answer the channel if needed */
|
||||
if (ast_channel_state(chan) != AST_STATE_UP) {
|
||||
@@ -512,15 +518,12 @@ static int park_app_exec(struct ast_channel *chan, const char *data)
|
||||
}
|
||||
|
||||
ast_channel_lock(chan);
|
||||
if (!(transferer = pbx_builtin_getvar_helper(chan, "ATTENDEDTRANSFER"))) {
|
||||
transferer = pbx_builtin_getvar_helper(chan, "BLINDTRANSFER");
|
||||
}
|
||||
transferer = ast_strdupa(S_OR(transferer, ""));
|
||||
blind_transfer = !ast_strlen_zero(pbx_builtin_getvar_helper(chan, "BLINDTRANSFER"));
|
||||
ast_channel_unlock(chan);
|
||||
|
||||
/* Handle the common parking setup stuff */
|
||||
if (!(parking_bridge = park_application_setup(chan, NULL, data, &silence_announcements))) {
|
||||
if (!silence_announcements && !transferer) {
|
||||
if (!silence_announcements && !blind_transfer) {
|
||||
ast_stream_and_wait(chan, "pbx-parkingfailed", "");
|
||||
}
|
||||
publish_parked_call_failure(chan);
|
||||
@@ -593,7 +596,6 @@ static int parked_call_app_exec(struct ast_channel *chan, const char *data)
|
||||
}
|
||||
|
||||
lot = parking_lot_find_by_name(lot_name);
|
||||
|
||||
if (!lot) {
|
||||
ast_log(LOG_ERROR, "Could not find the requested parking lot\n");
|
||||
ast_stream_and_wait(chan, "pbx-invalidpark", "");
|
||||
|
Reference in New Issue
Block a user