]> git.ipfire.org Git - thirdparty/asterisk.git/log
thirdparty/asterisk.git
9 years agoapp_voicemail: always copy dynamic struct to avoid race condition 33/2433/13
Andrew Nagy [Thu, 17 Mar 2016 19:29:38 +0000 (12:29 -0700)] 
app_voicemail: always copy dynamic struct to avoid race condition

Voicemail email addresses can be corrupt or voicemail
emails can end up being sent to the wrong email address if asterisk is
reading voicemail.conf during a reload and processing an email at the
same time. This patch always copies the struct that would otherwise only
be copied once.

ASTERISK-24463 #close
Reported by: John Campbell
Tested by: Etienne Lessard
Tested by: Andrew Nagy
Change-Id: I3a0643813116da84e2617291903d0d489b7425fb

9 years agoMerge "pjproject_bundled: Disable PJSIP_UNESCAPE_IN_PLACE" into 13
zuul [Fri, 29 Apr 2016 20:08:33 +0000 (15:08 -0500)] 
Merge "pjproject_bundled:  Disable PJSIP_UNESCAPE_IN_PLACE" into 13

9 years agoMerge "res_pjsip: Start body generator users after suppliers." into 13
Joshua Colp [Fri, 29 Apr 2016 18:11:37 +0000 (13:11 -0500)] 
Merge "res_pjsip: Start body generator users after suppliers." into 13

9 years agoMerge "res_pjsip_pubsub.c: Fix body generator registration race." into 13
zuul [Fri, 29 Apr 2016 18:06:27 +0000 (13:06 -0500)] 
Merge "res_pjsip_pubsub.c: Fix body generator registration race." into 13

9 years agoMerge "chan_sip: Make autocreated peers send PeerStatus events" into 13
zuul [Fri, 29 Apr 2016 17:13:57 +0000 (12:13 -0500)] 
Merge "chan_sip: Make autocreated peers send PeerStatus events" into 13

9 years agoMerge "res_pjsip_outbound_publish.c: Remove redundant flag check." into 13
Joshua Colp [Fri, 29 Apr 2016 09:57:32 +0000 (04:57 -0500)] 
Merge "res_pjsip_outbound_publish.c: Remove redundant flag check." into 13

9 years agoMerge "res_pjsip_pubsub.c: Add useful information to some messages." into 13
zuul [Fri, 29 Apr 2016 04:01:59 +0000 (23:01 -0500)] 
Merge "res_pjsip_pubsub.c: Add useful information to some messages." into 13

9 years agoMerge "res_pjsip_pubsub.h: Fix doxygen association." into 13
zuul [Fri, 29 Apr 2016 03:43:32 +0000 (22:43 -0500)] 
Merge "res_pjsip_pubsub.h: Fix doxygen association." into 13

9 years agoMerge "res_pjsip: Add ability to identify by Authorization username" into 13
zuul [Thu, 28 Apr 2016 22:49:56 +0000 (17:49 -0500)] 
Merge "res_pjsip:  Add ability to identify by Authorization username" into 13

9 years agores_pjsip: Start body generator users after suppliers. 31/2731/1
Richard Mudgett [Thu, 28 Apr 2016 16:35:44 +0000 (11:35 -0500)] 
res_pjsip: Start body generator users after suppliers.

Change-Id: I8f0b57841feaab56c8a4e821b5ccb4e05e5fbadb

9 years agores_pjsip_pubsub.c: Add useful information to some messages. 29/2729/1
Richard Mudgett [Thu, 28 Apr 2016 21:06:57 +0000 (16:06 -0500)] 
res_pjsip_pubsub.c: Add useful information to some messages.

Change-Id: Ia0b2e15773894c599e5c5748bbc70e99f434192a

9 years agores_pjsip_pubsub.c: Fix body generator registration race. 27/2727/1
Richard Mudgett [Tue, 26 Apr 2016 20:58:06 +0000 (15:58 -0500)] 
res_pjsip_pubsub.c: Fix body generator registration race.

Change-Id: Id8752073ef06472a2fd96080f4009fac42843e67

9 years agores_pjsip_pubsub.h: Fix doxygen association. 23/2723/1
Richard Mudgett [Tue, 26 Apr 2016 20:13:50 +0000 (15:13 -0500)] 
res_pjsip_pubsub.h: Fix doxygen association.

Change-Id: I110d3e3572598289fcd4215d966cf0c858f98632

9 years agores_pjsip_outbound_publish.c: Remove redundant flag check. 21/2721/1
Richard Mudgett [Mon, 25 Apr 2016 21:00:30 +0000 (16:00 -0500)] 
res_pjsip_outbound_publish.c: Remove redundant flag check.

Change-Id: I0da80a3c3e0eae0c52ff27e7412ba027d6f52353

9 years agopjproject_bundled: Disable PJSIP_UNESCAPE_IN_PLACE 24/2724/1
George Joseph [Thu, 28 Apr 2016 21:54:07 +0000 (15:54 -0600)] 
pjproject_bundled:  Disable PJSIP_UNESCAPE_IN_PLACE

When pjsip_parse_uri is called with PJSIP_UNESCAPE_IN_PLACE enabled,
the input uri string will become corrupted if it contains escape sequences.
It's not possible to automatically strdup or strdupa the input string because
the output uri pj_str_t's will have pointers to chunks of the input string.
Getting around this would require more memory management code and wouldn't
be worth the savings of doing the unescape in place.

ASTERISK-25970 #close
Reported-by: Dmitriy Serov
Change-Id: I28dc0e599b5108f7959b9c46dc8278371b372f88

9 years agoMerge "func_odbc: Check connection status before executing queries." into 13
Joshua Colp [Thu, 28 Apr 2016 11:50:55 +0000 (06:50 -0500)] 
Merge "func_odbc: Check connection status before executing queries." into 13

9 years agores_pjsip: Add ability to identify by Authorization username 67/2367/18
George Joseph [Tue, 8 Mar 2016 00:34:31 +0000 (17:34 -0700)] 
res_pjsip:  Add ability to identify by Authorization username

A feature of chan_sip that service providers relied upon was the ability to
identify by the Authorization username.  This is most often used when customers
have a PBX that needs to register rather than identify by IP address.  From my
own experiance, this is pretty common with small businesses who otherwise
don't need a static IP.

In this scenario, a register from the customer's PBX may succeed because From
will usually contain the PBXs account id but an INVITE will contain the caller
id.  With nothing recognizable in From, the service provider's Asterisk can
never match to an endpoint and the INVITE just stays unauthorized.

The fixes:

A new value "auth_username" has been added to endpoint/identify_by that
will use the username and digest fields in the Authorization header
instead of username and domain in the the From header to match an endpoint,
or the To header to match an aor.  This code as added to
res_pjsip_endpoint_identifier_user rather than creating a new module.

