[asterisk-commits] anthonyl: branch anthonyl/testing-branch r42476
- in /team/anthonyl/testing-b...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Fri Sep 8 12:40:07 MST 2006
Author: anthonyl
Date: Fri Sep 8 14:40:06 2006
New Revision: 42476
URL: http://svn.digium.com/view/asterisk?rev=42476&view=rev
Log:
updating to allow one to abort halt on a gracefull restart
Modified:
team/anthonyl/testing-branch/include/asterisk/channel.h
team/anthonyl/testing-branch/main/asterisk.c
team/anthonyl/testing-branch/main/manager.c
Modified: team/anthonyl/testing-branch/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/team/anthonyl/testing-branch/include/asterisk/channel.h?rev=42476&r1=42475&r2=42476&view=diff
==============================================================================
--- team/anthonyl/testing-branch/include/asterisk/channel.h (original)
+++ team/anthonyl/testing-branch/include/asterisk/channel.h Fri Sep 8 14:40:06 2006
@@ -1355,27 +1355,15 @@
#include <openssl/err.h>
/***** end openssl specific ******/
-
-
#define AST_SSL_DIRECTORY ""
-#define CA_LIST "root.pem"
-#define HOST "localhost"
-#define RANDOM "random.pem"
-#define SSL_PORT 4433
-
-#define CA_LIST "root.pem"
-#define HOST "localhost"
-#define RANDOM "random.pem"
-#define SSL_PORT 4433
-
-#define KEYFILE "/var/lib/asterisk/keys/server.pem"
#define ALLOC(x) malloc((x)+1)
#define ZERO(p,i) memset((p),0x00,(i))
#define SIZE 4092
-#define AST_SSL_DIR "/var/lib/asterisk/keys"
+#define AST_SSL_DIR "/var/lib/asterisk/keys/"
#define AST_SSL_CFG "/etc/asterisk/ssl.conf"
+
/* these are the types i plan on using for socket_type */
#define AST_SOCKET_TLS1 1
Modified: team/anthonyl/testing-branch/main/asterisk.c
URL: http://svn.digium.com/view/asterisk/team/anthonyl/testing-branch/main/asterisk.c?rev=42476&r1=42475&r2=42476&view=diff
==============================================================================
--- team/anthonyl/testing-branch/main/asterisk.c (original)
+++ team/anthonyl/testing-branch/main/asterisk.c Fri Sep 8 14:40:06 2006
@@ -234,7 +234,7 @@
static pthread_t consolethread = AST_PTHREADT_NULL;
static char randompool[256];
-
+static void consolehandler(char *s);
#if !defined(LOW_MEMORY)
struct file_version {
AST_LIST_ENTRY(file_version) list;
@@ -1072,11 +1072,15 @@
AST_LIST_UNLOCK(&atexits);
}
+/* 0 1 1 1 is restart gracefull */
static void quit_handler(int num, int nice, int safeshutdown, int restart)
{
char filename[80] = "";
time_t s,e;
int x;
+ int t_num;
+ char *buf;
+
/* Try to get as many CDRs as possible submitted to the backend engines (if in batch mode) */
ast_cdr_engine_term();
if (safeshutdown) {
@@ -1104,11 +1108,37 @@
ast_begin_shutdown(0);
if (option_verbose && ast_opt_console)
ast_verbose("Waiting for inactivity to perform %s...\n", restart ? "restart" : "halt");
+
+
+ /* we need to accept new cli commands here */
for (;;) {
+
+ buf = (char *)el_gets(el,&t_num);
+
+ if (buf) {
+ if (buf[strlen(buf)-1] == '\n')
+ buf[strlen(buf)-1] = '\0';
+ consolehandler((char *)buf);
+ } else {
+ if (write(STDOUT_FILENO, "\nUse EXIT or QUIT to exit the asterisk console\n",
+ strlen("\nUse EXIT or QUIT to exit the asterisk console\n")) < 0) {
+ int fd;
+ fd = open("/dev/null", O_RDWR);
+ if( fd > -1) {
+ dup2(fd,STDOUT_FILENO);
+ dup2(fd,STDIN_FILENO);
+ } else
+ ast_log(LOG_WARNING, "Failed to open /dev/null to recover from dead console. Bad things will happen!\n");
+ break;
+ }
+
+ }
+
if (!ast_active_channels())
break;
if (!shuttingdown)
break;
+
sleep(1);
}
}
@@ -2304,7 +2334,8 @@
int is_child_of_nonroot = 0;
char *buf;
char *runuser = NULL, *rungroup = NULL;
-
+
+
/* Remember original args for restart */
if (argc > sizeof(_argv) / sizeof(_argv[0]) - 1) {
fprintf(stderr, "Truncating argument size to %d\n", (int)(sizeof(_argv) / sizeof(_argv[0])) - 1);
Modified: team/anthonyl/testing-branch/main/manager.c
URL: http://svn.digium.com/view/asterisk/team/anthonyl/testing-branch/main/manager.c?rev=42476&r1=42475&r2=42476&view=diff
==============================================================================
--- team/anthonyl/testing-branch/main/manager.c (original)
+++ team/anthonyl/testing-branch/main/manager.c Fri Sep 8 14:40:06 2006
@@ -188,18 +188,16 @@
/* this is the main thread for manaing ssl manager connections */
static int *astman_ssl_thread(void)
{
- int ret;
- pthread_attr_t attr;
- time_t now;
- struct pollfd pfds[1];
-
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
- ret = ast_socket_openssl(5039,AST_SOCKET_TLS1);
-
- if(!ret) {
- ast_log(LOG_WARNING, "Error binding SSL socket\n");
- }
+ int ret;
+ pthread_attr_t attr;
+
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+ ret = ast_socket_openssl(5039,AST_SOCKET_TLS1);
+
+ if (!ret) {
+ ast_log(LOG_WARNING, "Error binding SSL socket\n");
+ }
return 0;
}
@@ -225,7 +223,7 @@
memset(res, 0, reslen);
for (i = 0; i < (sizeof(perms) / sizeof(perms[0])) - 1; i++) {
- if (authority & perms[i].num) {
+ if (authority & perms[i].num) {
if (*res) {
strncat(res, ",", (reslen > running_total) ? reslen - running_total : 0);
running_total++;
@@ -2625,9 +2623,10 @@
fcntl(asock, F_SETFL, flags | O_NONBLOCK);
if (option_verbose)
ast_verbose("Asterisk Management interface listening on port %d\n", portno);
+
ast_pthread_create(&t, NULL, accept_thread, NULL);
ast_pthread_create(&ssl_main_thread,NULL,astman_ssl_thread ,NULL);
- //astman_ssl_thread();
+
}
return 0;
}
More information about the asterisk-commits
mailing list