Allow AMI action callback to be reentrant.

Fix AMI module reload deadlock regression from ASTERISK-18479 when it
tried to fix the race between calling an AMI action callback and
unregistering that action.  Refixes ASTERISK-13784 broken by
ASTERISK-17785 change.

Locking the ao2 object guaranteed that there were no active callbacks that
mattered when ast_manager_unregister() was called.  Unfortunately, this
causes the deadlock situation.  The patch stops locking the ao2 object to
allow multiple threads to invoke the callback re-entrantly.  There is no
way to guarantee a module unload will not crash because of an active
callback.  The code attempts to minimize the chance with the registered
flag and the maximum 5 second delay before ast_manager_unregister()
returns.

The trunk version of the patch changes the API to fix the race condition
correctly to prevent the module code from unloading from memory while an
action callback is active.

* Don't hold the lock while calling the AMI action callback.

(closes issue ASTERISK-19487)
Reported by: Philippe Lindheimer

Review: https://reviewboard.asterisk.org/r/1818/
Review: https://reviewboard.asterisk.org/r/1820/
........

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


git-svn-id: file:///sync/mirror/asterisk/branches/10@359980 eedb1c7a-6a47-11e1-93ee-a9c596eb3dd7
chan_iax2: Emit Port alongside Post in PeerStatus AMI Event.

The PeerStatus event for IAX2 channels currently includes a header named Post
which should have been Port.  So include Port along with Post when emitting the
event.  We'll remove Post in trunk.


git-svn-id: file:///sync/mirror/asterisk/branches/10@359982 eedb1c7a-6a47-11e1-93ee-a9c596eb3dd7
Prevent Echo() from relaying control, null, and modem frames

Echo()'s description states that it echoes audio, video, and DTMF except for #
while it actually echoes any frame that it receives other than DTMF #.  This
was causing frame storms in the test suite in some circumstances where Echo()
was attached to both ends of a pair of local channels and control frames
were being periodically generated.  Echo()'s behavior and description have
been modifed so that it only echoes media and non-# DTMF frames.
........

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


git-svn-id: file:///sync/mirror/asterisk/branches/10@360034 eedb1c7a-6a47-11e1-93ee-a9c596eb3dd7
Ensure Asterisk sends a BYE when pending on the final response to a re-INVITE

When Asterisk detects a hangup and cannot send a BYE due to a pending
INVITE, it sets the pendingbye flag and waits for the final response to that
INVITE.  When the response is received, it transmits the BYE.  If, however,
that INVITE request is a pending re-INVITE, it needs to first send a CANCEL
request to terminate the pending re-INVITE.  In that circumstance, Asterisk
was, in some scenarios, clearing the pendingbye flag after processing the
CANCEL request and not checking for a pending BYE when receiving the final
487 response to the INVITE.

This patch ensures that if the pendingbye flag is set, it is honored
regardless of the nature of the INVITE request currently in flight.

(closes issue ASTERISK-19365)
Reported by: Thomas Arimont
Tested by: Thomas Arimont
Patches:
  bugASTERISK-19365_2012_03_08.patch uploaded by mjordan (license 6283)

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

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


git-svn-id: file:///sync/mirror/asterisk/branches/10@360088 eedb1c7a-6a47-11e1-93ee-a9c596eb3dd7
Also detect gmime 2.6

Also detect gmime version 2.6 (Michael Biebl)

