Only send 180 ringing once, fix CTRL+D in main code
authorMark Spencer <markster@digium.com>
Thu, 22 May 2003 14:24:06 +0000 (14:24 +0000)
committerMark Spencer <markster@digium.com>
Thu, 22 May 2003 14:24:06 +0000 (14:24 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1052 65c4cc65-6c06-0410-ace0-fbb531ad65f3

asterisk.c
channels/chan_sip.c

index 933ab55..a00c990 100755 (executable)
@@ -1373,12 +1373,15 @@ int main(int argc, char *argv[])
            ast_cli_register(&astexit);
                consolethread = pthread_self();
 
            ast_cli_register(&astexit);
                consolethread = pthread_self();
 
-               while ( (buf = (char *)el_gets(el, &num) ) != NULL && num != 0) {
-
-                       if (buf[strlen(buf)-1] == '\n')
-                               buf[strlen(buf)-1] = '\0';
-
-                       consolehandler((char *)buf);
+               for (;;) {
+                       buf = (char *)el_gets(el, &num);
+                       if (buf) {
+                               if (buf[strlen(buf)-1] == '\n')
+                                       buf[strlen(buf)-1] = '\0';
+
+                               consolehandler((char *)buf);
+                       } else
+                               ast_cli(STDOUT_FILENO, "\nUse EXIT or QUIT to exist, or STOP NOW to shutdown Asterisk\n");
                }
 
        } else {
                }
 
        } else {
index df04adb..e4bd5af 100755 (executable)
@@ -179,6 +179,7 @@ static struct sip_pvt {
        int expiry;                                             /* How long we take to expire */
        int branch;                                                     /* One random number */
        int canreinvite;                                        /* Do we support reinvite */
        int expiry;                                             /* How long we take to expire */
        int branch;                                                     /* One random number */
        int canreinvite;                                        /* Do we support reinvite */
+       int ringing;                                            /* Have sent 180 ringing */
        int progress;                                           /* Have sent 183 message progress */
        int tag;                                                        /* Another random number */
        int nat;                                                        /* Whether to try to support NAT */
        int progress;                                           /* Have sent 183 message progress */
        int tag;                                                        /* Another random number */
        int nat;                                                        /* Whether to try to support NAT */
@@ -1011,8 +1012,9 @@ static int sip_indicate(struct ast_channel *ast, int condition)
        switch(condition) {
        case AST_CONTROL_RINGING:
                if (ast->_state == AST_STATE_RING) {
        switch(condition) {
        case AST_CONTROL_RINGING:
                if (ast->_state == AST_STATE_RING) {
-                       if (!p->progress) {
+                       if (!p->progress && !p->ringing) {
                                transmit_response(p, "180 Ringing", &p->initreq);
                                transmit_response(p, "180 Ringing", &p->initreq);
+                               p->ringing = 1;
                                break;
                        } else {
                                /* Oops, we've sent progress tones.  Let Asterisk do it instead */
                                break;
                        } else {
                                /* Oops, we've sent progress tones.  Let Asterisk do it instead */