AST-2014-015: Fix race condition in chan_pjsip when sending responses after a CANCEL has been received.

Due to the serialized architecture of chan_pjsip there exists a race condition where a CANCEL may
be received and processed before responses (such as 180 Ringing, 183 Session Progress, and 200 OK)
are sent. Since the session is in an unexpected state PJSIP will assert when this is attempted.

This change makes it so that these responses are not sent on disconnected sessions.

ASTERISK-24471 #close
Reported by: yaron nahum
........

Merged revisions 428301 from http://svn.asterisk.org/svn/asterisk/branches/12
........

Merged revisions 428302 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: http://svn.asterisk.org/svn/asterisk/trunk@428303 f38db490-d61c-443f-a65b-d21fe96a405b
AST-2014-016: Fix crash when receiving an in-dialog INVITE with Replaces in res_pjsip_refer.

The implementation of INVITE with Replaces in res_pjsip_refer did not expect them to
occur in-dialog. As a result it would incorrectly attempt to hang up a channel it
thought was under its control. In reality the channel would be under the control of
another thread. When the other thread accessed the channel it would be accessing freed
memory and could crash.

This change makes res_pjsip_refer not act on an in-dialog INVITE with Replaces.

ASTERISK-24528 #close
Reported by: Joshua Colp
........

Merged revisions 428304 from http://svn.asterisk.org/svn/asterisk/branches/12
........

Merged revisions 428305 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: http://svn.asterisk.org/svn/asterisk/trunk@428306 f38db490-d61c-443f-a65b-d21fe96a405b