]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Multiple revisions 368629,368645
authorJason Parker <jparker@digium.com>
Mon, 11 Jun 2012 21:54:53 +0000 (21:54 +0000)
committerJason Parker <jparker@digium.com>
Mon, 11 Jun 2012 21:54:53 +0000 (21:54 +0000)
........
  r368629 | mmichelson | 2012-06-06 14:18:20 -0500 (Wed, 06 Jun 2012) | 31 lines

  Fix a specific scenario where ACKs are not matched.

  If a dialog-starting INVITE contains a to-tag, then Asterisk
  will respond with a 481. In this case, the resulting incoming
  ACK would not be matched, so Asterisk would continue retransmitting
  the 481 until the transaction times out.

  There were two issues. Asterisk, upon creating a sip_pvt would generate
  a local tag. However, when the time came to transmit the 481, since there
  was a to-tag in the INVITE, Asterisk would place this original to-tag
  in the 481 response. When the ACK came in, Asterisk would attempt to
  match the to-tag in the ACK to the generated local tag. Unfortunately,
  Asterisk never actually transmitted a response with the generated local
  tag, so the to-tag in the ACK would not match.

  The other problem was that when the 481 was sent, nothing was set
  on the sip_pvt to indicate what CSeq is expected in the ACK.

  To fix the first problem, we zero out the to-tag seen in the incoming
  INVITE. This way, Asterisk, when time to send a response, will send
  its generated local tag instead.

  To fix the second problem, we set the sip_pvt's pendinginvite to the
  CSeq of the INVITE when we send a 481.

  (closes issue ASTERISK-19892)
  Reported by Mark Michelson
  ........

  Merged revisions 368625 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
  r368645 | rmudgett | 2012-06-06 16:32:09 -0500 (Wed, 06 Jun 2012) | 17 lines

  Fix POTS flash hook to orignate a second call deadlock.

  A deadlock can occur when a POTS phone tries to flash hook to originate a
  second call for 3-way or transfer.  If another process is scanning the
  channels container when the POTS line flash hooks then a deadlock will
  occur.

  * Release the channel and private locks when creating a new channel as a
  result of a flash hook.

  (closes issue ASTERISK-19842)
  Reported by: rmudgett
  Tested by: rmudgett
  ........

  Merged revisions 368644 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 368629,368645 from http://svn.asterisk.org/svn/asterisk/branches/10

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/10-digiumphones@368782 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_dahdi.c
channels/chan_sip.c
channels/sig_analog.c

index 5eddc3f604bc03eb3c5574a92d21b9d5f35580e8..2ce2cf8719d58f9992f0ad8de0fb78e0011bfe4f 100644 (file)
@@ -8601,8 +8601,18 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
                                                ast_log(LOG_WARNING, "Unable to allocate three-way subchannel\n");
                                                goto winkflashdone;
                                        }
-                                       /* Make new channel */
+
+                                       /*
+                                        * Make new channel
+                                        *
+                                        * We cannot hold the p or ast locks while creating a new
+                                        * channel.
+                                        */
+                                       ast_mutex_unlock(&p->lock);
+                                       ast_channel_unlock(ast);
                                        chan = dahdi_new(p, AST_STATE_RESERVED, 0, SUB_THREEWAY, 0, NULL);
+                                       ast_channel_lock(ast);
+                                       ast_mutex_lock(&p->lock);
                                        if (p->dahditrcallerid) {
                                                if (!p->origcid_num)
                                                        p->origcid_num = ast_strdup(p->cid_num);
index b4b6d0b7e10b64a25ab2861bc29b348a902cb3c2..b244466d3379b1a34489313b64cca908cbf062ab 100644 (file)
@@ -26239,6 +26239,15 @@ static int handle_incoming(struct sip_pvt *p, struct sip_request *req, struct as
                if (!p->initreq.headers && req->has_to_tag) {
                        /* If this is a first request and it got a to-tag, it is not for us */
                        if (!req->ignore && req->method == SIP_INVITE) {
+                               /* We will be subversive here. By blanking out the to-tag of the request,
+                                * it will cause us to attach our own generated to-tag instead. This way,
+                                * when we receive an ACK, the ACK will contain the to-tag we generated,
+                                * resulting in a proper to-tag match.
+                                */
+                               char *to_header = (char *) sip_get_header(req, "To");
+                               char *tag = strstr(to_header, ";tag=");
+                               *tag = '\0';
+                               p->pendinginvite = p->icseq;
                                transmit_response_reliable(p, "481 Call/Transaction Does Not Exist", req);
                                /* Will cease to exist after ACK */
                                return res;
index aded6054d7310010539c939a35eca3bfe878fcd8..b3e75b18b8243ba7b44d95bbb335f4b0ba207b70 100644 (file)
@@ -3205,8 +3205,18 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
                                                ast_log(LOG_WARNING, "Unable to allocate three-way subchannel\n");
                                                goto winkflashdone;
                                        }
-                                       /* Make new channel */
+
+                                       /*
+                                        * Make new channel
+                                        *
+                                        * We cannot hold the p or ast locks while creating a new
+                                        * channel.
+                                        */
+                                       analog_unlock_private(p);
+                                       ast_channel_unlock(ast);
                                        chan = analog_new_ast_channel(p, AST_STATE_RESERVED, 0, ANALOG_SUB_THREEWAY, NULL);
+                                       ast_channel_lock(ast);
+                                       analog_lock_private(p);
                                        if (!chan) {
                                                ast_log(LOG_WARNING,
                                                        "Cannot allocate new call structure on channel %d\n",