Although identify_by was always a comma-separated list, there was only
1 choice so order wasn't preserved.  So to keep the order, a vector was added
to the end of ast_sip_endpoint.  This is only used by res_pjsip_registrar
to find the aor.  The res_pjsip_endpoint_identifier_* modules are called in
globals/endpoint_identifier_order.

Along the way, the logic in res_pjsip_registrar was corrected to match
most-specific to least-specific as res_pjsip_endpoint_identifier_user does.

The order is:

username@domain
username@domain_alias
username

Auth by username does present 1 problem however, the first INVITE won't have
an Authorization header so the distributor, not finding a match on anything,
sends a securty_alert.  It still sends a 401 with a challenge so the next
INVITE will have the Authorization header and presumably succeed.  As a result
though, that first security alert is actually a false alarm.

To address this, a new feature has been added to pjsip_distributor that keeps
track of unidentified requests and only sends the security alert if a
configurable number of unidentified requests come from the same IP in a
configurable amout of time.  Those configuration options have been added to
the global config object.  This feature is only used when auth_username
is enabled.

Finally, default_realm was added to the globals object to replace the hard
coded "asterisk" used when an endpoint is not yet identified.

The testsuite tests all pass but new tests are forthcoming for this new
feature.

ASTERISK-25835 #close
Reported-by: Ross Beer
Change-Id: I30ba62d208e6f63439600916fcd1c08a365ed69d

9 years agoMerge "config: Fix ast_config_text_file_save2 writability check for missing files...
Joshua Colp [Wed, 27 Apr 2016 21:20:31 +0000 (16:20 -0500)] 
Merge "config:  Fix ast_config_text_file_save2 writability check for missing files" into 13

9 years agoMerge "res_pjsip: disable multi domain to improve realtime performace" into 13
Joshua Colp [Wed, 27 Apr 2016 19:03:53 +0000 (14:03 -0500)] 
Merge "res_pjsip: disable multi domain to improve realtime performace" into 13

9 years agofunc_odbc: Check connection status before executing queries. 15/2715/1
Mark Michelson [Wed, 27 Apr 2016 18:23:37 +0000 (13:23 -0500)] 
func_odbc: Check connection status before executing queries.

A recent change to func_odbc made it so that a single connection was
maintained per DSN. The problem was that the code was optimistic about
the health of the connection after initially opening it and did nothing
to re-connect in case the connection had died.

This change adds a check before executing a query to ensure that the
connection to the database is still up and running.

ASTERISK-25963 #close
Reported by Ross Beer

Change-Id: Id33c86eb04ff48ca088bb2e3086c27b3b683491d

9 years agores_pjsip: disable multi domain to improve realtime performace 23/2623/3
Alexei Gradinari [Fri, 15 Apr 2016 16:59:42 +0000 (12:59 -0400)] 
res_pjsip: disable multi domain to improve realtime performace

This patch added new global pjsip option 'disable_multi_domain'.
Disabling Multi Domain can improve Realtime performance by reducing
number of database requests.

ASTERISK-25930 #close

Change-Id: I2e7160f3aae68475d52742107949a799aa2c7dc7

9 years agoMerge "res_pjsip: Add serialized scheduler (res_pjsip/pjsip_scheduler.c)" into 13
Joshua Colp [Wed, 27 Apr 2016 15:12:31 +0000 (10:12 -0500)] 
Merge "res_pjsip:  Add serialized scheduler (res_pjsip/pjsip_scheduler.c)" into 13

9 years agoMerge "chan_sip: Give more time for TCP/TLS threads to stop." into 13
zuul [Wed, 27 Apr 2016 13:50:35 +0000 (08:50 -0500)] 
Merge "chan_sip: Give more time for TCP/TLS threads to stop." into 13

9 years agochan_sip: Give more time for TCP/TLS threads to stop. 01/2701/4
Joshua Colp [Tue, 26 Apr 2016 16:13:14 +0000 (13:13 -0300)] 
chan_sip: Give more time for TCP/TLS threads to stop.

The unload process currently tells each TCP/TLS to terminate but
does not wait for them to do so. This introduces a race condition
where the container holding the threads may be destroyed before
the threads are able to remove themselves from it. When they
finally do the container is invalid and can't be used causing a
crash.

A previous change existed which waited a bit to wait for any
stranglers to finish. This change extends this and waits longer.

ASTERISK-25961 #close

Change-Id: Idc6262b670ca49ede32061159e323b7b63c6f3c6

9 years agoapp_queue: Fix crash when unloading module. 04/2704/2
Joshua Colp [Tue, 26 Apr 2016 10:48:40 +0000 (07:48 -0300)] 
app_queue: Fix crash when unloading module.

When unloading the app_queue module the members in each queue are
destroyed and as part of this they are removed from the pending
members container. Unfortunately a crash would occur as the container
was destroyed before the members were removed.

This change tweaks ordering so the container destruction occurs
after the members are destroyed.

ASTERISK-16115

Change-Id: I48c728668c55aee3d05b751a5d450fb57e87f44b

9 years agoMerge changes from topic 'system_stress_patches' into 13
Joshua Colp [Tue, 26 Apr 2016 09:57:07 +0000 (04:57 -0500)] 
Merge changes from topic 'system_stress_patches' into 13

* changes:
  test_message.c: Wait longer in case dialplan also processes the test message.
  Manager: Short circuit AMI message processing.
  manager.c: Eliminate most RAII_VAR usage.
  manager_channels.c: Fix allocation failure crash.

9 years agoMerge changes from topic 'system_stress_patches' into 13
Joshua Colp [Tue, 26 Apr 2016 09:56:36 +0000 (04:56 -0500)] 
Merge changes from topic 'system_stress_patches' into 13

* changes:
  Bridge system: Fix memory leaks and double frees on impart failure.
  bridge_softmix.c: Fix crash if channel fails to join mixing tech.

9 years agoconfig: Fix ast_config_text_file_save2 writability check for missing files 91/2691/4
George Joseph [Mon, 25 Apr 2016 03:51:16 +0000 (21:51 -0600)] 
config:  Fix ast_config_text_file_save2 writability check for missing files

A patch I did back in 2014 modified ast_config_text_file_save2 to check the
writability of the main file and include files before truncating and re-writing
them.  An unintended side-effect of this was that if a file doesn't exist,
the check fails and the write is aborted.

This patch causes ast_config_text_file_save2 to check the writability of the
parent directory of missing files instead of checking the file itself.  This
allows missing files to be created again.  A unit test was also added to
test_config to test saving of config files.

The regression was discovered when app_voicemail's passwordlocation=spooldir
feature stopped working.

ASTERISK-25917 #close
Reported-by: Jonathan Rose
Change-Id: Ic4dbe58c277a47b674679e49daed5fc6de349f80

