Index: channels/chan_sip.c =================================================================== RCS file: /home/ipcontact/cvsroot/asterisk/channels/chan_sip.c,v retrieving revision 1.11 diff -w -u -r1.11 chan_sip.c --- channels/chan_sip.c 30 Jun 2004 15:20:58 -0000 1.11 +++ channels/chan_sip.c 7 Jul 2004 19:02:41 -0000 @@ -271,7 +271,8 @@ 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 ringing; /* Incomming: Have sent 180 ringing + Outgoing: INVITE sent with no final response */ int progress; /* Have sent 183 message progress */ int tag; /* Another random number */ int nat; /* Whether to try to support NAT */ @@ -1476,6 +1477,7 @@ /* Initialize auto-congest time */ p->initid = ast_sched_add(sched, p->maxtime * 4, auto_congest, p); } + p->ringing = 1; } return res; } @@ -1707,7 +1709,7 @@ ast_mutex_unlock(&p->lock); return 0; } - if (!ast || (ast->_state != AST_STATE_UP)) + if (!ast || (p->outgoing && p->ringing) ) needcancel = 1; /* Disconnect */ p = ast->pvt->pvt; @@ -1723,10 +1725,15 @@ ast_update_use_count(); needdestroy = 1; + ast_log(LOG_WARNING, "Hangup on channel:%s username:%s peername:%s uri:%s needcancel=%d state=%d alreadygone=%d from=%s ourcontact=%s ringing=%d progress=%d\n", ast->name,p->username,p->peername,p->uri,needcancel,ast->_state,p->alreadygone,p->from,p->our_contact,p->ringing,p->progress); + /* Start the process if it's not already started */ if (!p->alreadygone && !ast_strlen_zero(p->initreq.data)) { + ast_log(LOG_DEBUG, "Channel %s startin disconnect\n", ast->name); if (needcancel) { + ast_log(LOG_DEBUG, "Channel %s needcancel\n", ast->name); if (p->outgoing) { + ast_log(LOG_DEBUG, "Channel %s is outgoing, request CANCEL\n", ast->name); transmit_request_with_auth(p, "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. */ @@ -6467,6 +6474,7 @@ } } p->authtries = 0; + p->ringing = 0; /* If I understand this right, the branch is different for a non-200 ACK only */ transmit_request(p, "ACK", seqno, 0, 1); check_pendings(p); @@ -6952,6 +6960,7 @@ } else { ast_mutex_unlock(&p->lock); ast_setstate(c, AST_STATE_DOWN); + ast_log(LOG_NOTICE, "Calling Hangup in channel: %s\n",c->name); ast_hangup(c); ast_mutex_lock(&p->lock); c = NULL;