Signed-off-by: Tzafrir Cohen (License #5035) <tzafrir.cohen@xorcom.com>
........

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


git-svn-id: file:///sync/mirror/asterisk/branches/10@360098 eedb1c7a-6a47-11e1-93ee-a9c596eb3dd7
Update install_prereq script to include missing GSM library for debian amd move SQLite3.

(closes issue ASTERISK-19367)
Reported by: Andrew Latham
Patches:
	debian_install_prereq.diff uploaded by Andrew Latham (license 5985)
........

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


git-svn-id: file:///sync/mirror/asterisk/branches/10@360139 eedb1c7a-6a47-11e1-93ee-a9c596eb3dd7
Add missing initialization of update_redirecting in chan_sip.c
........

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


git-svn-id: file:///sync/mirror/asterisk/branches/10@360263 eedb1c7a-6a47-11e1-93ee-a9c596eb3dd7
Make number not available presentation also set screening to network provided.

Q.951 indicates that when the presentation indicator is "Number not
available due to interworking" for a number then the screening indicator
field should be "Network provided".

* Made ast_party_id_presentation() return AST_PRES_NUMBER_NOT_AVAILABLE
when the presentation is "Number not available due to interworking".  This
fix makes Asterisk consistent and it also makes it consistent with earlier
branches as far as this presentation value is concerned.

* Made pri_to_ast_presentation() and ast_to_pri_presentation() conversions
handle the "Number not available due to interworking" case better in
sig_pri.c.  This change is possible because the minimum required libpri
version (v1.4.11) has the necessary defines in libpri.h.
........

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


git-svn-id: file:///sync/mirror/asterisk/branches/10@360310 eedb1c7a-6a47-11e1-93ee-a9c596eb3dd7
Multiple revisions 360356-360357

........
  r360356 | russell | 2012-03-23 22:33:36 -0400 (Fri, 23 Mar 2012) | 6 lines
  
  expression parser: Fix (theoretical) memory leak.
  
  Fix a memory leak that is very unlikely to actually happen.  If a malloc()
  succeeded, but the following strdup() failed, the memory from the original
  malloc() would be leaked.
........
  r360357 | russell | 2012-03-23 22:34:39 -0400 (Fri, 23 Mar 2012) | 6 lines
  
  Rebuild parsers.
  
  This is needed to include the last fix to main/ast_expr2.y.  The changes look
  much bigger as this regeneration of the code was done with newer versions of
  flex and bison.
........

Merged revisions 360356-360357 from http://svn.asterisk.org/svn/asterisk/branches/1.8


git-svn-id: file:///sync/mirror/asterisk/branches/10@360358 eedb1c7a-6a47-11e1-93ee-a9c596eb3dd7
app_jack: fix datastore memory leak in error handling path.
........

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


git-svn-id: file:///sync/mirror/asterisk/branches/10@360361 eedb1c7a-6a47-11e1-93ee-a9c596eb3dd7
app_page: Fix a memory leak on every Page().

dial_list is a dynamically allocated array that is allocated at the beginning
of Page() based on how many devices will be dialed.  This was never being freed.
........

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


git-svn-id: file:///sync/mirror/asterisk/branches/10@360364 eedb1c7a-6a47-11e1-93ee-a9c596eb3dd7
func_curl: Fix leak of an ast_str in error handling code path.
........

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


git-svn-id: file:///sync/mirror/asterisk/branches/10@360414 eedb1c7a-6a47-11e1-93ee-a9c596eb3dd7
Increase verbosity level for ast_verb messages

While this does not fix the issue of the CLI being flooded by 'doing
dnsmgr_lookup' messages, increasing the verbosity level above 5 should help
minimize it.
........

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


git-svn-id: file:///sync/mirror/asterisk/branches/10@360472 eedb1c7a-6a47-11e1-93ee-a9c596eb3dd7
Blocked revisions 360473

........
Fix Asterisk version typo


git-svn-id: file:///sync/mirror/asterisk/branches/10@360475 eedb1c7a-6a47-11e1-93ee-a9c596eb3dd7
Update CHANGES for r360471
........

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


git-svn-id: file:///sync/mirror/asterisk/branches/10@360476 eedb1c7a-6a47-11e1-93ee-a9c596eb3dd7
Fix BETTER_BACKTRACES library detection for Fedora/RedHat/CentOS

(closes ASTERISK-17842)
Reported by: Bryon Clark
Patches:
	20110512__issue19278.diff.txt uploaded by Tilghman Lesher (license 5003)
	configure_bfd_with_dl_and_iberty.patch uploaded by Bryon Clark (license 6157)
........

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


git-svn-id: file:///sync/mirror/asterisk/branches/10@360489 eedb1c7a-6a47-11e1-93ee-a9c596eb3dd7
Updates config with bootstrap where I changed configure.ac in r360488

(issue ASTERISK-17842)
Reported by: Bryon Clark
........

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


git-svn-id: file:///sync/mirror/asterisk/branches/10@360575 eedb1c7a-6a47-11e1-93ee-a9c596eb3dd7
Make a debug message regarding subscription changes more accurate.

I was getting confused during some testing why Asterisk was saying that
a subscription was being added when it was clearly being removed. This
fixes that confusion.
........

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


git-svn-id: file:///sync/mirror/asterisk/branches/10@360672 eedb1c7a-6a47-11e1-93ee-a9c596eb3dd7
Destroy configs when they are no longer used

https://reviewboard.asterisk.org/r/1834/
........

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


git-svn-id: file:///sync/mirror/asterisk/branches/10@360717 eedb1c7a-6a47-11e1-93ee-a9c596eb3dd7
Improve accuracy of identifying information sent in dialog-info SIP NOTIFY requests.

This change makes use of connected party information in addition to caller ID in order
to populate local and remote XML elements in the dialog-info NOTIFYs.

(closes issue ASTERISK-16735)
Reported by: Maciej Krajewski
Tested by: Maciej Krajewski
Patches:
    local_remote_hint2.diff uploaded by Mark Michelson (license 5049)
........

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


git-svn-id: file:///sync/mirror/asterisk/branches/10@360863 eedb1c7a-6a47-11e1-93ee-a9c596eb3dd7