9 years agoMerge "app_queue: queue members can receive multiple calls" into 13
Joshua Colp [Mon, 25 Apr 2016 22:47:02 +0000 (17:47 -0500)] 
Merge "app_queue: queue members can receive multiple calls" into 13

9 years agochan_sip: Make autocreated peers send PeerStatus events 03/2703/1
kkm [Fri, 22 Apr 2016 04:53:46 +0000 (21:53 -0700)] 
chan_sip: Make autocreated peers send PeerStatus events

Since Stasis has been introduced, an attempt to send AMI messages by an
autocreated peer caused a crash, and all events from autocreated peers were
semi-inadvertently disabled altogether in 0b83761. This change restores the
disabled functionality.

ASTERISK-25950

Change-Id: Iecc350f23db603fadb2f302064643ebe9664e974

9 years agoMerge "Fix case sensitive actions in AMI QueueSummary and QueueStatus" into 13
zuul [Mon, 25 Apr 2016 19:18:09 +0000 (14:18 -0500)] 
Merge "Fix case sensitive actions in AMI QueueSummary and QueueStatus" into 13

9 years agoapp_queue: queue members can receive multiple calls 77/2677/2
Kevin Harwell [Thu, 21 Apr 2016 19:23:21 +0000 (14:23 -0500)] 
app_queue: queue members can receive multiple calls

It was possible for a queue member that is a member of at least 2 or more
queues to receive mulitiple calls at the same time. This happened because
of a race between when a member was being rung and when the device state
notified the other queue(s) member object of the state change.

This patch makes it so when a queue member is being rung it gets added to
a global pool of queue members. If that same member is tried again, e.g.
from another queue, and it is found to already exist in the pending member
container then it will not ring that member.

ASTERISK-16115 #close

Change-Id: I546dd474776d158c2b6be44205353dee5bac7e48

9 years agoMerge "res_agi: Prevent run_agi from eating frames it shouldn't" into 13
zuul [Mon, 25 Apr 2016 16:49:18 +0000 (11:49 -0500)] 
Merge "res_agi:  Prevent run_agi from eating frames it shouldn't" into 13

9 years agoFix case sensitive actions in AMI QueueSummary and QueueStatus 96/2696/2
DarkS [Mon, 25 Apr 2016 13:11:31 +0000 (15:11 +0200)] 
Fix case sensitive actions in AMI QueueSummary and QueueStatus

ASTERISK-25954 #close
Reported by: Javier Acosta

Change-Id: I00be83d45cc7e8385de2523012bd196aafeeb256

9 years agores_agi: Prevent run_agi from eating frames it shouldn't 87/2687/3
George Joseph [Fri, 22 Apr 2016 22:53:23 +0000 (16:53 -0600)] 
res_agi:  Prevent run_agi from eating frames it shouldn't

The run_agi function is eating control frames when it shouldn't be. This is
causing issues when an AGI is run from CONNECTED_LINE_SEND_SUB in a blond
transfer.

Alice calls Bob. Bob attended transfers to Charlie but hangs up before Charlie
answers.

Alice gets the COLP UPDATE indicating Charlie but Charlie never gets an UPDATE
and is left thinking he's connected to Bob.

In this case, when CONNECTED_LINE_SEND_SUB runs on Alice's channel and it calls
an AGI, the extra eaten frames prevent CONNECTED_LINE_SEND_SUB from running on
Charlie's channel.

The fix was to accumulate deferrable frames in the "forever" loop instead of
dropping them, and re-queue them just before running the actual agi command
or exiting.

ASTERISK-25951 #close

Change-Id: I0f4bbfd72fc1126c2aaba41da3233a33d0433645

9 years agoMerge "func_odbc: Use one connection per DSN." into 13
zuul [Mon, 25 Apr 2016 01:14:32 +0000 (20:14 -0500)] 
Merge "func_odbc: Use one connection per DSN." into 13

9 years agoMerge "Remove reference to non-existent sip.conf option" into 13
zuul [Fri, 22 Apr 2016 23:55:42 +0000 (18:55 -0500)] 
Merge "Remove reference to non-existent sip.conf option" into 13

9 years agoMerge "res_stasis: Handle re-enter stasis bridge with swap channel." into 13
zuul [Fri, 22 Apr 2016 23:55:41 +0000 (18:55 -0500)] 
Merge "res_stasis: Handle re-enter stasis bridge with swap channel." into 13

9 years agoMerge "bridge: Hold off more than one imparting channel at a time." into 13
zuul [Fri, 22 Apr 2016 23:29:19 +0000 (18:29 -0500)] 
Merge "bridge: Hold off more than one imparting channel at a time." into 13

9 years agotest_message.c: Wait longer in case dialplan also processes the test message. 85/2685/1
Richard Mudgett [Fri, 22 Apr 2016 20:25:29 +0000 (15:25 -0500)] 
test_message.c: Wait longer in case dialplan also processes the test message.

Bumped the wait from 1 second to 5 seconds.  The test message was hitting my
default call handler and failing the test because it took longer.

Change-Id: I3a03737f25e92983de00548fcc7bbc50dd7544ba

9 years agoManager: Short circuit AMI message processing. 87/2587/2
Richard Mudgett [Tue, 12 Apr 2016 20:29:52 +0000 (15:29 -0500)] 
Manager: Short circuit AMI message processing.

Improve AMI message processing performance if there are no consumers
listening for the messages.  We now skip creating the AMI event message
text strings.

Change-Id: I7b22fc5ec4e500d00635c1a467aa8ea68a1bb2b3

9 years agomanager.c: Eliminate most RAII_VAR usage. 86/2586/2
Richard Mudgett [Wed, 13 Apr 2016 22:54:26 +0000 (17:54 -0500)] 
manager.c: Eliminate most RAII_VAR usage.

* Made ast_manager_event_blob_create() not allocate the ao2 event object
with a lock as it is not needed.

Change-Id: I8e11bfedd22c21316012e0b9dd79f5918f644b7c

9 years agomanager_channels.c: Fix allocation failure crash. 85/2585/2
Richard Mudgett [Wed, 13 Apr 2016 22:09:53 +0000 (17:09 -0500)] 
manager_channels.c: Fix allocation failure crash.

An earlier allocation failure failed to create a channel snapshot for the
AMI HangupRequest/SoftHangupRequest event which resulted in a crash in
channel_hangup_request_cb().  Where the stasis message gets generated
cannot tell if the NULL snapshot returned was because of an allocation
failure or the channel was a dummy channel.

* Made channel_hangup_request_cb() check if the channel blob has a
snapshot and exit if it doesn't.

* Eliminated the RAII_VAR usage in channel_hangup_request_cb().

Change-Id: I0b6a1c4e95cbb7d80b2a7054c6eadecc169dfd24

