[asterisk-commits] russell: branch russell/chan_refcount r114263 - in /team/russell/chan_refcoun...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Apr 18 13:19:16 CDT 2008
Author: russell
Date: Fri Apr 18 13:19:16 2008
New Revision: 114263
URL: http://svn.digium.com/view/asterisk?view=rev&rev=114263
Log:
resolve, reset
Added:
team/russell/chan_refcount/doc/chan_sip-perf-testing.txt
- copied unchanged from r114261, trunk/doc/chan_sip-perf-testing.txt
team/russell/chan_refcount/include/asterisk/dlinkedlists.h
- copied unchanged from r114261, trunk/include/asterisk/dlinkedlists.h
team/russell/chan_refcount/tests/test_dlinklists.c
- copied unchanged from r114261, trunk/tests/test_dlinklists.c
team/russell/chan_refcount/utils/refcounter.c
- copied unchanged from r114261, trunk/utils/refcounter.c
Modified:
team/russell/chan_refcount/ (props changed)
team/russell/chan_refcount/CHANGES
team/russell/chan_refcount/Makefile
team/russell/chan_refcount/apps/app_chanspy.c
team/russell/chan_refcount/apps/app_dial.c
team/russell/chan_refcount/apps/app_directory.c
team/russell/chan_refcount/apps/app_externalivr.c
team/russell/chan_refcount/apps/app_festival.c
team/russell/chan_refcount/apps/app_ices.c
team/russell/chan_refcount/apps/app_meetme.c
team/russell/chan_refcount/apps/app_mp3.c
team/russell/chan_refcount/apps/app_nbscat.c
team/russell/chan_refcount/apps/app_queue.c
team/russell/chan_refcount/apps/app_setcallerid.c
team/russell/chan_refcount/apps/app_voicemail.c
team/russell/chan_refcount/apps/app_zapras.c
team/russell/chan_refcount/cdr/cdr_pgsql.c
team/russell/chan_refcount/channels/chan_h323.c
team/russell/chan_refcount/channels/chan_iax2.c
team/russell/chan_refcount/channels/chan_local.c
team/russell/chan_refcount/channels/chan_sip.c
team/russell/chan_refcount/channels/chan_skinny.c
team/russell/chan_refcount/channels/chan_unistim.c
team/russell/chan_refcount/channels/chan_zap.c
team/russell/chan_refcount/configs/res_ldap.conf.sample
team/russell/chan_refcount/configs/sip.conf.sample
team/russell/chan_refcount/contrib/scripts/astcli
team/russell/chan_refcount/contrib/scripts/autosupport
team/russell/chan_refcount/doc/CODING-GUIDELINES
team/russell/chan_refcount/include/asterisk/app.h
team/russell/chan_refcount/include/asterisk/astobj2.h
team/russell/chan_refcount/include/asterisk/dsp.h
team/russell/chan_refcount/include/asterisk/frame.h
team/russell/chan_refcount/include/asterisk/lock.h
team/russell/chan_refcount/include/asterisk/logger.h
team/russell/chan_refcount/include/asterisk/sched.h
team/russell/chan_refcount/main/app.c
team/russell/chan_refcount/main/asterisk.c
team/russell/chan_refcount/main/astobj2.c
team/russell/chan_refcount/main/autoservice.c
team/russell/chan_refcount/main/callerid.c
team/russell/chan_refcount/main/channel.c
team/russell/chan_refcount/main/dsp.c
team/russell/chan_refcount/main/event.c
team/russell/chan_refcount/main/features.c
team/russell/chan_refcount/main/file.c
team/russell/chan_refcount/main/frame.c
team/russell/chan_refcount/main/logger.c
team/russell/chan_refcount/main/manager.c
team/russell/chan_refcount/main/pbx.c
team/russell/chan_refcount/main/rtp.c
team/russell/chan_refcount/main/sched.c
team/russell/chan_refcount/main/utils.c
team/russell/chan_refcount/phoneprov/polycom_line.xml
team/russell/chan_refcount/res/res_agi.c
team/russell/chan_refcount/res/res_config_ldap.c
team/russell/chan_refcount/res/res_http_post.c
team/russell/chan_refcount/res/res_jabber.c
team/russell/chan_refcount/res/res_musiconhold.c
team/russell/chan_refcount/res/res_phoneprov.c
team/russell/chan_refcount/utils/Makefile
team/russell/chan_refcount/utils/ael_main.c
team/russell/chan_refcount/utils/astman.c
team/russell/chan_refcount/utils/check_expr.c
team/russell/chan_refcount/utils/conf2ael.c
team/russell/chan_refcount/utils/hashtest.c
team/russell/chan_refcount/utils/hashtest2.c
Propchange: team/russell/chan_refcount/
------------------------------------------------------------------------------
Binary property 'branch-1.4-blocked' - no diff available.
Propchange: team/russell/chan_refcount/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.
Propchange: team/russell/chan_refcount/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Apr 18 13:19:16 2008
@@ -1,1 +1,1 @@
-/trunk:1-104106,104108-114007
+/trunk:1-104106,104108-114262
Modified: team/russell/chan_refcount/CHANGES
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/CHANGES?view=diff&rev=114263&r1=114262&r2=114263
==============================================================================
--- team/russell/chan_refcount/CHANGES (original)
+++ team/russell/chan_refcount/CHANGES Fri Apr 18 13:19:16 2008
@@ -29,12 +29,24 @@
messages, if the "messagewrap" option is set to a true value.
* Dial has a new option: F(context^extension^pri), which permits a callee to
continue in the dialplan, at the specified label, if the caller hangs up.
+ * ChanSpy and ExtenSpy have a new option, 's' which suppresses speaking the
+ technology name (e.g. SIP, IAX, etc) of the channel being spied on.
SIP Changes
-----------
* The ATTENDED_TRANSFER_COMPLETE_SOUND can now be set using setvar to cause a given
audio file to be played upon completion of an attended transfer.
* Added DNS manager support to registrations for peers referencing peer entries.
+ DNS manager runs in the background which allows DNS lookups to be run asynchronously
+ as well as periodically updating the IP address. These properties allow for
+ better performance as well as recovery in the event of an IP change.
+ * Performance improvements via using hash tables (astobj2) and doubly-linked lists to improve
+ load/reload of large numbers of peers/users by ~40x (for large lists of peers.
+ Initially, we saw 4x improvement in call setup/destruction, but at the time
+ of merging, this gain has disappeared; further research will be done to try
+ and restore this performance improvement. Astobj2 refcounting is now used
+ for users, peers, and dialogs. Users are encouraged to assist in regression
+ testing and problem reporting!
IAX Changes
-----------
@@ -257,6 +269,9 @@
SIP call to Voicemail by putting a Local channel in the middle. This
feature is enabled by using the 'j' option in the Dial string to the Local
channel in conjunction with the existing 'n' option for local channels.
+ * A 'b' option has been added which causes chan_local to return the actual channel
+ that is behind it when queried. This is useful for transfer scenarios as the
+ actual channel will be transferred, not the Local channel.
Zaptel channel driver (chan_zap) Changes
----------------------------------------
@@ -411,6 +426,8 @@
for the "meetme" command.
* Added the ability to specify the music on hold class used to play into the
conference when there is only one member and the M option is used.
+ * Added MEETME_INFO dialplan function which provides a way to query
+ various properties of a Meetme conference.
Other Dialplan Application Changes
----------------------------------
@@ -612,6 +629,18 @@
* A new option when starting a remote asterisk (rasterisk, asterisk -r) for
specifying which socket to use to connect to the running Asterisk daemon
(-s)
+ * Performance enhancements to the sched facility, which is used in
+ the channel drivers, etc. Added hashtabs and doubly-linked lists
+ to speed up deletion; start at the beginning or end of list to
+ speed up insertion.
+ * Added Doubly-linked lists after the fashion of linkedlists.h. They are in
+ dlinkedlists.h. Doubly-linked lists feature fast deletion times.
+ Added regression tests to the tests/ dir, also.
+ * Added a refcount trace feature to astobj2 for those trying to balance
+ object creation, deletion; work, play; space and time. See the
+ notes in astobj2.h. Also, see utils/refcounter as well, as a
+ quick way to find unbalanced refcounts in what could be a sea
+ of objects that were balanced.
* Added logging to 'make update' command. See update.log
* Added strictrtp option to rtp.conf. If enabled this will drop RTP packets that
do not come from the remote party.
Modified: team/russell/chan_refcount/Makefile
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/Makefile?view=diff&rev=114263&r1=114262&r2=114263
==============================================================================
--- team/russell/chan_refcount/Makefile (original)
+++ team/russell/chan_refcount/Makefile Fri Apr 18 13:19:16 2008
@@ -498,7 +498,7 @@
NEWHEADERS=$(notdir $(wildcard include/asterisk/*.h))
OLDHEADERS=$(filter-out $(NEWHEADERS),$(notdir $(wildcard $(DESTDIR)$(ASTHEADERDIR)/*.h)))
-bininstall: _all
+bininstall: _all $(SUBDIRS_INSTALL)
mkdir -p $(DESTDIR)$(MODULES_DIR)
mkdir -p $(DESTDIR)$(ASTSBINDIR)
mkdir -p $(DESTDIR)$(ASTETCDIR)
Modified: team/russell/chan_refcount/apps/app_chanspy.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/apps/app_chanspy.c?view=diff&rev=114263&r1=114262&r2=114263
==============================================================================
--- team/russell/chan_refcount/apps/app_chanspy.c (original)
+++ team/russell/chan_refcount/apps/app_chanspy.c Fri Apr 18 13:19:16 2008
@@ -77,6 +77,8 @@
" r[(basename)] - Record the session to the monitor spool directory. An\n"
" optional base for the filename may be specified. The\n"
" default is 'chanspy'.\n"
+" s - Skip the playback of the channel type (i.e. SIP, IAX, etc) when\n"
+" speaking the selected channel name.\n"
" v([value]) - Adjust the initial volume in the range from -4 to 4. A\n"
" negative value refers to a quieter setting.\n"
" w - Enable 'whisper' mode, so the spying channel can talk to\n"
@@ -117,6 +119,8 @@
" r[(basename)] - Record the session to the monitor spool directory. An\n"
" optional base for the filename may be specified. The\n"
" default is 'chanspy'.\n"
+" s - Skip the playback of the channel type (i.e. SIP, IAX, etc) when\n"
+" speaking the selected channel name.\n"
" v([value]) - Adjust the initial volume in the range from -4 to 4. A\n"
" negative value refers to a quieter setting.\n"
" w - Enable 'whisper' mode, so the spying channel can talk to\n"
@@ -143,6 +147,7 @@
OPTION_READONLY = (1 << 7), /* Don't mix the two channels */
OPTION_EXIT = (1 << 8), /* Exit to a valid single digit extension */
OPTION_ENFORCED = (1 << 9), /* Enforced mode */
+ OPTION_NOTECH = (1 << 10), /* Skip technology name playback */
} chanspy_opt_flags;
enum {
@@ -164,6 +169,7 @@
AST_APP_OPTION_ARG('e', OPTION_ENFORCED, OPT_ARG_ENFORCED),
AST_APP_OPTION('o', OPTION_READONLY),
AST_APP_OPTION('X', OPTION_EXIT),
+ AST_APP_OPTION('s', OPTION_NOTECH),
});
@@ -559,16 +565,20 @@
*s = tolower(*s);
if (!ast_test_flag(flags, OPTION_QUIET)) {
- if (ast_fileexists(peer_name, NULL, NULL) != -1) {
- res = ast_streamfile(chan, peer_name, chan->language);
- if (!res)
- res = ast_waitstream(chan, "");
- if (res) {
- chanspy_ds_free(peer_chanspy_ds);
- break;
+ if (!ast_test_flag(flags, OPTION_NOTECH)) {
+ if (ast_fileexists(peer_name, NULL, NULL) != -1) {
+ res = ast_streamfile(chan, peer_name, chan->language);
+ if (!res) {
+ res = ast_waitstream(chan, "");
+ }
+ if (res) {
+ chanspy_ds_free(peer_chanspy_ds);
+ break;
+ }
+ } else {
+ res = ast_say_character_str(chan, peer_name, "", chan->language);
}
- } else
- res = ast_say_character_str(chan, peer_name, "", chan->language);
+ }
if ((num = atoi(ptr)))
ast_say_digits(chan, atoi(ptr), "", chan->language);
}
@@ -660,7 +670,7 @@
}
if (recbase) {
- char filename[512];
+ char filename[PATH_MAX];
snprintf(filename, sizeof(filename), "%s/%s.%d.raw", ast_config_AST_MONITOR_DIR, recbase, (int) time(NULL));
if ((fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC, AST_FILE_MODE)) <= 0) {
@@ -739,7 +749,7 @@
}
if (recbase) {
- char filename[512];
+ char filename[PATH_MAX];
snprintf(filename, sizeof(filename), "%s/%s.%d.raw", ast_config_AST_MONITOR_DIR, recbase, (int) time(NULL));
if ((fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC, AST_FILE_MODE)) <= 0) {
Modified: team/russell/chan_refcount/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/apps/app_dial.c?view=diff&rev=114263&r1=114262&r2=114263
==============================================================================
--- team/russell/chan_refcount/apps/app_dial.c (original)
+++ team/russell/chan_refcount/apps/app_dial.c Fri Apr 18 13:19:16 2008
@@ -1600,8 +1600,14 @@
time(&start_time);
peer = wait_for_answer(chan, outgoing, &to, peerflags, &pa, &num, &result);
- ast_channel_datastore_remove(chan, datastore);
- ast_channel_datastore_free(datastore);
+ /* The ast_channel_datastore_remove() function could fail here if the
+ * datastore was moved to another channel during a masquerade. If this is
+ * the case, don't free the datastore here because later, when the channel
+ * to which the datastore was moved hangs up, it will attempt to free this
+ * datastore again, causing a crash
+ */
+ if (!ast_channel_datastore_remove(chan, datastore))
+ ast_channel_datastore_free(datastore);
if (!peer) {
if (result) {
res = result;
Modified: team/russell/chan_refcount/apps/app_directory.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/apps/app_directory.c?view=diff&rev=114263&r1=114262&r2=114263
==============================================================================
--- team/russell/chan_refcount/apps/app_directory.c (original)
+++ team/russell/chan_refcount/apps/app_directory.c Fri Apr 18 13:19:16 2008
@@ -858,14 +858,23 @@
if (!ast_strlen_zero(dirintro) && !res) {
res = ast_stream_and_wait(chan, dirintro, AST_DIGIT_ANY);
} else if (!res) {
- res = ast_stream_and_wait(chan, "dir-welcome", AST_DIGIT_ANY) ||
- ast_stream_and_wait(chan, "dir-pls-enter", AST_DIGIT_ANY) ||
- ast_stream_and_wait(chan, digits, AST_DIGIT_ANY) ||
- ast_stream_and_wait(chan,
+ /* Stop playing sounds as soon as we have a digit. */
+ res = ast_stream_and_wait(chan, "dir-welcome", AST_DIGIT_ANY);
+ if (!res) {
+ res = ast_stream_and_wait(chan, "dir-pls-enter", AST_DIGIT_ANY);
+ }
+ if (!res) {
+ res = ast_stream_and_wait(chan, digits, AST_DIGIT_ANY);
+ }
+ if (!res) {
+ res = ast_stream_and_wait(chan,
which == FIRST ? "dir-first" :
which == LAST ? "dir-last" :
- "dir-firstlast", AST_DIGIT_ANY) ||
+ "dir-firstlast", AST_DIGIT_ANY);
+ }
+ if (!res) {
ast_stream_and_wait(chan, "dir-usingkeypad", AST_DIGIT_ANY);
+ }
}
ast_stopstream(chan);
if (!res)
Modified: team/russell/chan_refcount/apps/app_externalivr.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/apps/app_externalivr.c?view=diff&rev=114263&r1=114262&r2=114263
==============================================================================
--- team/russell/chan_refcount/apps/app_externalivr.c (original)
+++ team/russell/chan_refcount/apps/app_externalivr.c Fri Apr 18 13:19:16 2008
@@ -319,13 +319,9 @@
.finishlist = AST_LIST_HEAD_INIT_VALUE,
};
struct ivr_localuser *u = &foo;
- sigset_t fullset, oldset;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(cmd)[32];
);
-
- sigfillset(&fullset);
- pthread_sigmask(SIG_BLOCK, &fullset, &oldset);
u->abort_current_sound = 0;
u->chan = chan;
@@ -405,7 +401,7 @@
gen_active = 1;
}
- pid = fork();
+ pid = ast_safe_fork(0);
if (pid < 0) {
ast_log(LOG_WARNING, "Failed to fork(): %s\n", strerror(errno));
goto exit;
@@ -413,19 +409,13 @@
if (!pid) {
/* child process */
- int i;
-
- signal(SIGPIPE, SIG_DFL);
- pthread_sigmask(SIG_UNBLOCK, &fullset, NULL);
-
if (ast_opt_high_priority)
ast_set_priority(0);
dup2(child_stdin[0], STDIN_FILENO);
dup2(child_stdout[1], STDOUT_FILENO);
dup2(child_stderr[1], STDERR_FILENO);
- for (i = STDERR_FILENO + 1; i < 1024; i++)
- close(i);
+ ast_close_fds_above_n(STDERR_FILENO);
execv(args.cmd[0], args.cmd);
fprintf(stderr, "Failed to execute '%s': %s\n", args.cmd[0], strerror(errno));
_exit(1);
Modified: team/russell/chan_refcount/apps/app_festival.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/apps/app_festival.c?view=diff&rev=114263&r1=114262&r2=114263
==============================================================================
--- team/russell/chan_refcount/apps/app_festival.c (original)
+++ team/russell/chan_refcount/apps/app_festival.c Fri Apr 18 13:19:16 2008
@@ -117,30 +117,20 @@
static int send_waveform_to_fd(char *waveform, int length, int fd)
{
int res;
- int x;
#ifdef __PPC__
char c;
#endif
- sigset_t fullset, oldset;
-
- sigfillset(&fullset);
- pthread_sigmask(SIG_BLOCK, &fullset, &oldset);
-
- res = fork();
+
+ res = ast_safe_fork(0);
if (res < 0)
ast_log(LOG_WARNING, "Fork failed\n");
if (res) {
- pthread_sigmask(SIG_SETMASK, &oldset, NULL);
return res;
}
- for (x = 0; x < 256; x++) {
- if (x != fd)
- close(x);
- }
+ dup2(fd, 0);
+ ast_close_fds_above_n(0);
if (ast_opt_high_priority)
ast_set_priority(0);
- signal(SIGPIPE, SIG_DFL);
- pthread_sigmask(SIG_UNBLOCK, &fullset, NULL);
#ifdef __PPC__
for (x = 0; x < length; x += 2) {
c = *(waveform + x + 1);
Modified: team/russell/chan_refcount/apps/app_ices.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/apps/app_ices.c?view=diff&rev=114263&r1=114262&r2=114263
==============================================================================
--- team/russell/chan_refcount/apps/app_ices.c (original)
+++ team/russell/chan_refcount/apps/app_ices.c Fri Apr 18 13:19:16 2008
@@ -43,6 +43,7 @@
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/translate.h"
+#include "asterisk/app.h"
#define ICES "/usr/bin/ices"
#define LOCAL_ICES "/usr/local/bin/ices"
@@ -60,31 +61,18 @@
static int icesencode(char *filename, int fd)
{
int res;
- int x;
- sigset_t fullset, oldset;
- sigfillset(&fullset);
- pthread_sigmask(SIG_BLOCK, &fullset, &oldset);
-
- res = fork();
+ res = ast_safe_fork(0);
if (res < 0)
ast_log(LOG_WARNING, "Fork failed\n");
if (res) {
- pthread_sigmask(SIG_SETMASK, &oldset, NULL);
return res;
}
-
- /* Stop ignoring PIPE */
- signal(SIGPIPE, SIG_DFL);
- pthread_sigmask(SIG_UNBLOCK, &fullset, NULL);
if (ast_opt_high_priority)
ast_set_priority(0);
dup2(fd, STDIN_FILENO);
- for (x=STDERR_FILENO + 1;x<1024;x++) {
- if ((x != STDIN_FILENO) && (x != STDOUT_FILENO))
- close(x);
- }
+ ast_close_fds_above_n(STDERR_FILENO);
/* Most commonly installed in /usr/local/bin */
execl(ICES, "ices", filename, (char *)NULL);
/* But many places has it in /usr/bin */
@@ -183,7 +171,7 @@
}
}
close(fds[1]);
-
+
if (pid > -1)
kill(pid, SIGKILL);
if (!res && oreadformat)
Modified: team/russell/chan_refcount/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/apps/app_meetme.c?view=diff&rev=114263&r1=114262&r2=114263
==============================================================================
--- team/russell/chan_refcount/apps/app_meetme.c (original)
+++ team/russell/chan_refcount/apps/app_meetme.c Fri Apr 18 13:19:16 2008
@@ -1694,8 +1694,17 @@
ast_mutex_unlock(&conf->playlock);
if (!(confflags & CONFFLAG_QUIET) && ((confflags & CONFFLAG_INTROUSER) || (confflags & CONFFLAG_INTROUSERNOREVIEW))) {
+ char destdir[PATH_MAX];
+
+ snprintf(destdir, sizeof(destdir), "%s/meetme", ast_config_AST_SPOOL_DIR);
+
+ if (ast_mkdir(destdir, 0777) != 0) {
+ ast_log(LOG_WARNING, "mkdir '%s' failed: %s\n", destdir, strerror(errno));
+ goto outrun;
+ }
+
snprintf(user->namerecloc, sizeof(user->namerecloc),
- "%s/meetme/meetme-username-%s-%d", ast_config_AST_SPOOL_DIR,
+ "%s/meetme-username-%s-%d", destdir,
conf->confno, user->user_no);
if (confflags & CONFFLAG_INTROUSERNOREVIEW)
res = ast_play_and_record(chan, "vm-rec-name", user->namerecloc, 10, "sln", &duration, ast_dsp_get_threshold_from_settings(THRESHOLD_SILENCE), 0, NULL);
@@ -5516,6 +5525,88 @@
return res;
}
+static int acf_meetme_info_eval(char *keyword, struct ast_conference *conf)
+{
+ if (!strcasecmp("lock", keyword)) {
+ return conf->locked;
+ } else if (!strcasecmp("parties", keyword)) {
+ return conf->users;
+ } else if (!strcasecmp("activity", keyword)) {
+ time_t now;
+ now = time(NULL);
+ return (now - conf->start);
+ } else if (!strcasecmp("dynamic", keyword)) {
+ return conf->isdynamic;
+ } else {
+ return -1;
+ }
+
+}
+
+static int acf_meetme_info(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
+{
+ struct ast_conference *conf;
+ char *parse;
+ int result = -2; /* only non-negative numbers valid, -1 is used elsewhere */
+ AST_DECLARE_APP_ARGS(args,
+ AST_APP_ARG(keyword);
+ AST_APP_ARG(confno);
+ );
+
+ if (ast_strlen_zero(data)) {
+ ast_log(LOG_ERROR, "Syntax: MEETME_INFO() requires two arguments\n");
+ return -1;
+ }
+
+ parse = ast_strdupa(data);
+ AST_STANDARD_APP_ARGS(args, parse);
+
+ if (ast_strlen_zero(args.keyword)) {
+ ast_log(LOG_ERROR, "Syntax: MEETME_INFO() requires a keyword\n");
+ return -1;
+ }
+
+ if (ast_strlen_zero(args.confno)) {
+ ast_log(LOG_ERROR, "Syntax: MEETME_INFO() requires a conference number\n");
+ return -1;
+ }
+
+ AST_LIST_LOCK(&confs);
+ AST_LIST_TRAVERSE(&confs, conf, list) {
+ if (!strcmp(args.confno, conf->confno)) {
+ result = acf_meetme_info_eval(args.keyword, conf);
+ break;
+ }
+ }
+ AST_LIST_UNLOCK(&confs);
+
+ if (result > -1) {
+ snprintf(buf, len, "%d", result);
+ } else if (result == -1) {
+ snprintf(buf, len, "%s %s", "Error: invalid keyword:", args.keyword);
+ } else if (result == -2) {
+ snprintf(buf, len, "Error: conference (%s) not found", args.confno);
+ }
+
+ return 0;
+}
+
+
+static struct ast_custom_function meetme_info_acf = {
+ .name = "MEETME_INFO",
+ .synopsis = "Query a given conference of various properties.",
+ .syntax = "MEETME_INFO(<keyword>,<confno>)",
+ .read = acf_meetme_info,
+ .desc =
+"Returns information from a given keyword. (For booleans 1-true, 0-false)\n"
+" Options:\n"
+" lock - boolean of whether the corresponding conference is locked\n"
+" parties - number of parties in a given conference\n"
+" activity - duration of conference in seconds\n"
+" dynamic - boolean of whether the corresponding coference is dynamic\n",
+};
+
+
static int load_config(int reload)
{
load_config_meetme();
@@ -5549,6 +5640,8 @@
ast_devstate_prov_del("SLA");
sla_destroy();
+
+ res |= ast_custom_function_unregister(&meetme_info_acf);
return res;
}
@@ -5578,6 +5671,8 @@
res |= ast_devstate_prov_add("Meetme", meetmestate);
res |= ast_devstate_prov_add("SLA", sla_state);
+ res |= ast_custom_function_register(&meetme_info_acf);
+
return res;
}
Modified: team/russell/chan_refcount/apps/app_mp3.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/apps/app_mp3.c?view=diff&rev=114263&r1=114262&r2=114263
==============================================================================
--- team/russell/chan_refcount/apps/app_mp3.c (original)
+++ team/russell/chan_refcount/apps/app_mp3.c Fri Apr 18 13:19:16 2008
@@ -39,6 +39,7 @@
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/translate.h"
+#include "asterisk/app.h"
#define LOCAL_MPG_123 "/usr/local/bin/mpg123"
#define MPG_123 "/usr/bin/mpg123"
@@ -56,29 +57,19 @@
static int mp3play(char *filename, int fd)
{
int res;
- int x;
- sigset_t fullset, oldset;
-
- sigfillset(&fullset);
- pthread_sigmask(SIG_BLOCK, &fullset, &oldset);
-
- res = fork();
+
+ res = ast_safe_fork(0);
if (res < 0)
ast_log(LOG_WARNING, "Fork failed\n");
if (res) {
- pthread_sigmask(SIG_SETMASK, &oldset, NULL);
return res;
}
if (ast_opt_high_priority)
ast_set_priority(0);
- signal(SIGPIPE, SIG_DFL);
- pthread_sigmask(SIG_UNBLOCK, &fullset, NULL);
dup2(fd, STDOUT_FILENO);
- for (x=STDERR_FILENO + 1;x<256;x++) {
- if (x != STDOUT_FILENO)
- close(x);
- }
+ ast_close_fds_above_n(STDERR_FILENO);
+
/* Execute mpg123, but buffer if it's a net connection */
if (!strncasecmp(filename, "http://", 7)) {
/* Most commonly installed in /usr/local/bin */
@@ -96,7 +87,8 @@
/* As a last-ditch effort, try to use PATH */
execlp("mpg123", "mpg123", "-q", "-s", "-f", "8192", "--mono", "-r", "8000", filename, (char *)NULL);
}
- ast_log(LOG_WARNING, "Execute of mpg123 failed\n");
+ /* Can't use ast_log since FD's are closed */
+ fprintf(stderr, "Execute of mpg123 failed\n");
_exit(0);
}
Modified: team/russell/chan_refcount/apps/app_nbscat.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/apps/app_nbscat.c?view=diff&rev=114263&r1=114262&r2=114263
==============================================================================
--- team/russell/chan_refcount/apps/app_nbscat.c (original)
+++ team/russell/chan_refcount/apps/app_nbscat.c Fri Apr 18 13:19:16 2008
@@ -41,6 +41,7 @@
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/translate.h"
+#include "asterisk/app.h"
#define LOCAL_NBSCAT "/usr/local/bin/nbscat8k"
#define NBSCAT "/usr/bin/nbscat8k"
@@ -61,34 +62,25 @@
static int NBScatplay(int fd)
{
int res;
- int x;
- sigset_t fullset, oldset;
-
- sigfillset(&fullset);
- pthread_sigmask(SIG_BLOCK, &fullset, &oldset);
-
- res = fork();
- if (res < 0)
+
+ res = ast_safe_fork(0);
+ if (res < 0) {
ast_log(LOG_WARNING, "Fork failed\n");
+ }
+
if (res) {
- pthread_sigmask(SIG_SETMASK, &oldset, NULL);
return res;
}
- signal(SIGPIPE, SIG_DFL);
- pthread_sigmask(SIG_UNBLOCK, &fullset, NULL);
if (ast_opt_high_priority)
ast_set_priority(0);
dup2(fd, STDOUT_FILENO);
- for (x = STDERR_FILENO + 1; x < 1024; x++) {
- if (x != STDOUT_FILENO)
- close(x);
- }
+ ast_close_fds_above_n(STDERR_FILENO);
/* Most commonly installed in /usr/local/bin */
execl(NBSCAT, "nbscat8k", "-d", (char *)NULL);
execl(LOCAL_NBSCAT, "nbscat8k", "-d", (char *)NULL);
- ast_log(LOG_WARNING, "Execute of nbscat8k failed\n");
+ fprintf(stderr, "Execute of nbscat8k failed\n");
_exit(0);
}
Modified: team/russell/chan_refcount/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/apps/app_queue.c?view=diff&rev=114263&r1=114262&r2=114263
==============================================================================
--- team/russell/chan_refcount/apps/app_queue.c (original)
+++ team/russell/chan_refcount/apps/app_queue.c Fri Apr 18 13:19:16 2008
@@ -939,7 +939,6 @@
q->monfmt[0] = '\0';
q->reportholdtime = 0;
q->wrapuptime = 0;
- q->autofill = 0;
q->joinempty = 0;
q->leavewhenempty = 0;
q->memberdelay = 0;
@@ -1532,7 +1531,11 @@
*tmp++ = '-';
} else
tmp_name = v->name;
- queue_set_param(q, tmp_name, v->value, -1, 0);
+
+ if (!ast_strlen_zero(v->value)) {
+ /* Don't want to try to set the option if the value is empty */
+ queue_set_param(q, tmp_name, v->value, -1, 0);
+ }
}
/* Temporarily set realtime members dead so we can detect deleted ones.
@@ -3252,8 +3255,13 @@
if (use_weight)
ao2_unlock(queues);
lpeer = wait_for_answer(qe, outgoing, &to, &digit, numbusies, ast_test_flag(&(bridge_config.features_caller), AST_FEATURE_DISCONNECT), forwardsallowed);
- if (datastore) {
- ast_channel_datastore_remove(qe->chan, datastore);
+ /* The ast_channel_datastore_remove() function could fail here if the
+ * datastore was moved to another channel during a masquerade. If this is
+ * the case, don't free the datastore here because later, when the channel
+ * to which the datastore was moved hangs up, it will attempt to free this
+ * datastore again, causing a crash
+ */
+ if (datastore && !ast_channel_datastore_remove(qe->chan, datastore)) {
ast_channel_datastore_free(datastore);
}
ao2_lock(qe->parent);
Modified: team/russell/chan_refcount/apps/app_setcallerid.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/apps/app_setcallerid.c?view=diff&rev=114263&r1=114262&r2=114263
==============================================================================
--- team/russell/chan_refcount/apps/app_setcallerid.c (original)
+++ team/russell/chan_refcount/apps/app_setcallerid.c Fri Apr 18 13:19:16 2008
@@ -68,7 +68,11 @@
deprecated = 1;
ast_log(LOG_WARNING, "SetCallerPres is deprecated. Please use Set(CALLERPRES()=%s) instead.\n", (char *)data);
}
- pres = ast_parse_caller_presentation(data);
+
+ /* For interface consistency, permit the argument to be specified as a number */
+ if (sscanf(data, "%d", &pres) != 1 || pres < 0 || pres > 255 || (pres & 0x9c)) {
+ pres = ast_parse_caller_presentation(data);
+ }
if (pres < 0) {
ast_log(LOG_WARNING, "'%s' is not a valid presentation (see 'show application SetCallerPres')\n",
Modified: team/russell/chan_refcount/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/apps/app_voicemail.c?view=diff&rev=114263&r1=114262&r2=114263
==============================================================================
--- team/russell/chan_refcount/apps/app_voicemail.c (original)
+++ team/russell/chan_refcount/apps/app_voicemail.c Fri Apr 18 13:19:16 2008
@@ -6636,7 +6636,7 @@
res = say_and_wait(chan, dcnum, chan->language);
if (!res && lastnum) {
if (lastnum == 1)
- res = ast_play_and_wait(chan, "digits/ru/odno");
+ res = ast_play_and_wait(chan, "digits/odno");
else
res = say_and_wait(chan, lastnum, chan->language);
}
@@ -6655,7 +6655,7 @@
res = say_and_wait(chan, dcnum, chan->language);
if (!res && lastnum) {
if (lastnum == 1)
- res = ast_play_and_wait(chan, "digits/ru/odno");
+ res = ast_play_and_wait(chan, "digits/odno");
else
res = say_and_wait(chan, lastnum, chan->language);
}
Modified: team/russell/chan_refcount/apps/app_zapras.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/apps/app_zapras.c?view=diff&rev=114263&r1=114262&r2=114263
==============================================================================
--- team/russell/chan_refcount/apps/app_zapras.c (original)
+++ team/russell/chan_refcount/apps/app_zapras.c Fri Apr 18 13:19:16 2008
@@ -50,6 +50,7 @@
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
+#include "asterisk/app.h"
static char *app = "ZapRAS";
@@ -69,29 +70,17 @@
static pid_t spawn_ras(struct ast_channel *chan, char *args)
{
pid_t pid;
- int x;
char *c;
char *argv[PPP_MAX_ARGS];
int argc = 0;
char *stringp=NULL;
- sigset_t fullset, oldset;
-
- sigfillset(&fullset);
- pthread_sigmask(SIG_BLOCK, &fullset, &oldset);
/* Start by forking */
- pid = fork();
+ pid = ast_safe_fork(1);
if (pid) {
- pthread_sigmask(SIG_SETMASK, &oldset, NULL);
return pid;
}
-
- /* Restore original signal handlers */
- for (x=0;x<NSIG;x++)
- signal(x, SIG_DFL);
-
- pthread_sigmask(SIG_UNBLOCK, &fullset, NULL);
/* Execute RAS on File handles */
dup2(chan->fds[0], STDIN_FILENO);
@@ -101,8 +90,7 @@
ast_set_priority(0);
/* Close other file descriptors */
- for (x=STDERR_FILENO + 1;x<1024;x++)
- close(x);
+ ast_close_fds_above_n(STDERR_FILENO);
/* Reset all arguments */
memset(argv, 0, sizeof(argv));
@@ -185,6 +173,7 @@
break;
}
}
+ ast_safe_fork_cleanup();
}
static int zapras_exec(struct ast_channel *chan, void *data)
Modified: team/russell/chan_refcount/cdr/cdr_pgsql.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/cdr/cdr_pgsql.c?view=diff&rev=114263&r1=114262&r2=114263
==============================================================================
--- team/russell/chan_refcount/cdr/cdr_pgsql.c (original)
+++ team/russell/chan_refcount/cdr/cdr_pgsql.c Fri Apr 18 13:19:16 2008
@@ -66,6 +66,8 @@
char *name;
char *type;
int len;
+ unsigned int notnull:1;
+ unsigned int hasdefault:1;
AST_RWLIST_ENTRY(columns) list;
};
@@ -138,8 +140,17 @@
AST_RWLIST_TRAVERSE(&psql_columns, cur, list) {
/* For fields not set, simply skip them */
ast_cdr_getvar(cdr, cur->name, &value, buf, sizeof(buf), 0, 0);
- if (!value)
+ if (!value) {
+ if (cur->notnull && !cur->hasdefault) {
+ /* Field is NOT NULL (but no default), must include it anyway */
+ LENGTHEN_BUF1(strlen(cur->name));
+ lensql += snprintf(sql + lensql, sizesql - lensql, "%s,", cur->name);
+ LENGTHEN_BUF2(3);
+ strcat(sql2, "'',");
+ lensql2 += 3;
+ }
continue;
+ }
LENGTHEN_BUF1(strlen(cur->name));
lensql += snprintf(sql + lensql, sizesql - lensql, "%s,", cur->name);
@@ -444,14 +455,14 @@
conn = PQsetdbLogin(pghostname, pgdbport, NULL, NULL, pgdbname, pgdbuser, pgpassword);
if (PQstatus(conn) != CONNECTION_BAD) {
- char sqlcmd[256];
- char *fname, *ftype, *flen;
+ char sqlcmd[512];
+ char *fname, *ftype, *flen, *fnotnull, *fdef;
int i, rows;
ast_debug(1, "Successfully connected to PostgreSQL database.\n");
connected = 1;
/* Query the columns */
- snprintf(sqlcmd, sizeof(sqlcmd), "select a.attname, t.typname, a.attlen from pg_class c, pg_attribute a, pg_type t where c.oid = a.attrelid and a.atttypid = t.oid and (a.attnum > 0) and c.relname = '%s' order by c.relname, attnum", table);
+ snprintf(sqlcmd, sizeof(sqlcmd), "select a.attname, t.typname, a.attlen, a.attnotnull, d.adsrc from pg_class c, pg_type t, pg_attribute a left outer join pg_attrdef d on a.atthasdef and d.adrelid = a.attrelid and d.adnum = a.attnum where c.oid = a.attrelid and a.atttypid = t.oid and (a.attnum > 0) and c.relname = '%s' order by c.relname, attnum", table);
result = PQexec(conn, sqlcmd);
if (PQresultStatus(result) != PGRES_TUPLES_OK) {
pgerror = PQresultErrorMessage(result);
@@ -466,6 +477,8 @@
fname = PQgetvalue(result, i, 0);
ftype = PQgetvalue(result, i, 1);
flen = PQgetvalue(result, i, 2);
+ fnotnull = PQgetvalue(result, i, 3);
+ fdef = PQgetvalue(result, i, 4);
ast_verb(4, "Found column '%s' of type '%s'\n", fname, ftype);
cur = ast_calloc(1, sizeof(*cur) + strlen(fname) + strlen(ftype) + 2);
if (cur) {
@@ -474,6 +487,16 @@
cur->type = (char *)cur + sizeof(*cur) + strlen(fname) + 1;
strcpy(cur->name, fname);
strcpy(cur->type, ftype);
+ if (*fnotnull == 't') {
+ cur->notnull = 1;
+ } else {
+ cur->notnull = 0;
+ }
+ if (!ast_strlen_zero(fdef)) {
+ cur->hasdefault = 1;
+ } else {
+ cur->hasdefault = 0;
+ }
AST_RWLIST_INSERT_TAIL(&psql_columns, cur, list);
}
}
Modified: team/russell/chan_refcount/channels/chan_h323.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/channels/chan_h323.c?view=diff&rev=114263&r1=114262&r2=114263
==============================================================================
--- team/russell/chan_refcount/channels/chan_h323.c (original)
+++ team/russell/chan_refcount/channels/chan_h323.c Fri Apr 18 13:19:16 2008
@@ -1148,7 +1148,7 @@
while(pvt) {
if (!pvt->needdestroy && ((signed int)pvt->cd.call_reference == call_reference)) {
/* Found the call */
- if ((token != NULL) && (!strcmp(pvt->cd.call_token, token))) {
+ if ((token != NULL) && (pvt->cd.call_token != NULL) && (!strcmp(pvt->cd.call_token, token))) {
ast_mutex_lock(&pvt->lock);
ast_mutex_unlock(&iflock);
return pvt;
Modified: team/russell/chan_refcount/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/channels/chan_iax2.c?view=diff&rev=114263&r1=114262&r2=114263
==============================================================================
--- team/russell/chan_refcount/channels/chan_iax2.c (original)
+++ team/russell/chan_refcount/channels/chan_iax2.c Fri Apr 18 13:19:16 2008
@@ -1484,7 +1484,7 @@
*
* \note Calling this function while holding another pvt lock can cause a deadlock.
*/
-static int find_callno(unsigned short callno, unsigned short dcallno, struct sockaddr_in *sin, int new, int sockfd)
+static int __find_callno(unsigned short callno, unsigned short dcallno, struct sockaddr_in *sin, int new, int sockfd, int return_locked)
{
int res = 0;
int x;
@@ -1560,10 +1560,21 @@
ast_mutex_unlock(&iaxsl[x]);
return 0;
}
- ast_mutex_unlock(&iaxsl[x]);
+ if (!return_locked)
+ ast_mutex_unlock(&iaxsl[x]);
res = x;
}
return res;
+}
+
+static int find_callno(unsigned short callno, unsigned short dcallno, struct sockaddr_in *sin, int new, int sockfd) {
+
+ return __find_callno(callno, dcallno, sin, new, sockfd, 0);
+}
+
+static int find_callno_locked(unsigned short callno, unsigned short dcallno, struct sockaddr_in *sin, int new, int sockfd) {
+
+ return __find_callno(callno, dcallno, sin, new, sockfd, 1);
}
static void iax2_frame_free(struct iax_frame *fr)
@@ -3888,6 +3899,13 @@
ast_mutex_unlock(&iaxsl[callno]);
tmp = ast_channel_alloc(1, state, i->cid_num, i->cid_name, i->accountcode, i->exten, i->context, i->amaflags, "IAX2/%s-%d", i->host, i->callno);
ast_mutex_lock(&iaxsl[callno]);
+ if (!iaxs[callno]) {
+ if (tmp) {
+ ast_channel_free(tmp);
+ }
+ ast_mutex_unlock(&iaxsl[callno]);
+ return NULL;
+ }
iax2_ami_channelupdate(i);
if (!tmp)
return NULL;
@@ -7589,11 +7607,9 @@
/* Stop if we don't have enough data */
if (len > packet_len)
break;
- fr->callno = find_callno(callno & ~IAX_FLAG_FULL, 0, sin, NEW_PREVENT, sockfd);
+ fr->callno = find_callno_locked(callno & ~IAX_FLAG_FULL, 0, sin, NEW_PREVENT, sockfd);
if (!fr->callno)
continue;
-
- ast_mutex_lock(&iaxsl[fr->callno]);
/* If it's a valid call, deliver the contents. If not, we
drop it, since we don't have a scallno to use for an INVAL */
@@ -7973,7 +7989,9 @@
if (call_to_destroy) {
if (iaxdebug)
ast_debug(1, "Really destroying %d, having been acked on final message\n", call_to_destroy);
+ ast_mutex_lock(&iaxsl[call_to_destroy]);
iax2_destroy(call_to_destroy);
+ ast_mutex_unlock(&iaxsl[call_to_destroy]);
}
}
/* Note how much we've received acknowledgement for */
@@ -9389,13 +9407,14 @@
if (!reg->callno) {
ast_debug(1, "Allocate call number\n");
- reg->callno = find_callno(0, 0, ®->addr, NEW_FORCE, defaultsockfd);
+ reg->callno = find_callno_locked(0, 0, ®->addr, NEW_FORCE, defaultsockfd);
if (reg->callno < 1) {
ast_log(LOG_WARNING, "Unable to create call for registration\n");
return -1;
} else
ast_debug(1, "Registration created on call %d\n", reg->callno);
iaxs[reg->callno]->reg = reg;
+ ast_mutex_unlock(&iaxsl[reg->callno]);
}
/* Setup the next registration a little early */
reg->expire = iax2_sched_replace(reg->expire, sched,
@@ -9439,11 +9458,10 @@
memset(&ied, 0, sizeof(ied));
iax_ie_append_raw(&ied, IAX_IE_PROVISIONING, provdata.buf, provdata.pos);
- callno = find_callno(0, 0, &sin, NEW_FORCE, cai.sockfd);
+ callno = find_callno_locked(0, 0, &sin, NEW_FORCE, cai.sockfd);
if (!callno)
return -1;
- ast_mutex_lock(&iaxsl[callno]);
if (iaxs[callno]) {
/* Schedule autodestruct in case they don't ever give us anything back */
[... 8433 lines stripped ...]
More information about the asterisk-commits
mailing list