diff options
author | file <file@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-09-05 23:48:48 +0000 |
---|---|---|
committer | file <file@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-09-05 23:48:48 +0000 |
commit | 2993593622bec2056db9560074d9aff5609fa59d (patch) | |
tree | 5591386be584106884a4ed675d417a70c15fe946 /channels | |
parent | 41ca1c9fb93018c5c83aba6816f499f841b41054 (diff) |
Merged revisions 41768,41827,41830,41880,41882,41989,42014,42054 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r41768 | file | 2006-09-01 18:49:07 -0400 (Fri, 01 Sep 2006) | 2 lines
Only wipe the redirected audio & video IP/port if it's specified, and trigger a reinvite.
........
r41827 | bweschke | 2006-09-03 10:16:08 -0400 (Sun, 03 Sep 2006) | 3 lines
Setting a retry of 0 is generally not a good idea and shouldn't be allowed. (#7574 - reported by regin)
........
r41830 | bweschke | 2006-09-03 10:50:59 -0400 (Sun, 03 Sep 2006) | 3 lines
Let's NOT spy on Zap/psuedo channels, mmmmmmmmk?
........
r41880 | bweschke | 2006-09-03 13:13:38 -0400 (Sun, 03 Sep 2006) | 3 lines
Don't keep trying the same member in certain strategies when members of the queue are unavailable (#7278 - diLLec reported and patched) - This should have been patched here first and then merged into /trunk. My bad!
........
r41882 | bweschke | 2006-09-03 13:38:22 -0400 (Sun, 03 Sep 2006) | 3 lines
Make sure the forwarded channel inherits variables appropriately when we receive a call forward in the queue. (#7867 - raarts reported and patched)
........
r41989 | oej | 2006-09-04 11:46:07 -0400 (Mon, 04 Sep 2006) | 2 lines
Don't kill the pvt before we have sent ACK on CANCEL (needs more testing before making a release)
........
r42014 | qwell | 2006-09-05 12:27:46 -0400 (Tue, 05 Sep 2006) | 4 lines
Small typo in zapata.conf.sample
Reported by ppyy in 7881
........
r42054 | file | 2006-09-05 16:02:48 -0400 (Tue, 05 Sep 2006) | 2 lines
Merge in last round of spy fixes. This should hopefully eliminate all the issues people have been seeing by distinctly separating what each component (core/spy) is responsible for. Core is responsible for adding a spy to a channel, feeding frames to the spy, removing the spy from a channel, and telling the spy to stop. Spy is responsible for reading frames in, and cleaning up after itself.
........
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.2-netsec@42081 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r-- | channels/chan_sip.c | 55 |
1 files changed, 38 insertions, 17 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 5259a459f..d217ba81c 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -2447,7 +2447,7 @@ static int sip_hangup(struct ast_channel *ast) { struct sip_pvt *p = ast->tech_pvt; int needcancel = 0; - struct ast_flags locflags = {0}; + int needdestroy = 0; if (!p) { ast_log(LOG_DEBUG, "Asked to hangup channel not connected\n"); @@ -2481,7 +2481,6 @@ static int sip_hangup(struct ast_channel *ast) #endif /* Disconnect */ - p = ast->tech_pvt; if (p->vad) { ast_dsp_free(p->vad); } @@ -2493,7 +2492,16 @@ static int sip_hangup(struct ast_channel *ast) ast_mutex_unlock(&usecnt_lock); ast_update_use_count(); - ast_set_flag(&locflags, SIP_NEEDDESTROY); + /* Do not destroy this pvt until we have timeout or + get an answer to the BYE or INVITE/CANCEL + If we get no answer during retransmit period, drop the call anyway. + (Sorry, mother-in-law, you can't deny a hangup by sending + 603 declined to BYE...) + */ + if (ast_test_flag(p, SIP_ALREADYGONE)) + needdestroy = 1; /* Set destroy flag at end of this function */ + else + sip_scheddestroy(p, 32000); /* Start the process if it's not already started */ if (!ast_test_flag(p, SIP_ALREADYGONE) && !ast_strlen_zero(p->initreq.data)) { @@ -2506,13 +2514,12 @@ static int sip_hangup(struct ast_channel *ast) it pending */ if (!ast_test_flag(p, SIP_CAN_BYE)) { ast_set_flag(p, SIP_PENDINGBYE); + /* Do we need a timer here if we don't hear from them at all? */ } else { /* Send a new request: CANCEL */ transmit_request_with_auth(p, SIP_CANCEL, p->ocseq, 1, 0); /* Actually don't destroy us yet, wait for the 487 on our original INVITE, but do set an autodestruct just in case we never get it. */ - ast_clear_flag(&locflags, SIP_NEEDDESTROY); - sip_scheddestroy(p, 32000); } if ( p->initid != -1 ) { /* channel still up - reverse dec of inUse counter @@ -2538,7 +2545,8 @@ static int sip_hangup(struct ast_channel *ast) } } } - ast_copy_flags(p, (&locflags), SIP_NEEDDESTROY); + if (needdestroy) + ast_set_flag(p, SIP_NEEDDESTROY); ast_mutex_unlock(&p->lock); return 0; } @@ -10085,6 +10093,9 @@ static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_ handle_response_invite(p, resp, rest, req, ignore, seqno); } else if (sipmethod == SIP_REGISTER) { res = handle_response_register(p, resp, rest, req, ignore, seqno); + } else if (sipmethod == SIP_BYE) { + /* Ok, we're ready to go */ + ast_set_flag(p, SIP_NEEDDESTROY); } break; case 401: /* Not www-authorized on SIP method */ @@ -10236,9 +10247,12 @@ static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_ handle_response_invite(p, resp, rest, req, ignore, seqno); } else if (sipmethod == SIP_CANCEL) { ast_log(LOG_DEBUG, "Got 200 OK on CANCEL\n"); - } else if (sipmethod == SIP_MESSAGE) + } else if (sipmethod == SIP_MESSAGE) /* We successfully transmitted a message */ ast_set_flag(p, SIP_NEEDDESTROY); + else if (sipmethod == SIP_BYE) + /* Ok, we're ready to go */ + ast_set_flag(p, SIP_NEEDDESTROY); break; case 401: /* www-auth */ case 407: @@ -10924,10 +10938,15 @@ static int handle_request_bye(struct sip_pvt *p, struct sip_request *req, int de if (p->owner) ast_queue_hangup(p->owner); } - } else if (p->owner) + } else if (p->owner) { ast_queue_hangup(p->owner); - else + if (option_debug > 2) + ast_log(LOG_DEBUG, "Received bye, issuing owner hangup\n."); + } else { ast_set_flag(p, SIP_NEEDDESTROY); + if (option_debug > 2) + ast_log(LOG_DEBUG, "Received bye, no owner, selfdestruct soon.\n."); + } transmit_response(p, "200 OK", req); return 1; @@ -13057,24 +13076,26 @@ static int sip_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struc if (!p) return -1; ast_mutex_lock(&p->lock); - if (rtp) { + if (rtp) { changed |= ast_rtp_get_peer(rtp, &p->redirip); #ifdef SIP_MIDCOM if (m_cb) - m_cb->ast_rtp_get_their_nat_audio_hook(rtp, p->r); + m_cb->ast_rtp_get_their_nat_audio_hook(rtp, p->r); #endif - } - else + } else if (p->redirip.sin_addr.s_addr || ntohs(p->redirip.sin_port) != 0) { memset(&p->redirip, 0, sizeof(p->redirip)); - if (vrtp) { + changed = 1; + } + if (vrtp) { changed |= ast_rtp_get_peer(vrtp, &p->vredirip); #ifdef SIP_MIDCOM if (m_cb) - m_cb->ast_rtp_get_their_nat_video_hook(vrtp, p->r); + m_cb->ast_rtp_get_their_nat_video_hook(vrtp, p->r); #endif - } - else + } else if (p->vredirip.sin_addr.s_addr || ntohs(p->vredirip.sin_port) != 0) { memset(&p->vredirip, 0, sizeof(p->vredirip)); + changed = 1; + } if (codecs && (p->redircodecs != codecs)) { p->redircodecs = codecs; changed = 1; |