9 years agoBridge system: Fix memory leaks and double frees on impart failure. 84/2584/2
Richard Mudgett [Wed, 13 Apr 2016 18:50:04 +0000 (13:50 -0500)] 
Bridge system: Fix memory leaks and double frees on impart failure.

You cannot reference the passed in features struct after calling
ast_bridge_impart().  Even if the call fails.

Change-Id: I902b88ba0d5d39520e670fb635078a367268ea21

9 years agobridge_softmix.c: Fix crash if channel fails to join mixing tech. 83/2583/2
Richard Mudgett [Wed, 13 Apr 2016 18:20:23 +0000 (13:20 -0500)] 
bridge_softmix.c: Fix crash if channel fails to join mixing tech.

softmix_bridge_join() failed because of an allocation failure.  To address
this, the softmix bridge technology now checks if the channel failed to
join softmix successfully.  In addition, the bridge now begins the process
of kicking the channel out of the bridge so we don't have channels
partially in the bridge for very long.

* Fix the test_channel_feature_hooks.c unit tests.  The test channel must
have a valid codec to join the simple_bridge technology.  This patch makes
joining a bridge more strict by not allowing partially joined channels to
remain in the bridge.

Change-Id: I97e2ade6a2bcd1214f24fb839fda948825b61a2b

9 years agofunc_odbc: Use one connection per DSN. 82/2682/3
Mark Michelson [Fri, 22 Apr 2016 18:49:50 +0000 (13:49 -0500)] 
func_odbc: Use one connection per DSN.

res_odbc was changed in Asterisk 13.8.0 to remove connection management,
opting instead to let unixodbc maintain open connections and return
those to Asterisk as requested.

This was a boon for realtime, since it meant that multiple threads could
potentially run parallel queries since they could each be using their
own database connections.

However, on the user-facing side, func_odbc, there were some inherent
behaviors being relied on that no longer hold true after the change.
One such reported behavior was that MySQL's LAST_INSERTED_ID() works
per-connection. This means that if Asterisk uses separate connections
for every database operation, whereas before it used one connection for
everything, we have broken expectations and functionality.

The fix provided in this patch is to make func_odbc use a single
database connection per DSN. This way, user-facing database usage will
have the same behavior as it did pre-13.8.0. However, realtime, which is
the real workhorse of database interaction, will continue to let
unixodbc manage connections.

ASTERISK-25938 #close
Reported by Edwin Vandamme

Change-Id: Iac961fe79154c6211569afcdfec843c0c24c46dc

9 years agoRemove reference to non-existent sip.conf option 81/2681/2
Leif Madsen [Fri, 22 Apr 2016 18:02:53 +0000 (14:02 -0400)] 
Remove reference to non-existent sip.conf option

Option was removed in commit 7f883ef495b57ae9182e47213d01d5e8009dbf3f

ASTERISK-25927 #close

Change-Id: I92f9b0196d9fc41d1d58354c07340c465ef1fcf8

9 years agoMerge "res_pjsip_callerid: Clear out display name if id->name is not valid" into 13
Joshua Colp [Thu, 21 Apr 2016 21:25:00 +0000 (16:25 -0500)] 
Merge "res_pjsip_callerid:  Clear out display name if id->name is not valid" into 13

9 years agolock.c: Check *lt before dereferencing it 74/2674/1
Diederik de Groot [Thu, 21 Apr 2016 13:26:47 +0000 (15:26 +0200)] 
lock.c: Check *lt before dereferencing it

*lt is NULL if t->tracking == 0

ASTERISK-25948 #close

Change-Id: I4a81af28f9c82a74aa82413d772a7dc8fa6f45ba

9 years agores_stasis: Handle re-enter stasis bridge with swap channel. 60/2660/1
Richard Mudgett [Fri, 15 Apr 2016 19:36:59 +0000 (14:36 -0500)] 
res_stasis: Handle re-enter stasis bridge with swap channel.

We lose the fact that there is a swap channel if there is one.  We
currently wind up rejoining the stasis bridge as a normal join after the
swap channel has already been kicked from the bridge.

This patch preserves the swap channel so the AMI/ARI events can note that
the channel joining the bridge is swapping with another channel.  Another
benefit to swaqpping in one operation is if there are any channels that
get lonely (MOH, bridge playback, and bridge record channels).  The lonely
channels won't leave before the joining channel has a chance to come back
in under stasis if the swap channel is the only reason the lonely channels
are staying in the bridge.

ASTERISK-25947 #close
Reported by: Richard Mudgett

ASTERISK-24649
Reported by: John Bigelow

ASTERISK-24782
Reported by: John Bigelow

Change-Id: If37ea508831d1fed6dbfac2f191c638fc0a850ee

9 years agobridge: Hold off more than one imparting channel at a time. 59/2659/1
Richard Mudgett [Tue, 19 Apr 2016 21:58:32 +0000 (16:58 -0500)] 
bridge: Hold off more than one imparting channel at a time.

An earlier patch blocked the ast_bridge_impart() call until the channel
either entered the target bridge or it failed.  Unfortuantely, if the
target bridge is stasis and the imprted channel is not a stasis channel,
stasis bounces the channel out of the bridge to come back into the bridge
as a proper stasis channel.  When the channel is bounced out, that
released the block on ast_bridge_impart() to continue.  If the impart was
a result of a transfer, then it became a race to see if the swap channel
would get hung up before the imparted channel could come back into the
stasis bridge.  If the imparted channel won then everything is fine.  If
the swap channel gets hung up first then the transfer will fail because
the swap channel is leaving the bridge.

* Allow a chain of ast_bridge_impart()'s to happen before any are
unblocked to prevent the race condition described above.  When the channel
finally joins the bridge or completely fails to join the bridge then the
ast_bridge_impart() instances are unblocked.

ASTERISK-25947
Reported by: Richard Mudgett

ASTERISK-24649
Reported by: John Bigelow

ASTERISK-24782
Reported by: John Bigelow

Change-Id: I8fef369171f295f580024ab4971e95c799d0dde1

9 years agoMerge "pjproject: Add patch for removing strip of '[]' from header params" into 13
Joshua Colp [Wed, 20 Apr 2016 13:17:21 +0000 (08:17 -0500)] 
Merge "pjproject:  Add patch for removing strip of '[]' from header params" into 13

9 years agores_pjsip_callerid: Clear out display name if id->name is not valid 52/2652/1
George Joseph [Tue, 19 Apr 2016 22:52:15 +0000 (16:52 -0600)] 
res_pjsip_callerid:  Clear out display name if id->name is not valid

When create_new_id_hdr creates a new RPID or PAI header, it starts by cloning
the From header, then it overwrites the display name and uri from the channel's
connected.id.  If the connected.id.name wasn't valid, create_new_id_hdr was
leaving the display name from the From header in the new RPID or PAI header.
On an attended transfer where the originator had a caller id number set but not
a display name, the re-INVITE to the final transferee had the number of the
originator but the display name of the transferer.

