res_fax: Resolve module reference leak caused by reserved sessions

Remove reference to module providing reserved session after
adding a reference to the final module.  This re-reference
is done to ensure that module references are correct even
if the final session selects a different module than the
reserved session.

ASTERISK-18923 #close
Reported by: Grigoriy Puzankin
Review: https://reviewboard.asterisk.org/r/4048/
........

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

Merged revisions 425407 from http://svn.asterisk.org/svn/asterisk/branches/11
........

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

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


git-svn-id: http://svn.asterisk.org/svn/asterisk/trunk@425419 f38db490-d61c-443f-a65b-d21fe96a405b
stasis_channels.c: Resolve unfinished Dials when doing masquerades (Part 2)

Masquerades into and out of channels that are involved in a dial operation
don't create the expected dial end event.  The missing dial end event goes
against the model for things like CDRs and generating Dial end manager
actions and such.

There are four cases:

1) A channel masquerades into the caller channel.  The case happens when
performing a blonde transfer using the channel driver's protocol.

2) A channel masquerades into a callee channel.  The case happens when
performing a directed call pickup.

3) The caller channel masquerades out of dial.  The case happens when
using the Bridge application on the caller channel.

4) A callee channel masquerades out of dial.  The case happens when using
the Bridge application on a peer channel.

As it turned out, all four cases need to be handled instead of just the
first one.

ASTERISK-24237
Reported by: Richard Mudgett

ASTERISK-24394 #close
Reported by: Richard Mudgett

Review: https://reviewboard.asterisk.org/r/4066/
........

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

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


git-svn-id: http://svn.asterisk.org/svn/asterisk/trunk@425456 f38db490-d61c-443f-a65b-d21fe96a405b
res_fax: Fix reference leak caused by gateway sessions

Fax gateway session objects can be re-used, causing the
same gateway session to be added to faxregistry.container
more than once.  This change causes fax_session_new to
remove the reserved session from the container before
it's id is changed, ensuring it's possible for the
session to be freed.

ASTERISK-24392 #close
Reported by: Corey Farrell
Review: https://reviewboard.asterisk.org/r/4049/
........

Merged revisions 425457 from http://svn.asterisk.org/svn/asterisk/branches/11
........

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

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


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