When swapping subs, queue a null frame, extend delay for hangup-on-flash
authorMark Spencer <markster@digium.com>
Fri, 11 Apr 2003 04:31:33 +0000 (04:31 +0000)
committerMark Spencer <markster@digium.com>
Fri, 11 Apr 2003 04:31:33 +0000 (04:31 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@823 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channel.c
channels/chan_sip.c
channels/chan_zap.c

index 032b693..49982d8 100755 (executable)
--- a/channel.c
+++ b/channel.c
@@ -378,6 +378,8 @@ int ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin, int lock)
                if (write(chan->pvt->alertpipe[1], &blah, sizeof(blah)) != sizeof(blah))
                        ast_log(LOG_WARNING, "Unable to write to alert pipe on %s, frametype/subclass %d/%d (qlen = %d): %s!\n",
                                chan->name, f->frametype, f->subclass, qlen, strerror(errno));
+       } else if (chan->blocking) {
+               pthread_kill(chan->blocker, SIGURG);
        }
        if (lock)
                ast_pthread_mutex_unlock(&chan->lock);
index 587fa9a..f2ee985 100755 (executable)
@@ -2304,8 +2304,8 @@ static void initreqprep(struct sip_request *req, struct sip_pvt *p, char *cmd, c
        add_header(req, "From", from);
        strncpy(p->exten, l, sizeof(p->exten) - 1);
        build_contact(p);
-       add_header(req, "Contact", p->our_contact);
        add_header(req, "To", to);
+       add_header(req, "Contact", p->our_contact);
        add_header(req, "Call-ID", p->callid);
        add_header(req, "CSeq", tmp);
        add_header(req, "User-Agent", "Asterisk PBX");
index 1ac3cf8..e67621c 100755 (executable)
@@ -242,7 +242,7 @@ static inline int zt_wait_event(int fd)
 #define CALLWAITING_SILENT_SAMPLES     ( (300 * 8) / READ_SIZE) /* 300 ms */
 #define CALLWAITING_REPEAT_SAMPLES     ( (10000 * 8) / READ_SIZE) /* 300 ms */
 #define CIDCW_EXPIRE_SAMPLES           ( (500 * 8) / READ_SIZE) /* 500 ms */
-#define MIN_MS_SINCE_FLASH                     ( (1000) )      /* 1000 ms */
+#define MIN_MS_SINCE_FLASH                     ( (2000) )      /* 2000 ms */
 #define RINGT                                          ( (8000 * 8) / READ_SIZE)
 
 struct zt_pvt;
@@ -497,6 +497,7 @@ static void swap_subs(struct zt_pvt *p, int a, int b)
        int tchan;
        int tinthreeway;
        struct ast_channel *towner;
+       struct ast_frame null = { AST_FRAME_NULL, };
 
        ast_log(LOG_DEBUG, "Swapping %d and %d\n", a, b);
 
@@ -512,10 +513,14 @@ static void swap_subs(struct zt_pvt *p, int a, int b)
        p->subs[b].owner = towner;
        p->subs[b].inthreeway = tinthreeway;
 
-       if (p->subs[a].owner)
+       if (p->subs[a].owner) {
                p->subs[a].owner->fds[0] = p->subs[a].zfd;
-       if (p->subs[b].owner)
+               ast_queue_frame(p->subs[a].owner, &null, 0);
+       }
+       if (p->subs[b].owner) {
                p->subs[b].owner->fds[0] = p->subs[b].zfd;
+               ast_queue_frame(p->subs[b].owner, &null, 0);
+       }
        
 }
 
@@ -2513,9 +2518,12 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
                                                unsigned int mssinceflash;
                                                gettimeofday(&tv, NULL);
                                                mssinceflash = (tv.tv_sec - p->flashtime.tv_sec) * 1000 + (tv.tv_usec - p->flashtime.tv_usec) / 1000;
+                                               ast_log(LOG_DEBUG, "Last flash was %d ms ago\n", mssinceflash);
                                                if (mssinceflash < MIN_MS_SINCE_FLASH) {
                                                        /* It hasn't been long enough since the last flashook.  This is probably a bounce on 
                                                           hanging up.  Hangup both channels now */
+                                                       if (p->subs[SUB_THREEWAY].owner)
+                                                               ast_queue_hangup(p->subs[SUB_THREEWAY].owner, 0);
                                                        p->subs[SUB_THREEWAY].owner->_softhangup |= AST_SOFTHANGUP_DEV;
                                                        ast_log(LOG_DEBUG, "Looks like a bounced flash, hanging up both calls on %d\n", p->channel);
                                                } else if ((ast->pbx) ||