Added a check to clear out the display name in the new header if
connected.id.name was invalid.

ASTERISK-25942 #close

Change-Id: I60b4bf7a7ece9b7425eba74151c0b4969cd2738b

9 years agoMerge "PJSIP: Remove PJSIP parsing functions from uri length validation." into 13
Joshua Colp [Tue, 19 Apr 2016 20:19:35 +0000 (15:19 -0500)] 
Merge "PJSIP: Remove PJSIP parsing functions from uri length validation." into 13

9 years agoapp_talkdetect: Make the module core supported. 49/2649/1
Joshua Colp [Tue, 19 Apr 2016 18:02:18 +0000 (15:02 -0300)] 
app_talkdetect: Make the module core supported.

This module is used as part of testsuite tests to confirm
stuff works. I'm accordingly marking it as core as it is
required by those tests.

Change-Id: I558e7af7679b22b8ed641d7dd37ee4ca35b11e88

9 years agoPJSIP: Remove PJSIP parsing functions from uri length validation. 37/2637/4
Mark Michelson [Mon, 18 Apr 2016 17:12:37 +0000 (12:12 -0500)] 
PJSIP: Remove PJSIP parsing functions from uri length validation.

The PJSIP parsing functions provide a nice concise way to check the
length of a hostname in a SIP URI. The problem is that in order to use
those parsing functions, it's required to use them from a thread that
has registered with PJLib.

On startup, when parsing AOR configuration, the permanent URI handler
may not be run from a PJLib-registered thread. Specifically, this could
happen when Asterisk was started in daemon mode rather than
console-mode. If PJProject were compiled with assertions enabled, then
this would cause Asterisk to crash on startup.

The solution presented here is to do our own parsing of the contact URI
in order to ensure that the hostname in the URI is not too long. The
parsing does not attempt to perform a full SIP URI parse/validation,
since the hostname in the URI is what is important.

ASTERISK-25928 #close
Reported by Joshua Colp

Change-Id: Ic3d6c20ff3502507c17244a8b7e2ca761dc7fb60

9 years agoMerge "app_queue: Frequent segfaults in function can_ring_entry()" into 13
Joshua Colp [Tue, 19 Apr 2016 14:49:11 +0000 (09:49 -0500)] 
Merge "app_queue: Frequent segfaults in function can_ring_entry()" into 13

9 years agoMerge "stasis_bridge.c: Update stasis bridge push diagnostic messages." into 13
Joshua Colp [Tue, 19 Apr 2016 14:42:50 +0000 (09:42 -0500)] 
Merge "stasis_bridge.c: Update stasis bridge push diagnostic messages." into 13

9 years agoMerge "res_pjsip_transport_management: Allow unload to occur." into 13
Joshua Colp [Tue, 19 Apr 2016 14:40:42 +0000 (09:40 -0500)] 
Merge "res_pjsip_transport_management: Allow unload to occur." into 13

9 years agoMerge "bridge_channel.c: Ignore role setup failure in channel push." into 13
Joshua Colp [Tue, 19 Apr 2016 14:37:30 +0000 (09:37 -0500)] 
Merge "bridge_channel.c: Ignore role setup failure in channel push." into 13

9 years agores_pjsip_registrar: Fix bad memory-ness with user_agent. 40/2640/2
Mark Michelson [Mon, 18 Apr 2016 22:00:42 +0000 (17:00 -0500)] 
res_pjsip_registrar: Fix bad memory-ness with user_agent.

Recent changes to the PJSIP registrar resulted in tests failing due to
missing AOR_CONTACT_ADDED test events. The reason for this was that the
user_agent string had junk values in it, resulting in being unable to
generate the event.

I'm going to be honest here, I have no idea why this was happening. Here
are the steps needed for the user_agent variable to get messed up:
* REGISTER is received
* First contact in the REGISTER results in a contact being removed
* Second contact in the REGISTER results in a contact being added
* The contact, AOR, expiration, and user agent all have to be passed as
  format parameters to the creation of a string. Any subset of those
  parameters would not be enough to cause the problem.

Looking into what was happening, the thing that struck me as odd was
that the user_agent variable was meant to be set to the value of the
User-Agent SIP header in the incoming REGISTER. However, when removing a
contact, the user_agent variable would be set (via ast_strdupa inside a
loop) to the stored contact's user_agent. This means that the
user_agent's value would be incorrect when attempting to process further
contacts in the incoming REGISTER.

The fix here is to use a different variable for the stored user agent
when removing a contact. Correcting the behavior to be correct also
means the memory usage is less weird, and the issue no longer occurs.

ASTERISK-25929 #close
Reported by Joshua Colp

Change-Id: I7cd24c86a38dec69ebcc94150614bc25f46b8c08

9 years agores_pjsip_transport_management: Allow unload to occur. 38/2638/2
Joshua Colp [Mon, 18 Apr 2016 18:41:34 +0000 (15:41 -0300)] 
res_pjsip_transport_management: Allow unload to occur.

At shutdown it is possible for modules to be unloaded that wouldn't
normally be unloaded. This allows the environment to be cleaned up.

The res_pjsip_transport_management module did not have the unload
logic in it to clean itself up causing the res_pjsip module to not
get unloaded. As a result the res_pjsip monitor thread kept going
processing traffic and timers when it shouldn't.

Change-Id: Ic8cadee131e3b2c436a81d3ae8bb5775999ae00a

9 years agobridge_channel.c: Ignore role setup failure in channel push. 27/2627/2
Richard Mudgett [Fri, 15 Apr 2016 16:41:49 +0000 (11:41 -0500)] 
bridge_channel.c: Ignore role setup failure in channel push.

We have to setup the channel roles after the bridge class push is called
because the bridge class push callback may have set roles on the incoming
channel.  Since we have already partially pushed the channel into the
bridge and reversing what we have already done could be problematic, the
only thing we can do is press on to complete pushing the channel into the
bridge.

* Ignore any channel role setup errors after pushing the channel into a
bridge.  The channel may behave incorrectly in the bridge but we can no
longer abort the push at this time.

Change-Id: I08a97082b729052ee65cdca6bb730cf1289ede00

9 years agochan_sip: Don't verify table if rtupdate=no 33/2633/2
Jaco Kroon [Sun, 17 Apr 2016 20:37:53 +0000 (22:37 +0200)] 
chan_sip: Don't verify table if rtupdate=no

If rtupdate=no do not verify sipregs/peers table has updatable fields.

ASTERISK-25934 #close

Change-Id: Iaa2c53037b93daccc7e7333c40d61861847b856d

9 years agoMerge "Codecs: strip codec name while parsing allow/disallow options" into 13
Joshua Colp [Mon, 18 Apr 2016 10:31:09 +0000 (05:31 -0500)] 
Merge "Codecs: strip codec name while parsing allow/disallow options" into 13

