Browse code

core: do not try to send a CANCEL request in Cancelling state.

Raphael Coeffic authored on 26/06/2013 13:37:03
Showing 1 changed files
... ...
@@ -524,7 +524,6 @@ int AmSipDialog::bye(const string& hdrs, int flags)
524 524
     case Trying:
525 525
     case Proceeding:
526 526
     case Early:
527
-    case Cancelling:
528 527
 	if(getUACInvTransPending())
529 528
 	    return cancel();
530 529
 	else {  
... ...
@@ -540,12 +539,27 @@ int AmSipDialog::bye(const string& hdrs, int flags)
540 539
 	    // missing AmSipRequest to be able
541 540
 	    // to send the reply on behalf of the app.
542 541
 	    ERROR("ignoring bye() in %s state: "
543
-		  "no UAC transaction to cancel.\n",
542
+		  "no UAC transaction to cancel or UAS transaction to reply.\n",
544 543
 		  getStatusStr());
545 544
 	    setStatus(Disconnected);
546 545
 	}
547 546
 	return 0;
548 547
 
548
+    case Cancelling:
549
+      for (TransMap::iterator it=uas_trans.begin();
550
+	   it != uas_trans.end(); it++) {
551
+	if (it->second.method == SIP_METH_INVITE){
552
+	  // let's quit this call by sending final reply
553
+	  return reply(it->second, 487,"Request terminated");
554
+	}
555
+      }
556
+
557
+      // missing AmSipRequest to be able
558
+      // to send the reply on behalf of the app.
559
+      ERROR("ignoring bye() in %s state: no UAS transaction to reply",getStatusStr());
560
+      setStatus(Disconnected);
561
+      return 0;
562
+
549 563
     default:
550 564
         DBG("bye(): we are not connected "
551 565
 	    "(status=%s). do nothing!\n",getStatusStr());