[asterisk-commits] jrose: branch jrose/bridge_projects r385809 - in /team/jrose/bridge_projects:...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Apr 15 13:55:58 CDT 2013
Author: jrose
Date: Mon Apr 15 13:55:56 2013
New Revision: 385809
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=385809
Log:
Most of Richard's review that he sent me should be addressed by this. Also Kinsey's request for ParkedCalls manager action to be able to handle specified lots
Modified:
team/jrose/bridge_projects/CHANGES
team/jrose/bridge_projects/include/asterisk/parking.h
team/jrose/bridge_projects/main/bridging.c
team/jrose/bridge_projects/res/parking/parking_bridge.c
team/jrose/bridge_projects/res/parking/parking_controller.c
team/jrose/bridge_projects/res/parking/parking_manager.c
team/jrose/bridge_projects/res/parking/parking_ui.c
team/jrose/bridge_projects/res/parking/res_parking.h
team/jrose/bridge_projects/res/res_parking.c
Modified: team/jrose/bridge_projects/CHANGES
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/CHANGES?view=diff&rev=385809&r1=385808&r2=385809
==============================================================================
--- team/jrose/bridge_projects/CHANGES (original)
+++ team/jrose/bridge_projects/CHANGES Mon Apr 15 13:55:56 2013
@@ -156,6 +156,9 @@
* The CLI command 'parkedcalls' is now deprecated in favor of
'parking show <parkinglot>'.
+
+ * The AMI command 'ParkedCalls' will now accept a 'ParkingLot' argument which
+ can be used to get a list of parked calls only for a specific parking lot.
Queue
-------------------
Modified: team/jrose/bridge_projects/include/asterisk/parking.h
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/include/asterisk/parking.h?view=diff&rev=385809&r1=385808&r2=385809
==============================================================================
--- team/jrose/bridge_projects/include/asterisk/parking.h (original)
+++ team/jrose/bridge_projects/include/asterisk/parking.h Mon Apr 15 13:55:56 2013
@@ -71,7 +71,10 @@
* \retval NULL if the parked call payload can't be allocated
* \retval reference to a newly created parked call payload
*/
-struct ast_parked_call_payload *ast_parked_call_payload_create(enum ast_parked_call_event_type event_type, struct ast_channel_snapshot *parkee_snapshot, struct ast_channel_snapshot *parker_snapshot, struct ast_channel_snapshot *retriever_snapshot, const char *parkinglot, unsigned int parkingspace, unsigned long int timeout, unsigned long int duration);
+struct ast_parked_call_payload *ast_parked_call_payload_create(enum ast_parked_call_event_type event_type,
+ struct ast_channel_snapshot *parkee_snapshot, struct ast_channel_snapshot *parker_snapshot,
+ struct ast_channel_snapshot *retriever_snapshot, const char *parkinglot,
+ unsigned int parkingspace, unsigned long int timeout, unsigned long int duration);
/*!
* \brief initialize parking stasis types
Modified: team/jrose/bridge_projects/main/bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/main/bridging.c?view=diff&rev=385809&r1=385808&r2=385809
==============================================================================
--- team/jrose/bridge_projects/main/bridging.c (original)
+++ team/jrose/bridge_projects/main/bridging.c Mon Apr 15 13:55:56 2013
@@ -511,6 +511,8 @@
}
}
+ ast_bridge_channel_clear_roles(bridge_channel);
+
/* Remove channel from the bridge */
if (!bridge_channel->suspended) {
--bridge->num_active;
@@ -575,12 +577,14 @@
}
/* Add channel to the bridge */
- if (bridge->v_table->push(bridge, bridge_channel, swap)) {
+ if (ast_bridge_channel_establish_roles(bridge_channel) || bridge->v_table->push(bridge, bridge_channel, swap)) {
+ /* A bridge channel can not be pushed if its roles can't be copied properly. */
ast_log(LOG_ERROR, "Bridge %s: failed to push channel %s into bridge\n",
bridge->uniqueid, ast_channel_name(bridge_channel->chan));
ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_HANGUP);
return;
}
+
bridge_channel->in_bridge = 1;
bridge_channel->just_joined = 1;
AST_LIST_INSERT_TAIL(&bridge->channels, bridge_channel, entry);
@@ -2465,8 +2469,6 @@
struct ast_bridge_channel *bridge_channel = obj;
struct ast_frame *fr;
- ast_bridge_channel_clear_roles(bridge_channel);
-
if (bridge_channel->callid) {
bridge_channel->callid = ast_callid_unref(bridge_channel->callid);
}
@@ -2863,16 +2865,6 @@
bridge_channel->swap = swap;
bridge_channel->features = features;
- if (ast_bridge_channel_establish_roles(bridge_channel)) {
- /* A bridge channel should not be allowed to join if its roles couldn't be copied properly. */
- state = AST_BRIDGE_CHANNEL_STATE_HANGUP;
- ast_channel_lock(chan);
- ast_channel_internal_bridge_channel_set(chan, NULL);
- ast_channel_unlock(chan);
- ao2_ref(bridge_channel, -1);
- goto join_exit;
- }
-
bridge_channel_join(bridge_channel);
state = bridge_channel->state;
@@ -2977,11 +2969,6 @@
bridge_channel->depart_wait = independent ? 0 : 1;
bridge_channel->callid = ast_read_threadstorage_callid();
- if (ast_bridge_channel_establish_roles(bridge_channel)) {
- res = -1;
- goto bridge_impart_cleanup;
- }
-
/* Actually create the thread that will handle the channel */
if (independent) {
/* Independently imparted channels cannot have a PBX. */
@@ -2997,7 +2984,6 @@
bridge_channel_depart_thread, bridge_channel);
}
-bridge_impart_cleanup:
if (res) {
/* cleanup */
ast_channel_lock(chan);
@@ -3136,10 +3122,6 @@
}
bridge_channel_pull(bridge_channel);
-
- /* While we are pulled we need to re-establish the channel roles */
- ast_bridge_channel_clear_roles(bridge_channel);
- ast_bridge_channel_establish_roles(bridge_channel);
/* Point to new bridge. */
ao2_ref(bridge_dst, +1);
Modified: team/jrose/bridge_projects/res/parking/parking_bridge.c
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/res/parking/parking_bridge.c?view=diff&rev=385809&r1=385808&r2=385809
==============================================================================
--- team/jrose/bridge_projects/res/parking/parking_bridge.c (original)
+++ team/jrose/bridge_projects/res/parking/parking_bridge.c Mon Apr 15 13:55:56 2013
@@ -124,7 +124,7 @@
}
/* We should already have a parked user set for the channel when we push. Take a reference to it. We'll keep this. */
- for (iter = ao2_iterator_init(self->lot->parked_user_list, 0); (pu = ao2_iterator_next(&iter)); ao2_ref(pu, -1)) {
+ for (iter = ao2_iterator_init(self->lot->parked_users, 0); (pu = ao2_iterator_next(&iter)); ao2_ref(pu, -1)) {
if (bridge_channel->chan != pu->chan) {
continue;
}
Modified: team/jrose/bridge_projects/res/parking/parking_controller.c
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/res/parking/parking_controller.c?view=diff&rev=385809&r1=385808&r2=385809
==============================================================================
--- team/jrose/bridge_projects/res/parking/parking_controller.c (original)
+++ team/jrose/bridge_projects/res/parking/parking_controller.c Mon Apr 15 13:55:56 2013
@@ -73,7 +73,7 @@
int unpark_parked_user(struct parked_user *pu)
{
if (pu->lot_state) {
- ao2_unlink(pu->lot_state->parked_user_list, pu);
+ ao2_unlink(pu->lot_state->parked_users, pu);
parking_lot_state_remove_if_unused(pu->lot_state);
return 0;
}
@@ -105,7 +105,7 @@
wrap = lot->parking_start;
- i = ao2_iterator_init(lot->parked_user_list, 0);
+ i = ao2_iterator_init(lot->parked_users, 0);
while ((user = ao2_iterator_next(&i))) {
/* Only deal with wrap until we get to the target */
if (wrap == user->parking_space) {
@@ -168,9 +168,9 @@
RAII_VAR(struct parked_user *, user, NULL, ao2_cleanup);
if (target < 0) {
- user = ao2_callback(lot->parked_user_list, 0, retrieve_parked_user_first, NULL);
+ user = ao2_callback(lot->parked_users, 0, retrieve_parked_user_first, NULL);
} else {
- user = ao2_callback(lot->parked_user_list, 0, retrieve_parked_user_targeted, &target);
+ user = ao2_callback(lot->parked_users, 0, retrieve_parked_user_targeted, &target);
}
if (!user) {
@@ -184,7 +184,7 @@
return NULL;
}
- ao2_unlink(lot->parked_user_list, user);
+ ao2_unlink(lot->parked_users, user);
user->resolution = PARK_ANSWERED;
ao2_unlock(user);
@@ -359,7 +359,7 @@
}
/* Insert into the parking lot's parked user list. We can unlock the lot now. */
- ao2_link(lot_state->parked_user_list, new_parked_user);
+ ao2_link(lot_state->parked_users, new_parked_user);
ao2_unlock(lot_state);
return new_parked_user;
Modified: team/jrose/bridge_projects/res/parking/parking_manager.c
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/res/parking/parking_manager.c?view=diff&rev=385809&r1=385808&r2=385809
==============================================================================
--- team/jrose/bridge_projects/res/parking/parking_manager.c (original)
+++ team/jrose/bridge_projects/res/parking/parking_manager.c Mon Apr 15 13:55:56 2013
@@ -56,6 +56,9 @@
</synopsis>
<syntax>
<xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" />
+ <parameter name="ParkingLot">
+ <para>If specified, only show parked calls from the parking lot with this name.</para>
+ </parameter>
</syntax>
<description>
<para>List parked calls.</para>
@@ -292,27 +295,65 @@
return out;
}
-static int manager_parking_status(struct mansession *s, const struct message *m)
-{
+static int manager_parking_status_single_lot(struct mansession *s, const struct message *m, const char *id_text, const char *lot_name)
+{
+ RAII_VAR(struct parking_lot_state *, curlot, NULL, ao2_cleanup);
struct parked_user *curuser;
- const char *id = astman_get_header(m, "ActionID");
- char id_text[256] = "";
+ struct ao2_iterator iter_users;
+ int total = 0;
+
+ curlot = parking_lot_state_find_by_name(lot_name);
+
+ if (!curlot) {
+ astman_send_error(s, m, "Requested ParkingLot could not be found.");
+ return RESULT_SUCCESS;
+ }
+
+ iter_users = ao2_iterator_init(curlot->parked_users, 0);
+ while ((curuser = ao2_iterator_next(&iter_users))) {
+ RAII_VAR(struct ast_parked_call_payload *, payload, NULL, ao2_cleanup);
+ RAII_VAR(struct ast_str *, parked_call_string, NULL, ast_free);
+ payload = parked_call_payload_from_parked_user(curuser, PARKED_CALL);
+ parked_call_string = manager_build_parked_call_string(payload);
+ total++;
+
+ astman_append(s, "Event: ParkedCall\r\n"
+ "%s" /* The parked call string */
+ "%s" /* The action ID */
+ "\r\n",
+ ast_str_buffer(parked_call_string),
+ id_text);
+
+ ao2_ref(curuser, -1);
+ }
+
+ ao2_iterator_destroy(&iter_users);
+
+ astman_append(s,
+ "Event: ParkedCallsComplete\r\n"
+ "Total: %d\r\n"
+ "%s"
+ "\r\n",
+ total, id_text);
+
+ return RESULT_SUCCESS;
+}
+
+static int manager_parking_status_all_lots(struct mansession *s, const struct message *m, const char *id_text)
+{
+ struct parked_user *curuser;
struct ao2_container *lot_container;
struct ao2_iterator iter_lots;
struct ao2_iterator iter_users;
struct parking_lot_state *curlot;
int total = 0;
- if (!ast_strlen_zero(id)) {
- snprintf(id_text, sizeof(id_text), "ActionID: %s\r\n", id);
- }
-
lot_container = get_parking_lot_state_container();
if (!lot_container) {
ast_log(LOG_ERROR, "Failed to obtain parking lot list. Action canceled.\n");
astman_send_error(s, m, "Could not create parking lot list");
- return -1;
+ return RESULT_SUCCESS;
}
iter_lots = ao2_iterator_init(lot_container, 0);
@@ -320,7 +361,7 @@
astman_send_ack(s, m, "Parked calls will follow");
while ((curlot = ao2_iterator_next(&iter_lots))) {
- iter_users = ao2_iterator_init(curlot->parked_user_list, 0);
+ iter_users = ao2_iterator_init(curlot->parked_users, 0);
while ((curuser = ao2_iterator_next(&iter_users))) {
RAII_VAR(struct ast_parked_call_payload *, payload, NULL, ao2_cleanup);
RAII_VAR(struct ast_str *, parked_call_string, NULL, ast_free);
@@ -351,6 +392,24 @@
total, id_text);
return RESULT_SUCCESS;
+}
+
+static int manager_parking_status(struct mansession *s, const struct message *m)
+{
+ const char *id = astman_get_header(m, "ActionID");
+ const char *lot_name = astman_get_header(m, "ParkingLot");
+ char id_text[256] = "";
+
+ if (!ast_strlen_zero(id)) {
+ snprintf(id_text, sizeof(id_text), "ActionID: %s\r\n", id);
+ }
+
+ if (!ast_strlen_zero(lot_name)) {
+ return manager_parking_status_single_lot(s, m, id_text, lot_name);
+ }
+
+ return manager_parking_status_all_lots(s, m, id_text);
+
}
static int manager_append_event_parking_lot_data_cb(void *obj, void *arg, void *data, int flags)
Modified: team/jrose/bridge_projects/res/parking/parking_ui.c
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/res/parking/parking_ui.c?view=diff&rev=385809&r1=385808&r2=385809
==============================================================================
--- team/jrose/bridge_projects/res/parking/parking_ui.c (original)
+++ team/jrose/bridge_projects/res/parking/parking_ui.c Mon Apr 15 13:55:56 2013
@@ -91,13 +91,13 @@
ast_cli(fd, "Parked Calls\n------------\n");
- if (!ao2_container_count(lot->parked_user_list)) {
+ if (!ao2_container_count(lot->parked_users)) {
ast_cli(fd, " (none)\n");
ast_cli(fd, "\n\n");
return;
}
- ao2_callback(lot->parked_user_list, OBJ_MULTIPLE | OBJ_NODATA, display_parked_users_cb, &fd);
+ ao2_callback(lot->parked_users, OBJ_MULTIPLE | OBJ_NODATA, display_parked_users_cb, &fd);
ast_cli(fd, "\n");
}
Modified: team/jrose/bridge_projects/res/parking/res_parking.h
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/res/parking/res_parking.h?view=diff&rev=385809&r1=385808&r2=385809
==============================================================================
--- team/jrose/bridge_projects/res/parking/res_parking.h (original)
+++ team/jrose/bridge_projects/res/parking/res_parking.h Mon Apr 15 13:55:56 2013
@@ -67,7 +67,7 @@
int parking_disabled; /*!< Used for reloading, keeps calls from being parked to a parking lot removed from configs */
struct ast_bridge *parking_bridge; /*!< Bridged where parked calls will rest until they are answered or otherwise leave */
- struct ao2_container *parked_user_list; /*!< List of parked users rigidly ordered by their parking space */
+ struct ao2_container *parked_users; /*!< List of parked users rigidly ordered by their parking space */
int has_owner; /*!< Used for reloading, marks a parking lot to be removed from the list of parking lots when
* its last parked call has departed the parking_brige.
Modified: team/jrose/bridge_projects/res/res_parking.c
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/res/res_parking.c?view=diff&rev=385809&r1=385808&r2=385809
==============================================================================
--- team/jrose/bridge_projects/res/res_parking.c (original)
+++ team/jrose/bridge_projects/res/res_parking.c Mon Apr 15 13:55:56 2013
@@ -212,11 +212,83 @@
static int parking_lot_state_cmp_fn(void *obj, void *arg, const int flags)
{
- struct parking_lot_state *entry1 = obj;
+ return CMP_MATCH;
+}
+
+/*! All parking lots that are currently alive in some fashion can be obtained from here */
+static struct ao2_container *parking_lot_state_container;
+
+static void *parking_config_alloc(void);
+
+static void *parking_lot_cfg_alloc(const char *cat);
+static void *named_item_find(struct ao2_container *container, const char *name); /* XXX This is really just a generic string find. Move to astobj2.c? */
+
+struct parking_global_config {
+ int parkeddynamic; /* XXX This feature still needs to be implemented. Entirely. */
+};
+
+struct parking_config {
+ struct parking_global_config *global;
+ struct ao2_container *parking_lot_list;
+};
+
+static struct aco_type global_option = {
+ .type = ACO_GLOBAL,
+ .name = "globals",
+ .item_offset = offsetof(struct parking_config, global),
+ .category_match = ACO_WHITELIST,
+ .category = "^general$",
+};
+
+struct aco_type *global_options[] = ACO_TYPES(&global_option);
+
+static struct aco_type parking_lot_type = {
+ .type = ACO_ITEM,
+ .name = "parking_lot",
+ .category_match = ACO_BLACKLIST,
+ .category = "^(general)$",
+ .item_alloc = parking_lot_cfg_alloc,
+ .item_find = named_item_find,
+ .item_offset = offsetof(struct parking_config, parking_lot_list),
+};
+
+struct aco_type *parking_lot_types[] = ACO_TYPES(&parking_lot_type);
+
+struct aco_file parking_lot_conf = {
+ .filename = "res_parking.conf",
+ .types = ACO_TYPES(&global_option, &parking_lot_type),
+};
+
+static AO2_GLOBAL_OBJ_STATIC(globals);
+
+CONFIG_INFO_STANDARD(cfg_info, globals, parking_config_alloc,
+ .files = ACO_FILES(&parking_lot_conf),
+);
+
+static int parking_lot_cfg_hash_fn(const void *obj, const int flags)
+{
+ const struct parking_lot_cfg *entry;
+ const char *key;
+
+ switch (flags & (OBJ_POINTER | OBJ_KEY)) {
+ case OBJ_KEY:
+ key = obj;
+ return ast_str_hash(key);
+ case OBJ_POINTER:
+ entry = obj;
+ return ast_str_hash(entry->name);
+ default:
+ return 0;
+ }
+}
+
+static int parking_lot_cfg_cmp_fn(void *obj, void *arg, const int flags)
+{
+ struct parking_lot_cfg *entry1 = obj;
char *key;
size_t key_size;
- struct parking_lot_state *entry2;
+ struct parking_lot_cfg *entry2;
switch (flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY)) {
case OBJ_KEY:
@@ -234,97 +306,6 @@
}
}
-/*! All parking lots that are currently alive in some fashion can be obtained from here */
-static struct ao2_container *parking_lot_state_container;
-
-static void *parking_config_alloc(void);
-
-static void *parking_lot_cfg_alloc(const char *cat);
-static void *named_item_find(struct ao2_container *container, const char *name); /* XXX This is really just a generic string find. Move to astobj2.c? */
-
-struct parking_global_config {
- int parkeddynamic; /* XXX This feature still needs to be implemented. Entirely. */
-};
-
-struct parking_config {
- struct parking_global_config *global;
- struct ao2_container *parking_lot_list;
-};
-
-static struct aco_type global_option = {
- .type = ACO_GLOBAL,
- .name = "globals",
- .item_offset = offsetof(struct parking_config, global),
- .category_match = ACO_WHITELIST,
- .category = "^general$",
-};
-
-struct aco_type *global_options[] = ACO_TYPES(&global_option);
-
-static struct aco_type parking_lot_type = {
- .type = ACO_ITEM,
- .name = "parking_lot",
- .category_match = ACO_BLACKLIST,
- .category = "^(general)$",
- .item_alloc = parking_lot_cfg_alloc,
- .item_find = named_item_find,
- .item_offset = offsetof(struct parking_config, parking_lot_list),
-};
-
-struct aco_type *parking_lot_types[] = ACO_TYPES(&parking_lot_type);
-
-struct aco_file parking_lot_conf = {
- .filename = "res_parking.conf",
- .types = ACO_TYPES(&global_option, &parking_lot_type),
-};
-
-static AO2_GLOBAL_OBJ_STATIC(globals);
-
-CONFIG_INFO_STANDARD(cfg_info, globals, parking_config_alloc,
- .files = ACO_FILES(&parking_lot_conf),
-);
-
-static int parking_lot_cfg_hash_fn(const void *obj, const int flags)
-{
- const struct parking_lot_cfg *entry;
- const char *key;
-
- switch (flags & (OBJ_POINTER | OBJ_KEY)) {
- case OBJ_KEY:
- key = obj;
- return ast_str_hash(key);
- case OBJ_POINTER:
- entry = obj;
- return ast_str_hash(entry->name);
- default:
- return 0;
- }
-}
-
-static int parking_lot_cfg_cmp_fn(void *obj, void *arg, const int flags)
-{
- struct parking_lot_cfg *entry1 = obj;
-
- char *key;
- size_t key_size;
- struct parking_lot_cfg *entry2;
-
- switch (flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY)) {
- case OBJ_KEY:
- key = arg;
- return (!strcmp(entry1->name, key)) ? CMP_MATCH : 0;
- case OBJ_PARTIAL_KEY:
- key = arg;
- key_size = strlen(key);
- return (!strncmp(entry1->name, key, key_size)) ? CMP_MATCH : 0;
- case OBJ_POINTER:
- entry2 = arg;
- return (!strcmp(entry1->name, entry2->name)) ? CMP_MATCH : 0;
- default:
- return CMP_STOP;
- }
-}
-
/*! \brief destructor for parking_config */
static void parking_config_destructor(void *obj)
{
@@ -367,7 +348,7 @@
return;
}
- if (!ao2_container_count(lot->parked_user_list)) {
+ if (!ao2_container_count(lot->parked_users)) {
ao2_unlink(parking_lot_state_container, lot);
}
}
@@ -587,7 +568,7 @@
{
struct parking_lot_state *lot = obj;
ao2_cleanup(lot->parking_bridge);
- ao2_cleanup(lot->parked_user_list);
+ ao2_cleanup(lot->parked_users);
ast_string_field_free_memory(lot);
}
@@ -610,12 +591,12 @@
}
/* Create parked user ordered list */
- lot->parked_user_list = ao2_container_alloc_list(AO2_ALLOC_OPT_LOCK_RWLOCK,
+ lot->parked_users = ao2_container_alloc_list(AO2_ALLOC_OPT_LOCK_RWLOCK,
AO2_CONTAINER_ALLOC_OPT_DUPS_REJECT,
parked_user_sort_fn,
parked_user_cmp_fn);
- if (!lot->parked_user_list) {
+ if (!lot->parked_users) {
ao2_cleanup(lot);
return NULL;
}
@@ -764,7 +745,7 @@
/* Reject unloads if any parking lots currently have calls in them */
while ((lot = ao2_iterator_next(&i))) {
- if (ao2_container_count(lot->parked_user_list)) {
+ if (ao2_container_count(lot->parked_users)) {
ast_log(LOG_ERROR, "Can not unload parking module because parking lot '%s' has one or more parked callers in it.\n",
lot->name);
ao2_ref(lot, -1);
More information about the asterisk-commits
mailing list