9 years agoapp_queue: Frequent segfaults in function can_ring_entry() 35/2635/1
ibercom [Mon, 18 Apr 2016 09:53:14 +0000 (11:53 +0200)] 
app_queue: Frequent segfaults in function can_ring_entry()

ASTERISK-25888 #close

Change-Id: I007a2f2dd99823e04fb5be3ff01f02b0a2956117

9 years agostasis_bridge.c: Update stasis bridge push diagnostic messages. 25/2625/2
Richard Mudgett [Fri, 15 Apr 2016 21:51:58 +0000 (16:51 -0500)] 
stasis_bridge.c: Update stasis bridge push diagnostic messages.

Change-Id: I195b14994c9dcccb9452491ca20a885d2a54605a

9 years agoMerge "app_voicemail/IMAP: function 'save_to_folder' creates wrong folder" into 13
Joshua Colp [Fri, 15 Apr 2016 18:21:21 +0000 (13:21 -0500)] 
Merge "app_voicemail/IMAP: function 'save_to_folder' creates wrong folder" into 13

9 years agotransport management: Register thread with PJProject. 11/2611/4
Mark Michelson [Thu, 14 Apr 2016 18:49:35 +0000 (13:49 -0500)] 
transport management: Register thread with PJProject.

The scheduler thread that kills idle TCP connections was not registering
with PJProject properly and causing assertions if PJProject was built in
debug mode.

This change registers the thread with PJProject the first time that the
scheduler callback executes.

AST-2016-005

Change-Id: I5f7a37e2c80726a99afe9dc2a4a69bdedf661283

9 years agores_pjsip: Add serialized scheduler (res_pjsip/pjsip_scheduler.c) 43/2443/8
George Joseph [Thu, 17 Mar 2016 17:28:26 +0000 (11:28 -0600)] 
res_pjsip:  Add serialized scheduler (res_pjsip/pjsip_scheduler.c)

There are several places that do scheduled tasks or periodic housecleaning,
each with its own implementation:

* res_pjsip_keepalive has a thread that sends keepalives.
* pjsip_distributor has a thread that cleans up expired unidentified requests.
* res_pjsip_registrar_expire has a thread that cleans up expired contacts.
* res_pjsip_pubsub uses ast_sched directly and then calls ast_sip_push_task.
* res_pjsip_sdp_rtp also uses ast_sched to send keepalives.

There are also places where we should be doing scheduled work but aren't.
A good example are the places we have sorcery observers to start registration
or qualify.  These don't work when changes are made to a backend database
without a pjsip reload.  We need to check periodically.

As a first step to solving these issues, a new ast_sip_sched facility has
been created.

ast_sip_sched wraps ast_sched but only uses ast_sched as a scheduled queue.
When a task is ready to run, ast_sip_task_pusk is called for it. This ensures
that the task is executed in a PJLIB registered thread and doesn't hold up the
ast_sched thread so it can immediately continue processing the queue.  The
serializer used by ast_sip_sched is one of your choosing or a random one from
the res_pjsip pool if you don't choose one.

Another feature is the ability to automatically clean up the task_data when the
task expires (if ever).  If it's an ao2 object, it will be dereferenced, if
it's a malloc'd object it will be freed.  This is selectable when the task is
scheduled.  Even if you choose to not auto dereference an ao2 task data object,
the scheduler itself maintains a reference to it while the task is under it's
control.  This prevents the data from disappearing out from under the task.

There are two scheduling models.

AST_SIP_SCHED_TASK_PERIODIC specifies that the invocations of the task occur at
the specific interval.  That is, every "interval" milliseconds, regardless of
how long the task takes.  If the task takes longer than the interval, it will
be scheduled at the next available multiple of interval.  For exmaple: If the
task has an interval of 60 secs and the task takes 70 secs (it better not),
the next invocation will happen at 120 seconds.

AST_SIP_SCHED_TASK_DELAY specifies that the next invocation of the task should
start "interval" milliseconds after the current invocation has finished.

Also, the same ast_sched facility for fixed or variable intervals exists.  The
task's return code in conjunction with the AST_SIP_SCHED_TASK_FIXED or
AST_SIP_SCHED_TASK_VARIABLE flags controls the next invocation start time.

One res_pjsip.h housekeeping change was made.  The pjsip header files were
added to the top.  There have been a few cases lately where I've needed
res_pjsip.h just for ast_sip calls and had compiles fail spectacularly because
I didn't add the pjsip header files to my source even though I never referenced
any pjsip calls.

Finally, a few new convenience APIs were added to astobj2 to make things a
little easier in the scheduler.  ao2_ref_and_lock() calls ao2_ref() and
ao2_lock() in one go.  ao2_unlock_and_unref() does the reverse. A few macros
were also copied from res_phoneprov because I got tired of having to duplicate
the same hash, sort and compare functions over and over again. The
AO2_STRING_FIELD_(HASH|SORT|CMP)_FN macros will insert functions suitable for
aor_container_alloc into your source.

This facility can be used immediately for the situations where we already have
a thread that wakes up periodically or do some scheduled work.  For the
registration and qualify issues, additional sorcery and schema changes would
need to be made so that we can easily detect changed objects on a periodic
basis without having to pull the entire database back to check.  I'm thinking
of a last-updated timestamp on the rows but more on this later.

Change-Id: I7af6ad2b2d896ea68e478aa1ae201d6dd016ba1c

9 years agoMerge "res_pjsip_transport_management: Kill idle TCP connections." into 13
Joshua Colp [Thu, 14 Apr 2016 18:02:47 +0000 (13:02 -0500)] 
Merge "res_pjsip_transport_management: Kill idle TCP connections." into 13

9 years agoMerge "Rename res_pjsip_keepalive res_pjsip_transport_management" into 13
Joshua Colp [Thu, 14 Apr 2016 18:01:13 +0000 (13:01 -0500)] 
Merge "Rename res_pjsip_keepalive res_pjsip_transport_management" into 13

9 years agoMerge "AST-2016-004: Fix crash on REGISTER with long URI." into 13
Joshua Colp [Thu, 14 Apr 2016 18:00:14 +0000 (13:00 -0500)] 
Merge "AST-2016-004: Fix crash on REGISTER with long URI." into 13

9 years agores_pjsip_transport_management: Kill idle TCP connections. 99/2599/2
Mark Michelson [Tue, 8 Mar 2016 18:12:16 +0000 (12:12 -0600)] 
res_pjsip_transport_management: Kill idle TCP connections.

"Idle" here means that someone connects to us and does not send a SIP
request. PJProject will not automatically time out such connections, so
it's up to Asterisk to do it instead.

When we receive an incoming TCP connection, we will start a timer
(equivalent to transaction timer D) waiting to receive an incoming
request. If we do not receive a request in that timeframe, then we will
shut down the TCP connection.

