summaryrefslogtreecommitdiff
path: root/res
AgeCommit message (Collapse)Author
2015-10-06res/res_rtp_asterisk: Fix assignment after ao2 decrementMatt Jordan
When we decide we will no longer schedule an RTCP write, we remove the reference to the RTP instance, then assign -1 to the stored scheduler ID in case something else comes along and wants to see if anything is scheduled. That scheduler ID is on the RTP instance. After 60a9172d7ef2 was merged to fix the regression introduced by 3cf0f29310, this improper assignment on a potentially destroyed object started getting tripped on the build agents. Frankly, this should have been crashing a lot more often earlier. I can only assume that the timing was changed just enough by both changes to start actually hitting this problem. As it is, simply moving the assignment prior to the ao2 deference is sufficient to keep the RTP instance from being referenced when it is very, truly, aboslutely dead. (Note that it is still good practice to assign -1 to the scheduler ID when we know we won't be scheduling it again, as the ao2 deref *may* not always destroy the ao2 object.) ASTERISK-25449 Change-Id: Ie6d3cb4adc7b1a6c078b1c38c19fc84cf787cda7
2015-10-06Fix improper usage of scheduler exposed by 5c713fdf18fMatt Jordan
When 5c713fdf18f was merged, it allowed for scheduled items to have an ID of '0' returned. While this was valid per the documentation for the API, it was apparently never returned previously. As a result, several users of the scheduler API viewed the result as being invalid, causing them to reschedule already scheduled items or otherwise fail in interesting ways. This patch corrects the users such that they view '0' as valid, and a returned ID of -1 as being invalid. Note that the failing HEP RTCP tests now pass with this patch. These tests failed due to a duplicate scheduling of the RTCP transmissions. ASTERISK-25449 #close Change-Id: I019a9aa8b6997584f66876331675981ac9e07e39
2015-10-01res_sorcery_memory_cache.c: Fix deadlock with scheduler.Richard Mudgett
A deadlock can happen when a sorcery object is being expired from the memory cache when at the same time another object is being placed into the memory cache. There are a couple other variations on this theme that could cause the deadlock. Basically if an object is being expired from the sorcery memory cache at the same time as another thread tries to update the next object expiration timer the deadlock can happen. * Add a deadlock avoidance loop in expire_objects_from_cache() to check if someone is trying to remove the scheduler callback from the scheduler. ASTERISK-25441 #close Change-Id: Iec7b0bdb81a72b39477727b1535b2539ad0cf4dc
2015-10-01res_sorcery_memory_cache.c: Replace inline code with function.Richard Mudgett
Make sorcery_memory_cache_close() call remove_all_from_cache() instead of partially inlining it. ASTERISK-25441 Change-Id: I1aa6cb425b1a4307096f3f914d17af8ec179a74c
2015-10-01res_sorcery_memory_cache.c: Shutdown in a less crash potential order.Richard Mudgett
Basically you should shutdown in the opposite order of how you setup since later setup pieces likely depend on earlier setup pieces. e.g., Registering your external API with the rest of the system should be the last thing setup and the first thing unregistered during shutdown. Change-Id: I5715765b723100c8d3c2642e9e72cc7ad5ad115e
2015-10-01res_sorcery_memory_cache.c: Misc tweaks.Richard Mudgett
Change-Id: I8cd32dffbb4f33bb0c39518d6e4c991e73573160
2015-10-01res_sorcery_memory_cache.c: Made use OBJ_SEARCH_MASK.Richard Mudgett
Change-Id: Ibca6574dc3c213b29cc93486e01ccd51f5caa46c
2015-09-30res_rtp_asterisk: Move "Set role" warning to be debug.Joshua Colp
In practice the set_role API callback can be invoked even when no ICE is present on an RTP instance. This can occur if ICE has not been enabled on it. ASTERISK-25438 #close Change-Id: I0e17e4316f0f0d7f095c78c3d4fd73a913b6ba69
2015-09-29res/ari/config.c: Fix user sort compare function.Richard Mudgett
Made use the ao2 sort compare template function and OBJ_SEARCH_xxx identifiers. Change-Id: Ic53005dc5aafa7a36c72300dd89b75fb63c92f4c
2015-09-29res/ari/config.c: Optimize conf_alloc() object init.Richard Mudgett
* Now conf_alloc() has more off nominal error checking. * Eliminated RAII_VAR() use in conf_alloc(). * Eliminated a dubius shortcut when destroying cfg->general in conf_destructor() that would cause a crash if cfg->general failed to get allocated. * Add some ACO registration section comments. Change-Id: Ia40c2b1b2d0777d641605118ae019c5a73865e1a
2015-09-29res/ari/config.c: Fix conf_alloc() object init.Richard Mudgett
Need to finish initializing the string fields in the ao2 object before putting any default strings into them. ASTERISK-25383 #close Reported by: yaron nahum Change-Id: I9f7f3a03f0c4991a01593abf8697b9a587c0ea84
2015-09-27res/res_stasis: Fix accidental subscription to 'all' bridge topicMatt Jordan
When b99a7052621700a1aa641a1c24308f5873275fc8 was merged, subscribing to a NULL bridge will now cause app_subscribe_bridge to implicitly subscribe to all bridges. Unfortunately, the res_stasis control loop did not check that a bridge changing on a channel's control object was actually also non-NULL. As a result, app_subscribe_bridge will be called with a NULL bridge when a channel leaves a bridge. This causes a new subscription to be made to the bridge. If an application has also subscribed to the bridge, the application will now have two subscriptions: (1) The explicit one created by the app (2) The implicit one accidentally created by the control structure As a result, the 'BridgeDestroyed' event can be sent multiple times. This patch corrects the control loop such that it only subscribes an application to a new bridge if the bridge pointer is non-NULL. ASTERISK-24870 Change-Id: I3510e55f6bc36517c10597ead857b964463c9f4f
2015-09-22ARI: Add events for Contact and Peer Status changesMatt Jordan
This patch adds support for receiving events regarding Peer status changes and Contact status changes. This is particularly useful in scenarios where we are subscribed to all endpoints and channels, where we often want to know more about the state of channel technology specific items than a single endpoint's state. ASTERISK-24870 Change-Id: I6137459cdc25ce27efc134ad58abf065653da4e9
2015-09-22res/res_stasis_device_state: Allow for subscribing to 'all' device stateMatt Jordan
This patch adds support for subscribing to all device state changes. This is done either by subscribing to an empty device, e.g., 'eventSource=deviceState:', or by the WebSocket connection specifying that it wants all state in the system. ASTERISK-24870 Change-Id: I9cfeca1c9e2231bd7ea73e45919111d44d2eda32
2015-09-22ARI: Add the ability to subscribe to all eventsMatt Jordan
This patch adds the ability to subscribe to all events. There are two possible ways to accomplish this: (1) On initial WebSocket connection. This patch adds a new query parameter, 'subscribeAll'. If present and True, Asterisk will subscribe the applications to all ARI events. (2) Via the applications resource. When subscribing in this manner, an ARI client should merely specify a blank resource name, i.e., 'channels:' instead of 'channels:12354'. This will subscribe the application to all resources of the 'channels' type. ASTERISK-24870 #close Change-Id: I4a943b4db24442cf28bc64b24bfd541249790ad6
2015-09-19Merge "CHAOS: res_pjsip_diversion avoid crash if allocation fails" into 13Matt Jordan
2015-09-18CHAOS: avoid crash if string create failsScott Griepentrog
Validate string buffer allocation before using them. ASTERISK-25323 Change-Id: Ib9c338bdc1e53fb8b81366f0b39482b83ef56ce0
2015-09-17CHAOS: res_pjsip_diversion avoid crash if allocation failsRichard Mudgett
Validate ast_malloc buffer returned before using it in set_redirecting_value(). ASTERISK-25323 Change-Id: I15d2ed7cb0546818264c0bf251aa40adeae83253
2015-09-17res_pjsip_pubsub: Eliminate race during initial NOTIFY.Mark Michelson
There is a slim chance of a race condition occurring where two threads can both attempt to manipulate the same area. Thread A can be handling an incoming initial SUBSCRIBE request. Thread A lets the specific subscription handler know that the subscription has been established. At this point, Thread B may detect a state change on the subscribed resource and queue up a notification task on Thread C, the subscription serializer thread. Now Thread A attempts to generate the initial NOTIFY request to send to the subscriber at the same time that Thread C attempts to generate a state change NOTIFY request to send to the subscriber. The result is that Threads A and C can step on the same memory area, resulting in a crash. The crash has been observed as happening when attempting to allocate more space to hold the body for the NOTIFY. The solution presented here is to queue the subscription establishment and initial NOTIFY generation onto the subscription serializer thread (Thread C in the above scenario). This way, there is no way that a state change notification can occur before the initial NOTIFY is sent, and if there is a quick succession of NOTIFYs, we can guarantee that the two NOTIFY requests will be sent in succession. Change-Id: I5a89a77b5f2717928c54d6efb9955e5f6f5cf815
2015-09-11Merge "res/res_pjsip_nat: Ignore REGISTER requests when looking for a ↵Matt Jordan
Record-Route" into 13
2015-09-10res_pjsip_pubsub.c: Mark ast_sip_create_subscription() as not used.Richard Mudgett
Change-Id: I2b8db18eac36c01a5c7eb9467699124e203fd093
2015-09-10res_pjsip_pubsub.c: Add some notification comments.Richard Mudgett
Change-Id: Ie62ff1f4b7adc1a12fa0303f53926af249b25e20
2015-09-10res_pjsip_pubsub.c: Set dlg_status code instead of sending SIP response.Richard Mudgett
We should not try to send a SIP response message because we may be restoring a persistent subscription where we are not responding to a SIP request. Change-Id: Id89167ef90320c5563f37e632db0dda6cb9e7dec
2015-09-10res_pjsip_pubsub.c: Fix off-nominal memory leak.Richard Mudgett
Fix off-nominal visited vector leak in build_resource_tree(). Change-Id: If0399c7941c9c0b1038bcfb7b9a371760977831c
2015-09-10res_pjsip_pubsub.c: Fix one byte buffer overrun error.Richard Mudgett
ast_sip_pubsub_register_body_generator() did not account for the null terminator set by sprintf() in the allocated output buffer. Change-Id: I388688a132e479bca6ad1c19275eae0070969ae2
2015-09-10res_pjsip_pubsub.c: Use ast_alloca() instead of alloca().Richard Mudgett
Change-Id: Ia396096b4fedc2874649ca11137612c3f55e83e3
2015-09-10res_pjsip_pubsub.c: Add missing error return in load_module().Richard Mudgett
Change-Id: I15debd0f717f16ee2f78e7f56151c3b3b97b72fc
2015-09-10res_pjsip/location.c: Use the builtin ao2_callback() match function instead.Richard Mudgett
Change-Id: I364906d6d2bad3472929986704a0286b9a2cbe3f
2015-09-10res_pjsip: Copy default_from_user to avoid crash.Mark Michelson
The default_from_user retrieval function was pulling the default_from_user from the global configuration struct in an unsafe way. If using a database as a backend configuration store, the global configuration struct is short-lived, so grabbing a pointer from it results in referencing freed memory. The fix here is to copy the default_from_user value out of the global configuration struct. Thanks go to John Hardin for discovering this problem and proposing the patch on which this fix is based. ASTERISK-25390 #close Reported by Mark Michelson Change-Id: I6b96067a495c1259da768f4012d44e03e7c6148c
2015-09-10res/res_pjsip_nat: Ignore REGISTER requests when looking for a Record-RouteMatt Jordan
We will only rewrite the Contact header if there is no Record-Route header in the received request. If a malfunctioning proxy places a Record-Route header into a REGISTER request, we will decide that we shouldn't update the IP/port in the Contact header, and we will end up storing a contact with an AoR that contains the NAT'd IP address. While it is nice to have the proxy *not* send a Record-Route in a REGISTER request, it's also a good idea to not process the header in a non-dialog message. This patch updates the code to explicitly ignore the Record-Route header in REGISTER requests. ASTERISK-25387 #close Change-Id: I4bd3bcccc4003d460cc354d986b0dea2e433ef3f
2015-09-10Merge "ParkAndAnnounce: Add variable inheritance" into 13Joshua Colp
2015-09-09pjsip: avoid possible crash req_caps allocation failureScott Griepentrog
Make certain that the pjsip session has not failed to allocate the format capabilities structure, which can otherwise cause a crash when referenced. ASTERISK-25323 Change-Id: I602790ba12714741165e441cc64a3ecde4cb5750
2015-09-09Merge "res_pjsip: Use hash for contact object identity instead of Contact ↵Joshua Colp
URI." into 13
2015-09-08ParkAndAnnounce: Add variable inheritanceJonathan Rose
In Asterisk 11, the announcer channel would receive channel variables from the channel being parked by means of normal channel inheritance. This functionality was lost during the big res_parking project in Asterisk 12. This patch restores that functionality. ASTERISK-25369 #close Review: https://gerrit.asterisk.org/#/c/1180/ Change-Id: Ie47e618330114ad2ea91e2edcef1cb6f341eed6e
2015-09-08Merge "res_rtp_asterisk: Add more ICE debugging" into 13Matt Jordan
2015-09-08res_rtp_asterisk: Add more ICE debuggingDavid M. Lee
In working through a recent ICE negotiation bug, I found the debug logging in res_rtp_asterisk to be lacking. This patch adds a number of debug and warning statements that were helpful. Change-Id: I950c6d8f13a41f14b3d6334b4cafe7d4e997be80
2015-09-08Merge "res/res_pjsip: Purge contacts when an AoR is deleted" into 13Joshua Colp
2015-09-08res_pjsip: Use hash for contact object identity instead of Contact URI.Joshua Colp
In the wild it is possible for Contact URIs to be quite long as parameters can exist on them. This can present a problem when storing them in the AstDB as the URI is used as part of the object name and there is a fixed length limit for the AstDB. This will cause the contact to not get stored. This change uses the MD5 hash of the Contact URI as part of the object name instead. This has a fixed length which is guaranteed to not exceed the AstDB length limit. ASTERISK-25295 #close Change-Id: Ie8252a75331ca00b41b9f308f42cc1fbdf701a02
2015-09-07res/res_pjsip: Purge contacts when an AoR is deletedMatt Jordan
When an AoR is deleted by an external mechanism, such as through ARI, we currently do not remove dynamic contacts that were created for that AoR as a result of a received REGISTER request. As a result, re-creating the AoR will cause the dynamic contact to be interpreted as a persistent contact, leading to some rather strange state being created for the contacts/endpoints. This patch adds a sorcery observer for the 'aor' object. When a delete is issued on the underlying sorcery object, the observer is called, and all contacts created and persisted in sorcery for that AoR are also removed. Note that we don't want to perform this action when an AO2 object that is an AoR is destroyed, as the AoR can still exist in the backing storage (and we would thus be removing valid contacts from an AoR that still "exists".) ASTERISK-25381 #close Change-Id: I6697e51ef6b2858b5d63401f35dc378bb0f90328
2015-09-05Merge "res_pjsip: Change default from user value." into 13Joshua Colp
2015-09-05Merge "Fix when remote candidates exceed PJ_ICE_MAX_CAND" into 13Joshua Colp
2015-09-04Fix when remote candidates exceed PJ_ICE_MAX_CANDDavid M. Lee
We were passing the wrong count into pj_ice_sess_create_check_list(), causing the create to fail if we ever received more than PJ_ICE_MAX_CAND candidates. Change-Id: I0303d8e1ecb20a8de9fe629a3209d216c4028378
2015-09-04res_pjsip: Change default from user value.Mark Michelson
When Asterisk sends an outbound SIP request, if there is no direct reason to place a specific value for the username in the From header, Asterisk would generate a UUID. For example, this would happen when sending outbound OPTIONS requests when qualifying or when sending outbound INVITE requests when originating (if no explicit caller ID were provided). The issue is that some SIP providers reject these sorts of requests with a "Name too long" error response. This patch aims to fix this by changing the default outbound username in From headers to "asterisk". This value can be overridden by changing the default_from_user option in the global options if desired. ASTERISK-25377 #close Reported by Mark Michelson Change-Id: I6a4d34a56ff73ff4f661b0075aeba5461b7f3190
2015-09-04res/pjsip: Mark WSS transport as secureMartin Tomec
Pjsip is refusing to use unsecure transport with "sips" in url. WSS should be considered as secure transport. ASTERISK-24602 #comment Partially fixed by setting WSS as secure Change-Id: Iddac406c6deba6240c41a603b8859dfefe1a5353
2015-09-02res_pjsip: Fix contact refleak on stateful responses.Mark Michelson
When sending a stateful response, creation of the transaction can fail, most commonly because we are trying to create a transaction from a retransmitted request. When creation of the transaction fails, we end up leaking a reference to a contact that was bumped when the response was created. This patch adds the missing deref and fixes the reference leak. Change-Id: I2f97ad512aeb1b17e87ca29ae0abacb4d6395f07
2015-09-01res_pjsip_pubsub: re-re-fix persistent subscription storage.Mark Michelson
A recent change to res_pjsip_pubsub switched to using pjsip_msg_print as a means of writing an appropriate packet to persistent storage. While this partially solved the issue, it had its own problems. pjsip_msg_print will always add a Content-Length header to the message it prints. Frequent restarts of Asterisk can result in persistent subscriptions being written with five or more Content-Length headers. In addition, sometimes some apparent corruption of individual headers could be seen. This aims to fix the problem by not running a parsed message through an interpreter but rather by taking the raw message and saving it. The logic for what to save is going to be different depending on whether a SUBSCRIBE was received from the wire or if it was pulled from persistence. When receiving a packet from the wire, when using a streaming transport, the rdata->pkt_info.packet may contain multiple SIP messages or fragments. However, the rdata->msg_info.msg_buf will always contain the current SIP message to be processed. When pulling from persistence, though, the rdata->msg_info.msg_buf will be NULL since no transport actually handled the packet. However, since we know that we will always ever pull one SIP message from persistence, we are free to save directly from rdata->pkt_info.packet instead. ASTERISK-25365 #close Reported by Mark Michelson Change-Id: I33153b10d0b4dc8e3801aaaee2f48173b867855b
2015-08-28res_pjsip_sdp_rtp: Fix multiple keepalive scheduled items.Joshua Colp
The keepalive support in res_pjsip_sdp_rtp currently assumes that a stream will only be negotiated once. This is false. If the stream is replaced and later added back it can be negotiated again causing multiple keepalive scheduled items to exist. This change explicitly deletes the existing keepalive scheduled item before adding the new one. The res_pjsip_sdp_rtp module also does not stop RTP keepalives or timeout timer if the stream has been replaced. This change adds a callback to the session media interface to allow a media stream to be stopped without the resources being destroyed. This allows the scheduled items and RTP to be stopped when the stream no longer exists. ASTERISK-25356 #close Change-Id: Ibe6a7cc0927c87326fd5f1c0d4ad889dbfbea1de
2015-08-28Merge "res_pjsip_session: Don't invoke session supplements twice for BYE ↵Mark Michelson
requests." into 13
2015-08-27Merge "res_pjsip: Add common ast_sip_get_host_ip API." into 13Joshua Colp
2015-08-27res_pjsip_session: Don't invoke session supplements twice for BYE requests.Joshua Colp
When a BYE request is received the PJSIP invite session implementation creates and sends a 200 OK response before we are aware of it. This causes the INVITE session state callback to be called into and ultimately the session supplements run on the BYE request. Once this response has been sent the normal transaction state callback is invoked which invokes the session supplements on the BYE request again. This can be problematic in particular with res_pjsip_rfc3326 as it may attempt to update the hangup cause code on the channel while it is in the process of being hung up. This change makes it so the session supplements are only invoked once by the INVITE session state callback. ASTERISK-25318 #close Change-Id: I69c17df55ccbb61ef779ac38cc8c6b411376c19a