diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2001-03-22 04:14:04 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2001-03-22 04:14:04 +0000 |
commit | da4387a3b3b1a3d85b288794b74007509c9967ae (patch) | |
tree | 4c96e7a5fd742133532f37a8f53f816e08c84af3 /asterisk.c | |
parent | ba4af431526c870cc4a17901b32b8b806f6d06fd (diff) |
Version 0.1.7 from FTP
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@251 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'asterisk.c')
-rwxr-xr-x | asterisk.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/asterisk.c b/asterisk.c index de86f561b..94e6802d0 100755 --- a/asterisk.c +++ b/asterisk.c @@ -17,6 +17,8 @@ #include <asterisk/options.h> #include <asterisk/cli.h> #include <asterisk/channel.h> +#include <asterisk/ulaw.h> +#include <asterisk/callerid.h> #include <stdio.h> #include <signal.h> #include <sched.h> @@ -35,9 +37,6 @@ int fully_booted = 0; char defaultlanguage[MAX_LANGUAGE] = DEFAULT_LANGUAGE; -#define HIGH_PRIORITY 1 -#define HIGH_PRIORITY_SCHED SCHED_RR - static void urg_handler(int num) { /* Called by soft_hangup to interrupt the select, read, or other @@ -64,14 +63,17 @@ static void set_icon(char *text) static int set_priority(int pri) { struct sched_param sched; + memset(&sched, 0, sizeof(sched)); /* We set ourselves to a high priority, that we might pre-empt everything else. If your PBX has heavy activity on it, this is a good thing. */ if (pri) { - sched.sched_priority = HIGH_PRIORITY; - if (sched_setscheduler(0, HIGH_PRIORITY_SCHED, &sched)) { + sched.sched_priority = 10; + if (sched_setscheduler(0, SCHED_RR, &sched)) { ast_log(LOG_WARNING, "Unable to set high priority\n"); return -1; - } + } else + if (option_verbose) + ast_verbose("Set to realtime thread\n"); } else { sched.sched_priority = 0; if (sched_setscheduler(0, SCHED_OTHER, &sched)) { @@ -161,6 +163,11 @@ int main(int argc, char *argv[]) fd_set rfds; int res; char filename[80] = ""; + char hostname[256]; + if (gethostname(hostname, sizeof(hostname))) + strncpy(hostname, "<Unknown>", sizeof(hostname)); + ast_ulaw_init(); + callerid_init(); if (getenv("HOME")) snprintf(filename, sizeof(filename), "%s/.asterisk_history", getenv("HOME")); /* Check if we're root */ @@ -178,6 +185,7 @@ int main(int argc, char *argv[]) case 'c': option_console++; option_nofork++; + break; case 'p': option_highpriority++; break; @@ -205,14 +213,14 @@ int main(int argc, char *argv[]) signal(SIGINT, quit_handler); signal(SIGTERM, quit_handler); signal(SIGHUP, quit_handler); + if (set_priority(option_highpriority)) + exit(1); if (init_logger()) exit(1); if (load_pbx()) exit(1); if (load_modules()) exit(1); - if (set_priority(option_highpriority)) - exit(1); /* We might have the option of showing a console, but for now just do nothing... */ if (option_console && !option_verbose) @@ -225,7 +233,7 @@ int main(int argc, char *argv[]) /* Register our quit function */ char title[256]; set_icon("Asterisk"); - snprintf(title, sizeof(title), "Asterisk Console (pid %d)", getpid()); + snprintf(title, sizeof(title), "Asterisk Console on '%s' (pid %d)", hostname, getpid()); set_title(title); ast_cli_register(&quit); consolethread = pthread_self(); |