ASTERISK-25796 #close
Reported by George Joseph

AST-2016-005

Change-Id: I7b0d303e5d140d0ccaf2f7af562071e3d1130ac6

9 years agoRename res_pjsip_keepalive res_pjsip_transport_management 98/2598/1
Mark Michelson [Tue, 8 Mar 2016 16:52:19 +0000 (10:52 -0600)] 
Rename res_pjsip_keepalive res_pjsip_transport_management

ASTERISK-25796
Reported by George Joseph

AST-2016-005

Change-Id: Id322a05f927392293570599730050bc677d99433

9 years agoAST-2016-004: Fix crash on REGISTER with long URI. 95/2595/1
Mark Michelson [Thu, 14 Apr 2016 12:15:47 +0000 (07:15 -0500)] 
AST-2016-004: Fix crash on REGISTER with long URI.

Due to some ignored return values, Asterisk could crash if processing an
incoming REGISTER whose contact URI was above a certain length.

ASTERISK-25707 #close
Reported by George Joseph

Patches:
0001-res_pjsip-Validate-that-URIs-don-t-exceed-pjproject-.patch

AST-2016-004

Change-Id: I0ed3898fe7ab10121b76c8c79046692de3a1be55

9 years agobridge_softmix.c: Fix crash if could not allocate the dsp. 82/2582/1
Richard Mudgett [Tue, 12 Apr 2016 18:10:47 +0000 (13:10 -0500)] 
bridge_softmix.c: Fix crash if could not allocate the dsp.

Fix off nominal crash where we could not setup the channel to process
frames for the softmix bridge technology because of allocation failure.

Change-Id: Ic307a8386e46bf551e48fcd1eb97276714d56372

9 years agoMerge "app_voicemail: Fix test_voicemail_notify_endl test." into 13
Joshua Colp [Wed, 13 Apr 2016 10:20:22 +0000 (05:20 -0500)] 
Merge "app_voicemail: Fix test_voicemail_notify_endl test." into 13

9 years agopjproject: Add patch for removing strip of '[]' from header params 79/2579/1
George Joseph [Tue, 12 Apr 2016 20:41:43 +0000 (14:41 -0600)] 
pjproject:  Add patch for removing strip of '[]' from header params

From the patch submitted to Teluu on 4/12/2016
<<<<<<<<<
The wholesale stripping of '[]' from header parameters causes issues if
something (like a port) occurs after the final ']'.

'[2001:a::b]' will correctly parse to '2001:a::b'
'[2001:a::b]:8080' will correctly parse to '2001:a::b' but the scanner is left
with ':8080' and parsing stops with a syntax error.

I can't even find a case where stripping the '[]' is a good thing anyway.  Even
if you continued to parse and resulted in a string that looks like this...
'2001:a::b:8080', it's not valid.

This came up in Asterisk because Kamailio sends us a Contact with an alias
URI parameter that has an IPv6 address in it like this:
Contact: <sip:1171@127.0.0.1:5080;alias=[2001:1:2::3]~43691~6>
which should be legal but causes a syntax error because of the characters
after the final ']'.  Even if it didn't, the '[]' should still not be stripped.

I've run the Asterisk Test Suite for PJSIP (252 tests) many of which are IPv6
enabled.  No issues were caused by removing the code that strips the '[]'.
>>>>>>>>>>>

ASTERISK-25123 #close
Reported-by: Anthony Messina
Change-Id: I5cb33f4ebf07ee1f2b26d07caae715e2ec65595a

9 years agoMerge "res_pjsip_dialog_info: Add missing "direction" attribute in NOTIFY event"...
Joshua Colp [Tue, 12 Apr 2016 18:28:47 +0000 (13:28 -0500)] 
Merge "res_pjsip_dialog_info: Add missing "direction" attribute in NOTIFY event" into 13

9 years agoapp_voicemail: Fix test_voicemail_notify_endl test. 76/2576/1
Joshua Colp [Tue, 12 Apr 2016 14:10:45 +0000 (11:10 -0300)] 
app_voicemail: Fix test_voicemail_notify_endl test.

The test_voicemail_notify_endl test checks the end-of-line
characters of an email message to confirm that they are consistent.
The test wrongfully assumed that reading from the email message
into a buffer will always result in more than 1 character being
read. This is incorrect. If only 1 character was read the test
would go outside of the buffer and access other memory causing
a crash.

The test now checks to ensure that 2 or more characters are read
in ensuring the test stays within the buffer.

ASTERISK-25874 #close

Change-Id: Ic2c89cea6e90f2c0bc2d8138306ebbffd4f8b710

9 years agoMerge "res_pjsip: Add headers to AMI Event ContactStatusDetail" into 13
zuul [Tue, 12 Apr 2016 12:35:01 +0000 (07:35 -0500)] 
Merge "res_pjsip: Add headers to AMI Event ContactStatusDetail" into 13

9 years agoapp_voicemail/IMAP: function 'save_to_folder' creates wrong folder 48/2548/3
Alexei Gradinari [Thu, 7 Apr 2016 17:02:19 +0000 (13:02 -0400)] 
app_voicemail/IMAP: function 'save_to_folder' creates wrong folder

If try to move message to Cust1 (number 5)
the function 'save_to_folder' tries to create Greeting folder instead of Cust1.

This patch fixed it by setting GREETINGS_FOLDER = -1

ASTERISK-24927 #close

Change-Id: I03d1a761894bcc2d130ec9b003bbcddc28e25c51

9 years agores_pjsip: Add headers to AMI Event ContactStatusDetail 55/2555/4
Alexei Gradinari [Thu, 7 Apr 2016 21:18:03 +0000 (17:18 -0400)] 
res_pjsip: Add headers to AMI Event ContactStatusDetail

* Added Useragent and RegExpire headers to AMI Event
ContactStatusDetail with associated documentation.

ASTERISK-25903 #close

Change-Id: If3d121e943e588d016ba51d4eb9c6a421a562239

9 years agoMerge "res_pjsip_outbound_publish: Add transport for outbound PUBLISH" into 13
zuul [Tue, 12 Apr 2016 02:26:28 +0000 (21:26 -0500)] 
Merge "res_pjsip_outbound_publish: Add transport for outbound PUBLISH" into 13

9 years agoMerge "alembic: Remove batch operations (and sqlite support)" into 13
zuul [Tue, 12 Apr 2016 01:43:18 +0000 (20:43 -0500)] 
Merge "alembic:  Remove batch operations (and sqlite support)" into 13

9 years agoMerge "core_unreal: Fix hangupcauses not getting set on Local channels" into 13
Joshua Colp [Mon, 11 Apr 2016 23:02:42 +0000 (18:02 -0500)] 
Merge "core_unreal: Fix hangupcauses not getting set on Local channels" into 13

