[asterisk-commits] branch bweschke/findme_followme r9205 -
/team/bweschke/findme_followme/
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Tue Feb 7 13:56:12 MST 2006
Author: bweschke
Date: Tue Feb 7 14:56:10 2006
New Revision: 9205
URL: http://svn.digium.com/view/asterisk?rev=9205&view=rev
Log:
More /trunk fixes
Modified:
team/bweschke/findme_followme/asterisk.c
Modified: team/bweschke/findme_followme/asterisk.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/findme_followme/asterisk.c?rev=9205&r1=9204&r2=9205&view=diff
==============================================================================
--- team/bweschke/findme_followme/asterisk.c (original)
+++ team/bweschke/findme_followme/asterisk.c Tue Feb 7 14:56:10 2006
@@ -18,7 +18,6 @@
/* Doxygenified Copyright Header */
-
/*!
* \mainpage Asterisk -- An Open Source Telephony Toolkit
*
@@ -101,6 +100,9 @@
#include "asterisk/pbx.h"
#include "asterisk/enum.h"
#include "asterisk/rtp.h"
+#if defined(T38_SUPPORT)
+#include "asterisk/udptl.h"
+#endif
#include "asterisk/app.h"
#include "asterisk/lock.h"
#include "asterisk/utils.h"
@@ -143,7 +145,7 @@
*/
/*! @{ */
-struct ast_flags ast_options = { AST_OPT_FLAG_TRANSCODE_VIA_SLIN | AST_OPT_FLAG_PRIORITY_JUMPING };
+struct ast_flags ast_options = { AST_OPT_FLAG_TRANSCODE_VIA_SLIN };
int option_verbose = 0; /*!< Verbosity level */
int option_debug = 0; /*!< Debug level */
@@ -165,12 +167,12 @@
pthread_t t; /*!< Thread of handler */
};
-static struct ast_atexit {
+struct ast_atexit {
void (*func)(void);
- struct ast_atexit *next;
-} *atexits = NULL;
-
-AST_MUTEX_DEFINE_STATIC(atexitslock);
+ AST_LIST_ENTRY(ast_atexit) list;
+};
+
+static AST_LIST_HEAD_STATIC(atexits, ast_atexit);
time_t ast_startuptime;
time_t ast_lastreloadtime;
@@ -212,6 +214,8 @@
static int restartnow = 0;
static pthread_t consolethread = AST_PTHREADT_NULL;
+static char randompool[256];
+
#if !defined(LOW_MEMORY)
struct file_version {
AST_LIST_ENTRY(file_version) list;
@@ -320,7 +324,7 @@
#undef FORMAT
}
-static char *complete_show_version_files(char *line, char *word, int pos, int state)
+static char *complete_show_version_files(const char *line, const char *word, int pos, int state)
{
struct file_version *find;
int which = 0;
@@ -351,35 +355,29 @@
struct ast_atexit *ae;
ast_unregister_atexit(func);
ae = malloc(sizeof(struct ast_atexit));
- ast_mutex_lock(&atexitslock);
+ AST_LIST_LOCK(&atexits);
if (ae) {
memset(ae, 0, sizeof(struct ast_atexit));
- ae->next = atexits;
+ AST_LIST_INSERT_HEAD(&atexits, ae, list);
ae->func = func;
- atexits = ae;
res = 0;
}
- ast_mutex_unlock(&atexitslock);
+ AST_LIST_UNLOCK(&atexits);
return res;
}
void ast_unregister_atexit(void (*func)(void))
{
- struct ast_atexit *ae, *prev = NULL;
- ast_mutex_lock(&atexitslock);
- ae = atexits;
- while(ae) {
+ struct ast_atexit *ae;
+ AST_LIST_LOCK(&atexits);
+ AST_LIST_TRAVERSE_SAFE_BEGIN(&atexits, ae, list) {
if (ae->func == func) {
- if (prev)
- prev->next = ae->next;
- else
- atexits = ae->next;
+ AST_LIST_REMOVE_CURRENT(&atexits, list);
break;
}
- prev = ae;
- ae = ae->next;
- }
- ast_mutex_unlock(&atexitslock);
+ }
+ AST_LIST_TRAVERSE_SAFE_END
+ AST_LIST_UNLOCK(&atexits);
}
static int fdprint(int fd, const char *s)
@@ -802,14 +800,12 @@
static void ast_run_atexits(void)
{
struct ast_atexit *ae;
- ast_mutex_lock(&atexitslock);
- ae = atexits;
- while(ae) {
+ AST_LIST_LOCK(&atexits);
+ AST_LIST_TRAVERSE(&atexits, ae, list) {
if (ae->func)
ae->func();
- ae = ae->next;
- }
- ast_mutex_unlock(&atexitslock);
+ }
+ AST_LIST_UNLOCK(&atexits);
}
static void quit_handler(int num, int nice, int safeshutdown, int restart)
@@ -1092,6 +1088,7 @@
{
if (argc != 3)
return RESULT_SHOWUSAGE;
+ ast_cli(fd, "Waiting for inactivity to perform halt\n");
quit_handler(0, 2 /* really nicely */, 1 /* safely */, 0 /* don't restart */);
return RESULT_SUCCESS;
}
@@ -1116,6 +1113,7 @@
{
if (argc != 3)
return RESULT_SHOWUSAGE;
+ ast_cli(fd, "Waiting for inactivity to perform restart\n");
quit_handler(0, 2 /* really nicely */, 1 /* safely */, 1 /* restart */);
return RESULT_SUCCESS;
}
@@ -1512,7 +1510,7 @@
idx = 1;
- qsort(&matches[0], (size_t)(len + 1), sizeof(char *), ast_el_sort_compare);
+ qsort(&matches[0], (size_t)(len), sizeof(char *), ast_el_sort_compare);
for (; count > 0; count--) {
numoutputline = 0;
@@ -1603,12 +1601,15 @@
free(mbuf);
} else
matches = (char **) NULL;
-
-
} else {
-
- nummatches = ast_cli_generatornummatches((char *)lf->buffer,ptr);
+ char **p, *oldbuf=NULL;
+ nummatches = 0;
matches = ast_cli_completion_matches((char *)lf->buffer,ptr);
+ for (p = matches; p && *p; p++) {
+ if (!oldbuf || strcmp(*p,oldbuf))
+ nummatches++;
+ oldbuf = *p;
+ }
}
if (matches) {
@@ -1642,7 +1643,7 @@
retval = CC_REFRESH;
}
}
- free(matches);
+ free(matches);
}
return (char *)(long)retval;
@@ -1931,7 +1932,7 @@
/* Run as console (-c at startup, implies nofork) */
} else if (!strcasecmp(v->name, "console")) {
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_CONSOLE);
- /* Run with highg priority if the O/S permits (-p at startup) */
+ /* Run with high priority if the O/S permits (-p at startup) */
} else if (!strcasecmp(v->name, "highpriority")) {
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_HIGH_PRIORITY);
/* Initialize RSA auth keys (IAX2) (-i at startup) */
@@ -2120,11 +2121,11 @@
}
}
- if (option_console && !option_verbose)
+ if (ast_opt_console && !option_verbose)
ast_verbose("[ Reading Master Configuration ]");
ast_readconfig();
- if (option_dumpcore) {
+ if (ast_opt_dump_core) {
struct rlimit l;
memset(&l, 0, sizeof(l));
l.rlim_cur = RLIM_INFINITY;
@@ -2286,7 +2287,7 @@
Asterisk is started
*/
srand((unsigned int) getpid() + (unsigned int) time(NULL));
- srandom((unsigned int) getpid() + (unsigned int) time(NULL));
+ initstate((unsigned int) getpid() * 65536 + (unsigned int) time(NULL), randompool, sizeof(randompool));
if (init_logger()) {
printf(term_quit());
@@ -2315,6 +2316,9 @@
exit(1);
}
ast_rtp_init();
+#if defined(T38_SUPPORT)
+ ast_udptl_init();
+#endif
if (ast_image_init()) {
printf(term_quit());
exit(1);
More information about the asterisk-commits
mailing list