[asterisk-commits] tilghman: branch tilghman/odbc_tx_support r136291 - in /team/tilghman/odbc_tx...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Aug 6 17:19:56 CDT 2008
Author: tilghman
Date: Wed Aug 6 17:19:55 2008
New Revision: 136291
URL: http://svn.digium.com/view/asterisk?view=rev&rev=136291
Log:
Merged revisions 136034,136063,136112,136141,136191,136239,136245 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r136034 | tilghman | 2008-08-06 09:51:51 -0500 (Wed, 06 Aug 2008) | 3 lines
Use a dynamic buffer for rendered SQL, instead of hardcoding 2048 bytes. Also,
switch to using RWLISTs for the linked list of queries.
................
r136063 | mmichelson | 2008-08-06 10:59:29 -0500 (Wed, 06 Aug 2008) | 24 lines
Merged revisions 136062 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r136062 | mmichelson | 2008-08-06 10:58:40 -0500 (Wed, 06 Aug 2008) | 16 lines
Since adding the AST_CONTROL_SRCUPDATE frame type,
there are places where ast_rtp_new_source may be called
where the tech_pvt of a channel may not yet have an
rtp structure allocated. This caused a crash in chan_skinny,
which was fixed earlier, but now the same crash has been
reported against chan_h323 as well. It seems that the best
solution is to modify ast_rtp_new_source to not attempt to
set the marker bit if the rtp structure passed in is NULL.
This change to ast_rtp_new_source also allows the removal
of what is now a redundant pointer check from chan_skinny.
(closes issue #13247)
Reported by: pj
........
................
r136112 | tilghman | 2008-08-06 11:58:42 -0500 (Wed, 06 Aug 2008) | 7 lines
Persist DIALGROUP() values in astdb
(closes issue #13138)
Reported by: Corydon76
Patches:
20080725__bug13138.diff.txt uploaded by Corydon76 (license 14)
Tested by: pj
................
r136141 | tilghman | 2008-08-06 12:33:48 -0500 (Wed, 06 Aug 2008) | 6 lines
Janitor ast_str project
(closes issue #13058)
Reported by: pputman
Patches:
app_meetme_aststr2.patch uploaded by pputman (license 81)
................
r136191 | tilghman | 2008-08-06 15:15:34 -0500 (Wed, 06 Aug 2008) | 12 lines
Merged revisions 136190 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r136190 | tilghman | 2008-08-06 15:14:54 -0500 (Wed, 06 Aug 2008) | 4 lines
-C option takes a filename, not a directory path.
(closes issue #13007)
Reported by: klaus3000
........
................
r136239 | mmichelson | 2008-08-06 15:43:58 -0500 (Wed, 06 Aug 2008) | 11 lines
Blocked revisions 136238 via svnmerge
........
r136238 | mmichelson | 2008-08-06 15:42:15 -0500 (Wed, 06 Aug 2008) | 4 lines
We only need to unregister the QueueStatus manager
command once on an unload
........
................
r136245 | dhubbard | 2008-08-06 16:22:56 -0500 (Wed, 06 Aug 2008) | 1 line
move taskprocessor CLI commands into the core namespace
................
Modified:
team/tilghman/odbc_tx_support/ (props changed)
team/tilghman/odbc_tx_support/apps/app_meetme.c
team/tilghman/odbc_tx_support/channels/chan_skinny.c
team/tilghman/odbc_tx_support/contrib/init.d/rc.redhat.asterisk
team/tilghman/odbc_tx_support/funcs/func_dialgroup.c
team/tilghman/odbc_tx_support/funcs/func_odbc.c
team/tilghman/odbc_tx_support/main/rtp.c
team/tilghman/odbc_tx_support/main/taskprocessor.c
Propchange: team/tilghman/odbc_tx_support/
------------------------------------------------------------------------------
automerge = *
Propchange: team/tilghman/odbc_tx_support/
------------------------------------------------------------------------------
Binary property 'branch-1.4-blocked' - no diff available.
Propchange: team/tilghman/odbc_tx_support/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.
Propchange: team/tilghman/odbc_tx_support/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Aug 6 17:19:55 2008
@@ -1,1 +1,1 @@
-/trunk:1-136031
+/trunk:1-136290
Modified: team/tilghman/odbc_tx_support/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/odbc_tx_support/apps/app_meetme.c?view=diff&rev=136291&r1=136290&r2=136291
==============================================================================
--- team/tilghman/odbc_tx_support/apps/app_meetme.c (original)
+++ team/tilghman/odbc_tx_support/apps/app_meetme.c Wed Aug 6 17:19:55 2008
@@ -954,7 +954,7 @@
int hr, min, sec;
int i = 0, total = 0;
time_t now;
- char cmdline[1024] = "";
+ struct ast_str *cmdline = NULL;
#define MC_HEADER_FORMAT "%-14s %-14s %-10s %-8s %-8s %-6s\n"
#define MC_DATA_FORMAT "%-12.12s %4.4d %4.4s %02d:%02d:%02d %-8s %-6s\n"
@@ -976,106 +976,126 @@
if (strlen(a->argv[i]) > 100)
ast_cli(a->fd, "Invalid Arguments.\n");
}
+
+ /* Max confno length */
+ if (!(cmdline = ast_str_create(MAX_CONFNUM))) {
+ return CLI_FAILURE;
+ }
+
if (a->argc == 1 || (a->argc == 2 && !strcasecmp(a->argv[1], "concise"))) {
/* 'MeetMe': List all the conferences */
int concise = (a->argc == 2 && !strcasecmp(a->argv[1], "concise"));
now = time(NULL);
AST_LIST_LOCK(&confs);
if (AST_LIST_EMPTY(&confs)) {
- if (!concise)
+ if (!concise) {
ast_cli(a->fd, "No active MeetMe conferences.\n");
+ }
AST_LIST_UNLOCK(&confs);
+ ast_free(cmdline);
return CLI_SUCCESS;
}
- if (!concise)
+ if (!concise) {
ast_cli(a->fd, MC_HEADER_FORMAT, "Conf Num", "Parties", "Marked", "Activity", "Creation", "Locked");
+ }
AST_LIST_TRAVERSE(&confs, cnf, list) {
- if (cnf->markedusers == 0)
- strcpy(cmdline, "N/A ");
- else
- snprintf(cmdline, sizeof(cmdline), "%4.4d", cnf->markedusers);
+ if (cnf->markedusers == 0) {
+ ast_str_set(&cmdline, 0, "N/A ");
+ } else {
+ ast_str_set(&cmdline, 0, "%4.4d", cnf->markedusers);
+ }
hr = (now - cnf->start) / 3600;
min = ((now - cnf->start) % 3600) / 60;
sec = (now - cnf->start) % 60;
- if (!concise)
- ast_cli(a->fd, MC_DATA_FORMAT, cnf->confno, cnf->users, cmdline, hr, min, sec, cnf->isdynamic ? "Dynamic" : "Static", cnf->locked ? "Yes" : "No");
- else {
- ast_cli(a->fd, "%s!%d!%d!%02d:%02d:%02d!%d!%d\n",
- cnf->confno,
- cnf->users,
- cnf->markedusers,
+ if (!concise) {
+ ast_cli(a->fd, MC_DATA_FORMAT, cnf->confno, cnf->users, cmdline->str, hr, min, sec, cnf->isdynamic ? "Dynamic" : "Static", cnf->locked ? "Yes" : "No");
+ } else {
+ ast_cli(a->fd, "%s!%d!%d!%02d:%02d:%02d!%d!%d\n",
+ cnf->confno,
+ cnf->users,
+ cnf->markedusers,
hr, min, sec,
- cnf->isdynamic,
+ cnf->isdynamic,
cnf->locked);
}
- total += cnf->users;
+ total += cnf->users;
}
AST_LIST_UNLOCK(&confs);
- if (!concise)
+ if (!concise) {
ast_cli(a->fd, "* Total number of MeetMe users: %d\n", total);
+ }
+ ast_free(cmdline);
return CLI_SUCCESS;
}
- if (a->argc < 3)
+ if (a->argc < 3) {
+ ast_free(cmdline);
return CLI_SHOWUSAGE;
- ast_copy_string(cmdline, a->argv[2], sizeof(cmdline)); /* Argv 2: conference number */
- if (strstr(a->argv[1], "lock")) {
+ }
+
+ ast_str_set(&cmdline, 0, "%s", a->argv[2]); /* Argv 2: conference number */
+ if (strstr(a->argv[1], "lock")) {
if (strcmp(a->argv[1], "lock") == 0) {
/* Lock */
- strncat(cmdline, ",L", sizeof(cmdline) - strlen(cmdline) - 1);
+ ast_str_append(&cmdline, 0, ",L");
} else {
/* Unlock */
- strncat(cmdline, ",l", sizeof(cmdline) - strlen(cmdline) - 1);
+ ast_str_append(&cmdline, 0, ",l");
}
} else if (strstr(a->argv[1], "mute")) {
- if (a->argc < 4)
+ if (a->argc < 4) {
+ ast_free(cmdline);
return CLI_SHOWUSAGE;
+ }
if (strcmp(a->argv[1], "mute") == 0) {
/* Mute */
if (strcmp(a->argv[3], "all") == 0) {
- strncat(cmdline, ",N", sizeof(cmdline) - strlen(cmdline) - 1);
+ ast_str_append(&cmdline, 0, ",N");
} else {
- strncat(cmdline, ",M,", sizeof(cmdline) - strlen(cmdline) - 1);
- strncat(cmdline, a->argv[3], sizeof(cmdline) - strlen(cmdline) - 1);
+ ast_str_append(&cmdline, 0, ",M,%s", a->argv[3]);
}
} else {
/* Unmute */
if (strcmp(a->argv[3], "all") == 0) {
- strncat(cmdline, ",n", sizeof(cmdline) - strlen(cmdline) - 1);
+ ast_str_append(&cmdline, 0, ",n");
} else {
- strncat(cmdline, ",m,", sizeof(cmdline) - strlen(cmdline) - 1);
- strncat(cmdline, a->argv[3], sizeof(cmdline) - strlen(cmdline) - 1);
+ ast_str_append(&cmdline, 0, ",m,%s", a->argv[3]);
}
}
} else if (strcmp(a->argv[1], "kick") == 0) {
- if (a->argc < 4)
+ if (a->argc < 4) {
+ ast_free(cmdline);
return CLI_SHOWUSAGE;
+ }
if (strcmp(a->argv[3], "all") == 0) {
/* Kick all */
- strncat(cmdline, ",K", sizeof(cmdline) - strlen(cmdline) - 1);
+ ast_str_append(&cmdline, 0, ",K");
} else {
/* Kick a single user */
- strncat(cmdline, ",k,", sizeof(cmdline) - strlen(cmdline) - 1);
- strncat(cmdline, a->argv[3], sizeof(cmdline) - strlen(cmdline) - 1);
+ ast_str_append(&cmdline, 0, ",k,%s", a->argv[3]);
}
} else if (strcmp(a->argv[1], "list") == 0) {
int concise = (a->argc == 4 && (!strcasecmp(a->argv[3], "concise")));
/* List all the users in a conference */
if (AST_LIST_EMPTY(&confs)) {
- if (!concise)
+ if (!concise) {
ast_cli(a->fd, "No active conferences.\n");
+ }
+ ast_free(cmdline);
return CLI_SUCCESS;
}
/* Find the right conference */
AST_LIST_LOCK(&confs);
AST_LIST_TRAVERSE(&confs, cnf, list) {
- if (strcmp(cnf->confno, a->argv[2]) == 0)
+ if (strcmp(cnf->confno, a->argv[2]) == 0) {
break;
+ }
}
if (!cnf) {
if (!concise)
ast_cli(a->fd, "No such conference: %s.\n", a->argv[2]);
AST_LIST_UNLOCK(&confs);
+ ast_free(cmdline);
return CLI_SUCCESS;
}
/* Show all the users */
@@ -1084,7 +1104,7 @@
hr = (now - user->jointime) / 3600;
min = ((now - user->jointime) % 3600) / 60;
sec = (now - user->jointime) % 60;
- if (!concise)
+ if (!concise) {
ast_cli(a->fd, "User #: %-2.2d %12.12s %-20.20s Channel: %s %s %s %s %s %s %02d:%02d:%02d\n",
user->user_no,
S_OR(user->chan->cid.cid_num, "<unknown>"),
@@ -1095,7 +1115,7 @@
user->adminflags & ADMINFLAG_MUTED ? "(Admin Muted)" : user->adminflags & ADMINFLAG_SELFMUTED ? "(Muted)" : "",
user->adminflags & ADMINFLAG_T_REQUEST ? "(Request to Talk)" : "",
istalking(user->talking), hr, min, sec);
- else
+ } else {
ast_cli(a->fd, "%d!%s!%s!%s!%s!%s!%s!%s!%d!%02d:%02d:%02d\n",
user->user_no,
S_OR(user->chan->cid.cid_num, ""),
@@ -1106,18 +1126,23 @@
user->adminflags & (ADMINFLAG_MUTED | ADMINFLAG_SELFMUTED) ? "1" : "",
user->adminflags & ADMINFLAG_T_REQUEST ? "1" : "",
user->talking, hr, min, sec);
-
- }
- if (!concise)
+ }
+ }
+ if (!concise) {
ast_cli(a->fd, "%d users in that conference.\n", cnf->users);
+ }
AST_LIST_UNLOCK(&confs);
+ ast_free(cmdline);
return CLI_SUCCESS;
- } else
+ } else {
+ ast_free(cmdline);
return CLI_SHOWUSAGE;
-
- ast_debug(1, "Cmdline: %s\n", cmdline);
-
- admin_exec(NULL, cmdline);
+ }
+
+ ast_debug(1, "Cmdline: %s\n", cmdline->str);
+
+ admin_exec(NULL, cmdline->str);
+ ast_free(cmdline);
return CLI_SUCCESS;
}
@@ -3912,7 +3937,7 @@
{
struct sla_station *station;
struct sla_trunk_ref *trunk_ref;
- char conf_name[MAX_CONFNUM];
+ struct ast_str *conf_name = ast_str_create(16);
struct ast_flags conf_flags = { 0 };
struct ast_conference *conf;
@@ -3927,11 +3952,11 @@
}
ast_atomic_fetchadd_int((int *) &trunk_ref->trunk->active_stations, 1);
- snprintf(conf_name, sizeof(conf_name), "SLA_%s", trunk_ref->trunk->name);
+ ast_str_set(&conf_name, 0, "SLA_%s", trunk_ref->trunk->name);
ast_set_flag(&conf_flags,
CONFFLAG_QUIET | CONFFLAG_MARKEDEXIT | CONFFLAG_PASS_DTMF | CONFFLAG_SLA_STATION);
ast_answer(trunk_ref->chan);
- conf = build_conf(conf_name, "", "", 0, 0, 1, trunk_ref->chan);
+ conf = build_conf(conf_name->str, "", "", 0, 0, 1, trunk_ref->chan);
if (conf) {
conf_run(trunk_ref->chan, conf, conf_flags.flags, NULL);
dispose_conf(conf);
@@ -3940,8 +3965,8 @@
trunk_ref->chan = NULL;
if (ast_atomic_dec_and_test((int *) &trunk_ref->trunk->active_stations) &&
trunk_ref->state != SLA_TRUNK_STATE_ONHOLD_BYME) {
- strncat(conf_name, ",K", sizeof(conf_name) - strlen(conf_name) - 1);
- admin_exec(NULL, conf_name);
+ ast_str_append(&conf_name, 0, ",K");
+ admin_exec(NULL, conf_name->str);
trunk_ref->trunk->hold_stations = 0;
sla_change_trunk_state(trunk_ref->trunk, SLA_TRUNK_STATE_IDLE, ALL_TRUNK_REFS, NULL);
}
@@ -3949,6 +3974,7 @@
ast_dial_join(station->dial);
ast_dial_destroy(station->dial);
station->dial = NULL;
+ ast_free(conf_name);
return NULL;
}
Modified: team/tilghman/odbc_tx_support/channels/chan_skinny.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/odbc_tx_support/channels/chan_skinny.c?view=diff&rev=136291&r1=136290&r2=136291
==============================================================================
--- team/tilghman/odbc_tx_support/channels/chan_skinny.c (original)
+++ team/tilghman/odbc_tx_support/channels/chan_skinny.c Wed Aug 6 17:19:55 2008
@@ -3909,9 +3909,7 @@
case AST_CONTROL_PROCEEDING:
break;
case AST_CONTROL_SRCUPDATE:
- if (sub->rtp) {
- ast_rtp_new_source(sub->rtp);
- }
+ ast_rtp_new_source(sub->rtp);
break;
default:
ast_log(LOG_WARNING, "Don't know how to indicate condition %d\n", ind);
Modified: team/tilghman/odbc_tx_support/contrib/init.d/rc.redhat.asterisk
URL: http://svn.digium.com/view/asterisk/team/tilghman/odbc_tx_support/contrib/init.d/rc.redhat.asterisk?view=diff&rev=136291&r1=136290&r2=136291
==============================================================================
--- team/tilghman/odbc_tx_support/contrib/init.d/rc.redhat.asterisk (original)
+++ team/tilghman/odbc_tx_support/contrib/init.d/rc.redhat.asterisk Wed Aug 6 17:19:55 2008
@@ -88,7 +88,7 @@
ASTARGS="$ASTARGS -G $AST_GROUP"
fi
if [ $AST_CONFIG ]; then
- ASTARGS="$ASTARGS -C $AST_CONFIG"
+ ASTARGS="$ASTARGS -C $AST_CONFIG/asterisk.conf"
fi
daemon $DAEMON $ASTARGS
RETVAL=$?
Modified: team/tilghman/odbc_tx_support/funcs/func_dialgroup.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/odbc_tx_support/funcs/func_dialgroup.c?view=diff&rev=136291&r1=136290&r2=136291
==============================================================================
--- team/tilghman/odbc_tx_support/funcs/func_dialgroup.c (original)
+++ team/tilghman/odbc_tx_support/funcs/func_dialgroup.c Wed Aug 6 17:19:55 2008
@@ -37,6 +37,7 @@
#include "asterisk/utils.h"
#include "asterisk/app.h"
#include "asterisk/astobj2.h"
+#include "asterisk/astdb.h"
static struct ao2_container *group_container = NULL;
@@ -94,13 +95,18 @@
struct group_entry *entry;
size_t bufused = 0;
int trunc_warning = 0;
+ int res = 0;
if (!grhead) {
- ast_log(LOG_WARNING, "No such dialgroup '%s'\n", data);
+ if (!ast_strlen_zero(cmd)) {
+ ast_log(LOG_WARNING, "No such dialgroup '%s'\n", data);
+ }
return -1;
}
- i = ao2_iterator_init(grhead->entries, 0);
+ buf[0] = '\0';
+
+ i = ao2_iterator_init(grhead->entries, OBJ_POINTER);
while ((entry = ao2_iterator_next(&i))) {
int tmp = strlen(entry->name);
/* Ensure that we copy only complete names, not partials */
@@ -109,10 +115,43 @@
buf[bufused++] = '&';
ast_copy_string(buf + bufused, entry->name, len - bufused);
bufused += tmp;
- } else if (trunc_warning++ == 0)
- ast_log(LOG_WARNING, "Dialgroup '%s' is too large. Truncating list.\n", data);
- }
-
+ } else if (trunc_warning++ == 0) {
+ if (!ast_strlen_zero(cmd)) {
+ ast_log(LOG_WARNING, "Dialgroup '%s' is too large. Truncating list.\n", data);
+ } else {
+ res = 1;
+ ao2_ref(entry, -1);
+ break;
+ }
+ }
+ ao2_ref(entry, -1);
+ }
+
+ return res;
+}
+
+static int dialgroup_refreshdb(struct ast_channel *chan, const char *cdialgroup)
+{
+ int len = 500, res = 0;
+ char *buf = NULL;
+ char *dialgroup = ast_strdupa(cdialgroup);
+
+ do {
+ len *= 2;
+ buf = ast_realloc(buf, len);
+
+ if ((res = dialgroup_read(chan, "", dialgroup, buf, len)) < 0) {
+ ast_free(buf);
+ return -1;
+ }
+ } while (res == 1);
+
+ if (ast_strlen_zero(buf)) {
+ ast_db_del("dialgroup", cdialgroup);
+ } else {
+ ast_db_put("dialgroup", cdialgroup, buf);
+ }
+ ast_free(buf);
return 0;
}
@@ -120,7 +159,7 @@
{
struct group *grhead;
struct group_entry *entry;
- int j;
+ int j, needrefresh = 1;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(group);
AST_APP_ARG(op);
@@ -133,7 +172,7 @@
AST_STANDARD_APP_ARGS(args, data);
AST_NONSTANDARD_APP_ARGS(inter, value, '&');
- if (!(grhead = ao2_find(group_container, data, 0))) {
+ if (!(grhead = ao2_find(group_container, args.group, 0))) {
/* Create group */
grhead = ao2_alloc(sizeof(*grhead), group_destroy);
if (!grhead)
@@ -153,8 +192,11 @@
/* Remove all existing */
ao2_ref(grhead->entries, -1);
- if (!(grhead->entries = ao2_container_alloc(37, entry_hash_fn, entry_cmp_fn)))
- return -1;
+ if (!(grhead->entries = ao2_container_alloc(37, entry_hash_fn, entry_cmp_fn))) {
+ ao2_unlink(group_container, grhead);
+ ao2_ref(grhead, -1);
+ return -1;
+ }
}
if (strcasecmp(args.op, "add") == 0) {
@@ -162,18 +204,28 @@
if ((entry = ao2_alloc(sizeof(*entry), NULL))) {
ast_copy_string(entry->name, inter.faces[j], sizeof(entry->name));
ao2_link(grhead->entries, entry);
- } else
+ ao2_ref(entry, -1);
+ } else {
ast_log(LOG_WARNING, "Unable to add '%s' to dialgroup '%s'\n", inter.faces[j], grhead->name);
+ }
}
} else if (strncasecmp(args.op, "del", 3) == 0) {
for (j = 0; j < inter.argc; j++) {
- if ((entry = ao2_find(grhead->entries, inter.faces[j], OBJ_UNLINK)))
+ if ((entry = ao2_find(grhead->entries, inter.faces[j], OBJ_UNLINK))) {
ao2_ref(entry, -1);
- else
+ } else {
ast_log(LOG_WARNING, "Interface '%s' not found in dialgroup '%s'\n", inter.faces[j], grhead->name);
- }
- } else
+ }
+ }
+ } else {
ast_log(LOG_ERROR, "Unrecognized operation: %s\n", args.op);
+ needrefresh = 0;
+ }
+ ao2_ref(grhead, -1);
+
+ if (needrefresh) {
+ dialgroup_refreshdb(chan, args.group);
+ }
return 0;
}
@@ -211,10 +263,25 @@
static int load_module(void)
{
- if ((group_container = ao2_container_alloc(37, group_hash_fn, group_cmp_fn)))
+ struct ast_db_entry *dbtree, *tmp;
+ char groupname[AST_MAX_EXTENSION], *ptr;
+
+ if ((group_container = ao2_container_alloc(37, group_hash_fn, group_cmp_fn))) {
+ /* Refresh groups from astdb */
+ if ((dbtree = ast_db_gettree("dialgroup", NULL))) {
+ for (tmp = dbtree; tmp; tmp = tmp->next) {
+ ast_copy_string(groupname, tmp->key, sizeof(groupname));
+ if ((ptr = strrchr(groupname, '/'))) {
+ ptr++;
+ dialgroup_write(NULL, "", ptr, tmp->data);
+ }
+ }
+ ast_db_freetree(dbtree);
+ }
return ast_custom_function_register(&dialgroup_function);
- else
+ } else {
return AST_MODULE_LOAD_DECLINE;
+ }
}
AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Dialgroup dialplan function");
Modified: team/tilghman/odbc_tx_support/funcs/func_odbc.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/odbc_tx_support/funcs/func_odbc.c?view=diff&rev=136291&r1=136290&r2=136291
==============================================================================
--- team/tilghman/odbc_tx_support/funcs/func_odbc.c (original)
+++ team/tilghman/odbc_tx_support/funcs/func_odbc.c Wed Aug 6 17:19:55 2008
@@ -53,7 +53,7 @@
} odbc_option_flags;
struct acf_odbc_query {
- AST_LIST_ENTRY(acf_odbc_query) list;
+ AST_RWLIST_ENTRY(acf_odbc_query) list;
char readhandle[5][30];
char writehandle[5][30];
char sql_read[2048];
@@ -82,7 +82,7 @@
char names[0];
};
-AST_LIST_HEAD_STATIC(queries, acf_odbc_query);
+AST_RWLIST_HEAD_STATIC(queries, acf_odbc_query);
static int resultcount = 0;
@@ -129,7 +129,7 @@
{
struct odbc_obj *obj = NULL;
struct acf_odbc_query *query;
- char *t, buf[2048], varname[15];
+ char *t, varname[15];
int i, dsn, bogus_chan = 0;
int transactional = 0;
AST_DECLARE_APP_ARGS(values,
@@ -140,9 +140,14 @@
);
SQLHSTMT stmt = NULL;
SQLLEN rows=0;
-
- AST_LIST_LOCK(&queries);
- AST_LIST_TRAVERSE(&queries, query, list) {
+ struct ast_str *buf = ast_str_create(16);
+
+ if (!buf) {
+ return -1;
+ }
+
+ AST_RWLIST_RDLOCK(&queries);
+ AST_RWLIST_TRAVERSE(&queries, query, list) {
if (!strcmp(query->acf->name, cmd)) {
break;
}
@@ -150,7 +155,8 @@
if (!query) {
ast_log(LOG_ERROR, "No such function '%s'\n", cmd);
- AST_LIST_UNLOCK(&queries);
+ AST_RWLIST_UNLOCK(&queries);
+ ast_free(buf);
return -1;
}
@@ -162,16 +168,19 @@
if (chan)
ast_autoservice_start(chan);
+ ast_str_make_space(&buf, strlen(query->sql_write) * 2);
+
/* Parse our arguments */
t = value ? ast_strdupa(value) : "";
if (!s || !t) {
ast_log(LOG_ERROR, "Out of memory\n");
- AST_LIST_UNLOCK(&queries);
+ AST_RWLIST_UNLOCK(&queries);
if (chan)
ast_autoservice_stop(chan);
if (bogus_chan)
ast_channel_free(chan);
+ ast_free(buf);
return -1;
}
@@ -191,7 +200,7 @@
/* Additionally set the value as a whole (but push an empty string if value is NULL) */
pbx_builtin_pushvar_helper(chan, "VALUE", value ? value : "");
- pbx_substitute_variables_helper(chan, query->sql_write, buf, sizeof(buf) - 1);
+ pbx_substitute_variables_helper(chan, query->sql_write, buf->str, buf->len - 1);
/* Restore prior values */
for (i = 0; i < args.argc; i++) {
@@ -234,7 +243,7 @@
}
}
- AST_LIST_UNLOCK(&queries);
+ AST_RWLIST_UNLOCK(&queries);
if (stmt) {
/* Rows affected */
@@ -259,6 +268,7 @@
ast_autoservice_stop(chan);
if (bogus_chan)
ast_channel_free(chan);
+ ast_free(buf);
return 0;
}
@@ -267,7 +277,7 @@
{
struct odbc_obj *obj = NULL;
struct acf_odbc_query *query;
- char sql[2048], varname[15], colnames[2048] = "", rowcount[12] = "-1";
+ char varname[15], colnames[2048] = "", rowcount[12] = "-1";
int res, x, y, buflen = 0, escapecommas, rowlimit = 1, dsn, bogus_chan = 0;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(field)[100];
@@ -278,9 +288,14 @@
SQLSMALLINT collength;
struct odbc_datastore *resultset = NULL;
struct odbc_datastore_row *row = NULL;
-
- AST_LIST_LOCK(&queries);
- AST_LIST_TRAVERSE(&queries, query, list) {
+ struct ast_str *sql = ast_str_create(16);
+
+ if (!sql) {
+ return -1;
+ }
+
+ AST_RWLIST_RDLOCK(&queries);
+ AST_RWLIST_TRAVERSE(&queries, query, list) {
if (!strcmp(query->acf->name, cmd)) {
break;
}
@@ -288,8 +303,9 @@
if (!query) {
ast_log(LOG_ERROR, "No such function '%s'\n", cmd);
- AST_LIST_UNLOCK(&queries);
+ AST_RWLIST_UNLOCK(&queries);
pbx_builtin_setvar_helper(chan, "ODBCROWS", rowcount);
+ ast_free(sql);
return -1;
}
@@ -307,7 +323,8 @@
pbx_builtin_pushvar_helper(chan, varname, args.field[x]);
}
- pbx_substitute_variables_helper(chan, query->sql_read, sql, sizeof(sql) - 1);
+ ast_str_make_space(&sql, strlen(query->sql_read) * 2);
+ pbx_substitute_variables_helper(chan, query->sql_read, sql->str, sql->len - 1);
/* Restore prior values */
for (x = 0; x < args.argc; x++) {
@@ -325,20 +342,20 @@
else
rowlimit = INT_MAX;
}
- AST_LIST_UNLOCK(&queries);
+ AST_RWLIST_UNLOCK(&queries);
for (dsn = 0; dsn < 5; dsn++) {
if (!ast_strlen_zero(query->readhandle[dsn])) {
obj = ast_odbc_request_obj(query->readhandle[dsn], 0);
if (obj)
- stmt = ast_odbc_direct_execute(obj, generic_execute, sql);
+ stmt = ast_odbc_direct_execute(obj, generic_execute, sql->str);
}
if (stmt)
break;
}
if (!stmt) {
- ast_log(LOG_ERROR, "Unable to execute query [%s]\n", sql);
+ ast_log(LOG_ERROR, "Unable to execute query [%s]\n", sql->str);
if (obj)
ast_odbc_release_obj(obj);
pbx_builtin_setvar_helper(chan, "ODBCROWS", rowcount);
@@ -346,12 +363,13 @@
ast_autoservice_stop(chan);
if (bogus_chan)
ast_channel_free(chan);
+ ast_free(sql);
return -1;
}
res = SQLNumResultCols(stmt, &colcount);
if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
- ast_log(LOG_WARNING, "SQL Column Count error!\n[%s]\n\n", sql);
+ ast_log(LOG_WARNING, "SQL Column Count error!\n[%s]\n\n", sql->str);
SQLCloseCursor(stmt);
SQLFreeHandle (SQL_HANDLE_STMT, stmt);
ast_odbc_release_obj(obj);
@@ -360,6 +378,7 @@
ast_autoservice_stop(chan);
if (bogus_chan)
ast_channel_free(chan);
+ ast_free(sql);
return -1;
}
@@ -367,11 +386,11 @@
if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
int res1 = -1;
if (res == SQL_NO_DATA) {
- ast_verb(4, "Found no rows [%s]\n", sql);
+ ast_verb(4, "Found no rows [%s]\n", sql->str);
res1 = 0;
ast_copy_string(rowcount, "0", sizeof(rowcount));
} else {
- ast_log(LOG_WARNING, "Error %d in FETCH [%s]\n", res, sql);
+ ast_log(LOG_WARNING, "Error %d in FETCH [%s]\n", res, sql->str);
}
SQLCloseCursor(stmt);
SQLFreeHandle(SQL_HANDLE_STMT, stmt);
@@ -381,6 +400,7 @@
ast_autoservice_stop(chan);
if (bogus_chan)
ast_channel_free(chan);
+ ast_free(sql);
return res1;
}
@@ -432,6 +452,7 @@
ast_autoservice_stop(chan);
if (bogus_chan)
ast_channel_free(chan);
+ ast_free(sql);
return -1;
}
resultset = tmp;
@@ -447,7 +468,7 @@
}
if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
- ast_log(LOG_WARNING, "SQL Get Data error!\n[%s]\n\n", sql);
+ ast_log(LOG_WARNING, "SQL Get Data error!\n[%s]\n\n", sql->str);
y = -1;
goto end_acf_read;
}
@@ -485,7 +506,7 @@
res = SQLFetch(stmt);
if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
if (res != SQL_NO_DATA)
- ast_log(LOG_WARNING, "Error %d in FETCH [%s]\n", res, sql);
+ ast_log(LOG_WARNING, "Error %d in FETCH [%s]\n", res, sql->str);
y++;
break;
}
@@ -512,6 +533,7 @@
ast_autoservice_stop(chan);
if (bogus_chan)
ast_channel_free(chan);
+ ast_free(sql);
return -1;
}
odbc_store->data = resultset;
@@ -524,6 +546,7 @@
ast_autoservice_stop(chan);
if (bogus_chan)
ast_channel_free(chan);
+ ast_free(sql);
return 0;
}
@@ -807,12 +830,12 @@
res |= ast_custom_function_register(&fetch_function);
res |= ast_register_application(app_odbcfinish, exec_odbcfinish, syn_odbcfinish, desc_odbcfinish);
- AST_LIST_LOCK(&queries);
+ AST_RWLIST_WRLOCK(&queries);
cfg = ast_config_load(config, config_flags);
if (!cfg) {
ast_log(LOG_NOTICE, "Unable to load config for func_odbc: %s\n", config);
- AST_LIST_UNLOCK(&queries);
+ AST_RWLIST_UNLOCK(&queries);
return AST_MODULE_LOAD_DECLINE;
}
@@ -830,7 +853,7 @@
else
ast_log(LOG_ERROR, "%s (%d)\n", strerror(err), err);
} else {
- AST_LIST_INSERT_HEAD(&queries, query, list);
+ AST_RWLIST_INSERT_HEAD(&queries, query, list);
ast_custom_function_register(query->acf);
}
}
@@ -838,7 +861,7 @@
ast_config_destroy(cfg);
res |= ast_custom_function_register(&escape_function);
- AST_LIST_UNLOCK(&queries);
+ AST_RWLIST_UNLOCK(&queries);
return res;
}
@@ -847,9 +870,9 @@
struct acf_odbc_query *query;
int res = 0;
- AST_LIST_LOCK(&queries);
- while (!AST_LIST_EMPTY(&queries)) {
- query = AST_LIST_REMOVE_HEAD(&queries, list);
+ AST_RWLIST_WRLOCK(&queries);
+ while (!AST_RWLIST_EMPTY(&queries)) {
+ query = AST_RWLIST_REMOVE_HEAD(&queries, list);
ast_custom_function_unregister(query->acf);
free_acf_query(query);
}
@@ -859,11 +882,11 @@
res |= ast_unregister_application(app_odbcfinish);
/* Allow any threads waiting for this lock to pass (avoids a race) */
- AST_LIST_UNLOCK(&queries);
+ AST_RWLIST_UNLOCK(&queries);
usleep(1);
- AST_LIST_LOCK(&queries);
-
- AST_LIST_UNLOCK(&queries);
+ AST_RWLIST_WRLOCK(&queries);
+
+ AST_RWLIST_UNLOCK(&queries);
return 0;
}
@@ -879,10 +902,10 @@
if (cfg == CONFIG_STATUS_FILEUNCHANGED)
return 0;
- AST_LIST_LOCK(&queries);
-
- while (!AST_LIST_EMPTY(&queries)) {
- oldquery = AST_LIST_REMOVE_HEAD(&queries, list);
+ AST_RWLIST_WRLOCK(&queries);
+
+ while (!AST_RWLIST_EMPTY(&queries)) {
+ oldquery = AST_RWLIST_REMOVE_HEAD(&queries, list);
ast_custom_function_unregister(oldquery->acf);
free_acf_query(oldquery);
}
@@ -900,14 +923,14 @@
if (init_acf_query(cfg, catg, &query)) {
ast_log(LOG_ERROR, "Cannot initialize query %s\n", catg);
} else {
- AST_LIST_INSERT_HEAD(&queries, query, list);
+ AST_RWLIST_INSERT_HEAD(&queries, query, list);
ast_custom_function_register(query->acf);
}
}
ast_config_destroy(cfg);
reload_out:
- AST_LIST_UNLOCK(&queries);
+ AST_RWLIST_UNLOCK(&queries);
return res;
}
Modified: team/tilghman/odbc_tx_support/main/rtp.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/odbc_tx_support/main/rtp.c?view=diff&rev=136291&r1=136290&r2=136291
==============================================================================
--- team/tilghman/odbc_tx_support/main/rtp.c (original)
+++ team/tilghman/odbc_tx_support/main/rtp.c Wed Aug 6 17:19:55 2008
@@ -2537,7 +2537,9 @@
void ast_rtp_new_source(struct ast_rtp *rtp)
{
- rtp->set_marker_bit = 1;
+ if (rtp) {
+ rtp->set_marker_bit = 1;
+ }
return;
}
Modified: team/tilghman/odbc_tx_support/main/taskprocessor.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/odbc_tx_support/main/taskprocessor.c?view=diff&rev=136291&r1=136290&r2=136291
==============================================================================
--- team/tilghman/odbc_tx_support/main/taskprocessor.c (original)
+++ team/tilghman/odbc_tx_support/main/taskprocessor.c Wed Aug 6 17:19:55 2008
@@ -160,7 +160,7 @@
char *name = NULL;
struct ao2_iterator i;
- if (a->pos != 2)
+ if (a->pos != 3)
return NULL;
tklen = strlen(a->word);
@@ -196,19 +196,19 @@
switch (cmd) {
case CLI_INIT:
- e->command = "taskprocessor ping";
+ e->command = "core taskprocessor ping";
e->usage =
- "Usage: taskprocessor ping <taskprocessor>\n"
- " Displays the time required for a processor to deliver a task\n";
+ "Usage: core taskprocessor ping <taskprocessor>\n"
+ " Displays the time required for a task to be processed\n";
return NULL;
case CLI_GENERATE:
return tps_taskprocessor_tab_complete(tps, a);
}
- if (a->argc != 3)
+ if (a->argc != 4)
return CLI_SHOWUSAGE;
- name = a->argv[2];
+ name = a->argv[3];
if (!(tps = ast_taskprocessor_get(name, TPS_REF_IF_EXISTS))) {
ast_cli(a->fd, "\nping failed: %s not found\n\n", name);
return CLI_SUCCESS;
@@ -232,7 +232,6 @@
return CLI_SUCCESS;
}
-/* TPS reports are cool */
static char *cli_tps_report(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
char name[256];
@@ -245,9 +244,9 @@
switch (cmd) {
case CLI_INIT:
- e->command = "taskprocessor show stats";
+ e->command = "core show taskprocessors";
e->usage =
- "Usage: taskprocessor show stats\n"
+ "Usage: core show taskprocessors\n"
" Shows a list of instantiated task processors and their statistics\n";
return NULL;
case CLI_GENERATE:
More information about the asterisk-commits
mailing list