9 years agoMerge "res_pjsip contact: Lock expiration/addition of contacts" into 13
zuul [Mon, 11 Apr 2016 21:29:38 +0000 (16:29 -0500)] 
Merge "res_pjsip contact:  Lock expiration/addition of contacts" into 13

9 years agoCodecs: strip codec name while parsing allow/disallow options 72/2572/1
Alexei Gradinari [Mon, 11 Apr 2016 21:20:49 +0000 (17:20 -0400)] 
Codecs: strip codec name while parsing allow/disallow options

Failed registration using PJSIP/Realtime if one of the codec name
in allow/disallow option is wrong or contains space.

This patch strip codec name.

ASTERISK-25914

Change-Id: Ifdf02de94e5ddbce305640f6f0666084a3b9283d

9 years agocore_unreal: Fix hangupcauses not getting set on Local channels 70/2570/2
Jaco Kroon [Mon, 11 Apr 2016 19:26:57 +0000 (21:26 +0200)] 
core_unreal: Fix hangupcauses not getting set on Local channels

ASTERISK-25912 #close

Change-Id: I8e72e6894feaf36c9450f2788d205d07baec23aa

9 years agoMerge "app_voicemail/IMAP: IMAP access FATAL error: Out of memory" into 13
zuul [Mon, 11 Apr 2016 19:10:51 +0000 (14:10 -0500)] 
Merge "app_voicemail/IMAP: IMAP access FATAL error: Out of memory" into 13

9 years agores_pjsip contact: Lock expiration/addition of contacts 25/2525/5
George Joseph [Fri, 1 Apr 2016 18:30:56 +0000 (12:30 -0600)] 
res_pjsip contact:  Lock expiration/addition of contacts

Contact expiration can occur in several places:  res_pjsip_registrar,
res_pjsip_registrar_expire, and automatically when anyone calls
ast_sip_location_retrieve_aor_contact.  At the same time, res_pjsip_registrar
may also be attempting to renew or add a contact.  Since none of this was locked
it was possible for one thread to be renewing a contact and another thread to
expire it immediately because it was working off of stale data.  This was the
casue of intermittent registration/inbound/nominal/multiple_contacts test
failures.

Now, the new named lock functionality is used to lock the aor during contact
expire and add operations and res_pjsip_registrar_expire now checks the
expiration with the lock held before deleting the contact.

ASTERISK-25885 #close
Reported-by: Josh Colp
Change-Id: I83d413c46a47796f3ab052ca3b349f21cca47059

9 years agoMerge "lock: Add named lock capability" into 13
zuul [Mon, 11 Apr 2016 17:56:40 +0000 (12:56 -0500)] 
Merge "lock:  Add named lock capability" into 13

9 years agopjproject: Add patch to fix Via IPv6 parsing 66/2566/1
George Joseph [Sun, 10 Apr 2016 19:16:42 +0000 (13:16 -0600)] 
pjproject:  Add patch to fix Via IPv6 parsing

There's a bug in pjproject's sip_parser where the ":" wasn't correctly
interpreted. This is causing IPv6 addresses in the "received" parameter of the
Via header to cause a syntax check failure.

This patch was submitted to Teluu on 4/10/2016.

ASTERISK-25910 #close
Reported-by: Anthony Messina
Change-Id: Ic7e4c4aa14ded61860401ec349f5177568c4d922

9 years agolock: Add named lock capability 21/2521/11
George Joseph [Fri, 1 Apr 2016 01:04:29 +0000 (19:04 -0600)] 
lock:  Add named lock capability

Locking some objects like sorcery objects can be tricky because the underlying
ao2 object may not be the same for all callers.  For instance, two threads that
call ast_sorcery_retrieve_by_id on the same aor name might actually get 2
different ao2 objects if the underlying wizard had to rehydrate the aor from a
database. Locking one ao2 object doesn't have any effect on the other even if
those objects had locks in the first place.

Named locks allow access control by keyspace and key strings.  Now an "aor"
named "1000" can be locked and any other thread attempting to lock "aor" "1000"
will wait regardless of whether the underlying ao2 object is the same or not.
Mutex and rwlocks are supported.

This capability will initially be used to lock an aor when multiple threads may
be attempting to prune expired contacts from it.

Change-Id: If258c0b7f92b02d07243ce70e535821a1ea7fb45

9 years agores_pjsip_outbound_publish: Add transport for outbound PUBLISH 37/2537/6
Alexei Gradinari [Tue, 5 Apr 2016 21:56:39 +0000 (17:56 -0400)] 
res_pjsip_outbound_publish: Add transport for outbound PUBLISH

The first available transport of the appropriate type is used now.
This patch adds new config option 'transport' for outbound-publish.
If transport is set then outbound PUBLISH requests will use this transport.

ASTERISK-25901 #close

Change-Id: Ib389130489b70e36795b0003fa5fd386e2680151

9 years agoMerge "pbx.c: Minor code rearangements." into 13
zuul [Fri, 8 Apr 2016 16:18:33 +0000 (11:18 -0500)] 
Merge "pbx.c: Minor code rearangements." into 13

9 years agores_pjsip_dialog_info: Add missing "direction" attribute in NOTIFY event 57/2557/2
Alexei Gradinari [Thu, 7 Apr 2016 21:39:19 +0000 (17:39 -0400)] 
res_pjsip_dialog_info: Add missing "direction" attribute in NOTIFY event

BLF pickup isn't working on Cisco SPA and Snom phones
if the direction="recipient" attribute is missing in 'dialog' tag.

This patch adds direction="recipient" if extension state is
Ringing.

ASTERISK-24601 #close

Change-Id: I5b2c097ca29fd59e92ba237ca5d397cb1b0bcd8c

9 years agopbx.c: Minor code rearangements. 58/2558/1
Richard Mudgett [Thu, 7 Apr 2016 15:59:13 +0000 (10:59 -0500)] 
pbx.c: Minor code rearangements.

* Pull out a loop invariant.

* Convert an else-if ladder to a switch statement.

Change-Id: I0a95cfa9474a4600b9865f7b444534d275b37e95

9 years agoapp_voicemail/IMAP: IMAP access FATAL error: Out of memory 45/2545/4
Alexei Gradinari [Thu, 7 Apr 2016 16:37:43 +0000 (12:37 -0400)] 
app_voicemail/IMAP: IMAP access FATAL error: Out of memory

Sometimes uw-imap function 'mail_fetchbody' returns huge len
which then pass to uw-imap function 'rfc822_base64'.
uw-imap tries to allocate huge memory and abort() on fail.

This patch check the len.
If the len more than max size (128 Mbytes) log error.
This patch also set variables len, newlen to avoid uninizialezed len.
This patch also check pointer returned by rfc822_base64.

ASTERISK-25899 #close

Change-Id: I4a0e7d655f11abef6a5224e2169df6d5c1f1caca