[asterisk-commits] jpeeler: branch jpeeler/feature14882 r282133 - in /team/jpeeler/feature14882:...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Aug 12 18:10:18 CDT 2010
Author: jpeeler
Date: Thu Aug 12 18:10:16 2010
New Revision: 282133
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=282133
Log:
fix handling when no default parking lot is assigned globally, fix chan_sip to process parking configuration correctly, ref counting is closer to being correct now
Modified:
team/jpeeler/feature14882/channels/chan_sip.c
team/jpeeler/feature14882/include/asterisk/features.h
team/jpeeler/feature14882/main/features.c
Modified: team/jpeeler/feature14882/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/jpeeler/feature14882/channels/chan_sip.c?view=diff&rev=282133&r1=282132&r2=282133
==============================================================================
--- team/jpeeler/feature14882/channels/chan_sip.c (original)
+++ team/jpeeler/feature14882/channels/chan_sip.c Thu Aug 12 18:10:16 2010
@@ -4865,7 +4865,9 @@
ast_string_field_set(dialog, cid_name, peer->cid_name);
ast_string_field_set(dialog, cid_tag, peer->cid_tag);
ast_string_field_set(dialog, mwi_from, peer->mwi_from);
- ast_string_field_set(dialog, parkinglot, peer->parkinglot);
+ if (!ast_strlen_zero(peer->parkinglot)) {
+ ast_string_field_set(dialog, parkinglot, peer->parkinglot);
+ }
ast_string_field_set(dialog, engine, peer->engine);
ref_proxy(dialog, obproxy_get(dialog, peer));
dialog->callgroup = peer->callgroup;
@@ -14807,7 +14809,9 @@
ast_string_field_set(p, subscribecontext, peer->subscribecontext);
ast_string_field_set(p, mohinterpret, peer->mohinterpret);
ast_string_field_set(p, mohsuggest, peer->mohsuggest);
- ast_string_field_set(p, parkinglot, peer->parkinglot);
+ if (!ast_strlen_zero(peer->parkinglot)) {
+ ast_string_field_set(p, parkinglot, peer->parkinglot);
+ }
ast_string_field_set(p, engine, peer->engine);
p->disallowed_methods = peer->disallowed_methods;
set_pvt_allowed_methods(p, req);
@@ -26340,6 +26344,7 @@
ast_set_flag(&global_flags[0], SIP_DTMF_RFC2833); /*!< Default DTMF setting: RFC2833 */
ast_set_flag(&global_flags[0], SIP_DIRECT_MEDIA); /*!< Allow re-invites */
ast_copy_string(default_engine, DEFAULT_ENGINE, sizeof(default_engine));
+ ast_copy_string(default_parkinglot, DEFAULT_PARKINGLOT, sizeof(default_parkinglot));
/* Debugging settings, always default to off */
dumphistory = FALSE;
@@ -26843,6 +26848,8 @@
}
} else if (!strcasecmp(v->name, "snom_aoc_enabled")) {
ast_set2_flag(&global_flags[2], ast_true(v->value), SIP_PAGE3_SNOM_AOC);
+ } else if (!strcasecmp(v->name, "parkinglot")) {
+ ast_copy_string(default_parkinglot, v->value, sizeof(default_parkinglot));
}
}
Modified: team/jpeeler/feature14882/include/asterisk/features.h
URL: http://svnview.digium.com/svn/asterisk/team/jpeeler/feature14882/include/asterisk/features.h?view=diff&rev=282133&r1=282132&r2=282133
==============================================================================
--- team/jpeeler/feature14882/include/asterisk/features.h (original)
+++ team/jpeeler/feature14882/include/asterisk/features.h Thu Aug 12 18:10:16 2010
@@ -35,6 +35,7 @@
#define FEATURE_MOH_LEN 80 /* same as MAX_MUSICCLASS from channel.h */
#define PARK_APP_NAME "Park"
+#define DEFAULT_PARKINGLOT "default" /*!< Default parking lot */
#define AST_FEATURE_RETURN_HANGUP -1
#define AST_FEATURE_RETURN_SUCCESSBREAK 0
Modified: team/jpeeler/feature14882/main/features.c
URL: http://svnview.digium.com/svn/asterisk/team/jpeeler/feature14882/main/features.c?view=diff&rev=282133&r1=282132&r2=282133
==============================================================================
--- team/jpeeler/feature14882/main/features.c (original)
+++ team/jpeeler/feature14882/main/features.c Thu Aug 12 18:10:16 2010
@@ -292,7 +292,6 @@
#define DEFAULT_TRANSFER_DIGIT_TIMEOUT 3000
#define DEFAULT_FEATURE_DIGIT_TIMEOUT 1000
#define DEFAULT_NOANSWER_TIMEOUT_ATTENDED_TRANSFER 15000
-#define DEFAULT_PARKINGLOT "default" /*!< Default parking lot */
#define DEFAULT_ATXFER_DROP_CALL 0
#define DEFAULT_ATXFER_LOOP_DELAY 10000
#define DEFAULT_ATXFER_CALLBACK_RETRIES 2
@@ -725,9 +724,6 @@
if (args->parkinglot) {
parkinglot = args->parkinglot;
- }
-
- if (parkinglot) {
parkinglotname = parkinglot->name;
} else if (peer) {
parkinglotname = findparkinglotname(peer);
@@ -735,10 +731,14 @@
parkinglotname = findparkinglotname(chan);
}
- if (!parkinglot && parkinglotname) {
- ast_debug(1, "Found chanvar Parkinglot: %s\n", parkinglotname);
- parkinglot = find_parkinglot(parkinglotname);
-
+ if (!args->parkinglot) {
+ if (parkinglotname) {
+ parkinglot = find_parkinglot(parkinglotname);
+ } else {
+ ast_log(LOG_WARNING, "This could be an indication channel driver needs updating, using default lot.\n");
+ parkinglot = parkinglot_addref(default_parkinglot);
+ }
+ ast_debug(1, "Found chanvar Parkinglot: %s\n", parkinglot->name);
}
/* Dynamically create parkinglot */
@@ -789,8 +789,7 @@
parkinglot = parkinglot_addref(default_parkinglot);
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Parkinglot: %s\n", parkinglot->name);
+ ast_debug(1, "Parkinglot: %s\n", parkinglot->name);
/* Allocate memory for parking data */
if (!(pu = ast_calloc(1, sizeof(*pu)))) {
@@ -872,9 +871,8 @@
pu->notquiteyet = 1;
pu->parkingnum = parking_space;
- pu->parkinglot = parkinglot_addref(parkinglot);
+ pu->parkinglot = parkinglot;
AST_LIST_INSERT_TAIL(&parkinglot->parkings, pu, list);
- parkinglot_unref(parkinglot);
return pu;
}
@@ -1032,7 +1030,7 @@
int ast_park_call(struct ast_channel *chan, struct ast_channel *peer, int timeout, const char *parkexten, int *extout)
{
/* JPEELER check reference handling */
- struct ast_parkinglot *found_lot = ao2_callback(parkinglots, 0, find_parkinglot_by_exten_cb, &parkexten);
+ struct ast_parkinglot *found_lot = ao2_callback(parkinglots, 0, find_parkinglot_by_exten_cb, (void *) parkexten);
struct ast_park_call_args args = {
.timeout = timeout,
@@ -1328,8 +1326,7 @@
if (data) {
args.parkinglot = (struct ast_parkinglot *) data;
- if (option_debug)
- ast_log(LOG_NOTICE, "Parkinglot specified for builtin_parkcall: %s\n", args.parkinglot->name);
+ ast_debug(1, "Parkinglot specified for builtin_parkcall: %s\n", args.parkinglot->name);
}
set_peers(&parker, &parkee, peer, chan, sense);
@@ -1868,7 +1865,6 @@
parkinglot = ao2_callback(parkinglots, 0, find_parkinglot_by_exten_cb, &xferto);
if (parkinglot) {
finishup(transferee);
- /* unrefed in park_space_reserve */
return builtin_parkcall(chan, peer, config, code, sense, parkinglot);
}
@@ -3798,6 +3794,7 @@
} else
ast_log(LOG_WARNING, "Whoa, no parking context for parking lot %s?\n", curlot->name);
AST_LIST_REMOVE_CURRENT(list);
+ parkinglot_unref(pu->parkinglot);
free(pu);
break;
} else {
@@ -3878,24 +3875,18 @@
/*! \brief Find parkinglot by name */
struct ast_parkinglot *find_parkinglot(const char *name)
{
-
- struct ao2_iterator iter;
struct ast_parkinglot *parkinglot;
- if (ast_strlen_zero(name))
+ if (ast_strlen_zero(name)) {
return NULL;
-
- iter = ao2_iterator_init(parkinglots,0);
-
- while ((parkinglot = ao2_iterator_next(&iter))) {
- if (!strncasecmp(parkinglot->name,name,sizeof(parkinglot->parking_con))){
- if (option_debug){
- ast_log(LOG_DEBUG, "Found Parkinglot: %s\n", parkinglot->name);
- }
- return parkinglot;
- }
- }
- return NULL;
+ }
+
+ parkinglot = ao2_find(parkinglots, (void *) name, 0);
+ if (parkinglot) {
+ ast_debug(1, "Found Parkinglot: %s\n", parkinglot->name);
+ }
+
+ return parkinglot;
}
/*! \brief Copy parkinglot and store it with new name */
@@ -4025,14 +4016,14 @@
struct ao2_iterator iter;
struct ast_parkinglot* parkinglot;
- if (data){
+ if (data) {
park = atoi((char *) data); /* char to int */
}
iter = ao2_iterator_init(parkinglots, 0); /* searching for the proper parkinglot */
while ((parkinglot = ao2_iterator_next(&iter))) {
ao2_ref(parkinglot, -1);
- if (park >= parkinglot->parking_start && park <= parkinglot->parking_stop){ /* found parkinglot */
+ if (park >= parkinglot->parking_start && park <= parkinglot->parking_stop) { /* found parkinglot */
break;
}
}
@@ -4173,6 +4164,7 @@
ast_set_flag(&(config.features_caller), AST_FEATURE_AUTOMON);
}
+ parkinglot_unref(parkinglot);
res = ast_bridge_call(chan, peer, &config);
pbx_builtin_setvar_helper(chan, "PARKEDCHANNEL", peer->name);
@@ -4202,15 +4194,13 @@
static void parkinglot_unref(struct ast_parkinglot *parkinglot)
{
int refcount = ao2_ref(parkinglot, -1);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Multiparking: %s refcount now %d\n", parkinglot->name, refcount - 1);
+ ast_debug(3, "Multiparking: %s refcount now %d\n", parkinglot->name, refcount - 1);
}
static struct ast_parkinglot *parkinglot_addref(struct ast_parkinglot *parkinglot)
{
int refcount = ao2_ref(parkinglot, +1);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Multiparking: %s refcount now %d\n", parkinglot->name, refcount + 1);
+ ast_debug(3, "Multiparking: %s refcount now %d\n", parkinglot->name, refcount + 1);
return parkinglot;
}
@@ -4262,7 +4252,7 @@
}
}
-/*! \brief Build parkinglot from configuration and chain it in */
+/*! \brief Build parkinglot from configuration and chain it in if it doesn't already exist */
static struct ast_parkinglot *build_parkinglot(char *name, struct ast_variable *var)
{
struct ast_parkinglot *parkinglot;
@@ -4348,9 +4338,9 @@
parkinglot->parkingtime = DEFAULT_PARK_TIME;
}
/* if there's no parkext specified - set to default */
- if (ast_strlen_zero(parkinglot->parkext)){
- ast_log(LOG_NOTICE,"no parkext specified for %s - setting it to %s\n",parkinglot->name, "700");
- ast_copy_string(parkinglot->parkext,"700",sizeof(parkinglot->parkext));
+ if (ast_strlen_zero(parkinglot->parkext)) {
+ ast_debug(2, "no parkext specified for %s - setting it to %s\n", parkinglot->name, "700");
+ ast_copy_string(parkinglot->parkext, "700", sizeof(parkinglot->parkext));
}
if (!var) { /* Default parking lot */
@@ -4390,9 +4380,7 @@
parkinglot_destroy(parkinglot);
return NULL;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Parking %s now open for business. (start exten %d end %d)\n", name, start, end);
-
+ ast_debug(1, "Parking %s now open for business. (start exten %d end %d)\n", name, start, end);
/* Move it into the list, if it wasn't already there */
if (!oldparkinglot) {
@@ -4447,8 +4435,7 @@
}
if (default_parkinglot) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Configuration of default parkinglot done.\n");
+ ast_debug(1, "Configuration of default parkinglot done.\n");
} else {
ast_log(LOG_ERROR, "Configuration of default parkinglot failed.\n");
return -1;
@@ -4843,14 +4830,10 @@
int ast_features_reload(void)
{
int res;
- /* Release parking lot list */
- //ASTOBJ_CONTAINER_MARKALL(&parkinglots);
- // TODO: I don't think any marking is necessary
/* Reload configuration */
res = load_config();
- //ASTOBJ_CONTAINER_PRUNE_MARKED(&parkinglots, parkinglot_destroy);
return res;
}
@@ -5063,7 +5046,7 @@
iter = ao2_iterator_init(parkinglots, 0);
while ((curlot = ao2_iterator_next(&iter))) {
int lotparked = 0;
- ast_cli(a->fd, "*** Parking lot: %s\n", curlot->name);
+ ast_cli(a->fd, "*** Parking lot: %s (%d)\n", curlot->name, ao2_ref(curlot, 0));
AST_LIST_LOCK(&curlot->parkings);
AST_LIST_TRAVERSE(&curlot->parkings, cur, list) {
More information about the asterisk-commits
mailing list