summaryrefslogtreecommitdiff
path: root/res/res_pjsip_mwi.c
AgeCommit message (Collapse)Author
2017-06-22Merge "res_pjsip_mwi: update unsolicited MWI subscriptions on updating contact"Jenkins2
2017-06-21res_pjsip_mwi.c: Eliminate RAII_VAR in contact delete observerRichard Mudgett
Change-Id: I0bc97c6608de1d1a4228826b3b3be43f162f05f3
2017-06-21res_pjsip_mwi: update unsolicited MWI subscriptions on updating contactAlexei Gradinari
Do not need to unsubscribe/subscribe on creating the ednpoint's contact. The modified function create_mwi_subscriptions_for_endpoint adds the subscription only if it does not exist. The subscriptions aren't added for active contacts which are retrieved on startup from realtime if mwi_disable_initial_unsolicited=yes. Because the mwi_contact_added is not called. So the subscriptions also should be created on updating contact. ASTERISK-26230 #close Change-Id: I47e265af9296ca09aa42a316fdacac104148cee4
2017-06-16res_pjsip_mwi: unsubscribe unsolicited MWI on deleting endpoint last contactAlexei Gradinari
If the endpoint's last contact is deleted unsolicited MWI has to be unsubscribed. ASTERISK-27051 #close Change-Id: I33e174e0b9dba0998927d16d6d100fda5c7254e0
2017-06-13res_pjsip_mwi: don't create mwi subscriptions if initial unsolicited disabledAlexei Gradinari
If sending unsolicited mwi to all endpoints on startup is disabled (mwi_disable_initial_unsolicited=yes) do not need to create subscriptions. If there are many (thousands) realtime endpoints configured with unsolicited mwi and Vociemail Storage configured as ODBC or IMAP there will be huge number of DB/IMAP requests on startup. ASTERISK-26230 #close Change-Id: I50ae909639e3ee298b931a54def4b2b9e0fb86c5
2017-02-06res_pjsip: Fix some off nominal tdata leaks.Richard Mudgett
Change-Id: I243a4be5e7fbfe604923764969c4ee04eee89b9d
2016-08-11res_pjsip res_pjsip_mwi: Misc fixes and cleanups.Richard Mudgett
* Eliminated RAII_VAR() usage in ast_sip_persistent_endpoint_update_state(). * Added a missing allocation failure check to persistent_endpoint_find_or_create(). * Made persistent_endpoint_find_or_create() create the new object without a lock as it isn't needed. * Cleaned up some ao2 container allocation idioms. * Reordered res_pjsip_mwi.c load_module() and unload_module() Change-Id: If8ce88fbd82a0c72a37a2388f74f77237a6a36a8
2016-08-08res_pjsip_mwi: fix unsolicited mwi blocks PJSIP stackAlexei Gradinari
The PJSIP taskprocessors could be overflowed on startup if there are many (thousands) realtime endpoints configured with unsolicited mwi. The PJSIP stack could be totally unresponsive for a few minutes after boot completed. This patch creates a separate PJSIP serializers pool for mwi and makes unsolicited mwi use serializers from this pool. This patch also adds 2 new global options to tune taskprocessor alert levels: 'mwi_tps_queue_high' and 'mwi_tps_queue_low'. This patch also adds new global option 'mwi_disable_initial_unsolicited' to disable sending unsolicited mwi to all endpoints on startup. If disabled then unsolicited mwi will start processing on next endpoint's contact update. ASTERISK-26230 #close Change-Id: I4c8ecb82c249eb887930980a800c9f87f28f861a
2016-07-18res_pjsip_mwi: remove unneeded check on endpoint's contacts.Alexei Gradinari
The function create_mwi_subscriptions_for_endpoint checks if there is active contacts by retrieving aors and contacts. This function is used to create all unsolicited mwi subscriptions on startup and is used when contact added. In both cases it's not necessary to check if there are contacts. The contacts are needed when asterisk sends mwi. ASTERISK-26200 #close Change-Id: I98e43bdc97f3c0829951cd9bf5f3c6348c6ac1fa
2016-04-28res_pjsip: Start body generator users after suppliers.Richard Mudgett
Change-Id: I8f0b57841feaab56c8a4e821b5ccb4e05e5fbadb
2016-04-04res_pjsip_mwi: Fix segv caused by 16c7d8e74a9af13f98c3c22aa9c43ce39965f6b7George Joseph
I forgot the new voicemail_extension wasn't a stringfield and didn't check for NULL where I should have. Change-Id: I029482d5c2ab72474838750461bd46b0809c90fb
2016-03-30res_pjsip_mwi: Allow subscribe to vm access extension as an aliasGeorge Joseph
Background: If your extension is 1000 and the voicemail access extension is 1571 and you dial 1571, usually a dialplan rule calls voicemailmain with your extension and you are placed directly in your mailbox. Therefore most admins program the voicemail (or other speed dial) button on their phones to the access extension. Some phones (Snom at least) use whatever is programmed there to also subscribe for MWI and so can't dial one number and subscribe to another. This works fine in chan_sip because chan_sip completely ignores the user portion of the SUBSCRIBE message request URI. If it can match the peer, is subscribes to the peer's mailbox. The user could be set to anything or nothing and you'd still get subscribed to your mailbox. Issue: chan_pjsip actually uses the user portion of the URI to find an aor and its mailboxes. Therefore a subscribe to 1571 results in a 404. Sure, you can create an aor for 1571 but you certainly can't add your entire voicemail system's mailboxes to it and everyone would get notified of every MWI. Solution: When an MWI subscribe comes in and an aor can't be found that matches the resource directly, check the resource against the endpoint's aors. If an aor is found that has a voicemail_extension that matches the resource, use it. ASTERISK-25865 Reported-by: Ross Beer Change-Id: I770ea185f751f1ada888fafb4b452115f1c06e9e
2016-03-30res_pjsip_mwi: Add voicemail extension and mwi_subscribe_replaces_unsolicitedGeorge Joseph
res_pjsip_mwi was missing the chan_sip "vmexten" functionality which adds the Message-Account header to the MWI NOTIFY. Also, specifying mailboxes on endpoints for unsolicited mwi and on aors for subscriptions required that the admin know in advance which the client wanted. If you specified mailboxes on the endpoint, subscriptions were rejected even if you also specified mailboxes on the aor. Voicemail extension: * Added a global default_voicemail_extension which defaults to "". * Added voicemail_extension to both endpoint and aor. * Added ast_sip_subscription_get_dialog for support. * Added ast_sip_subscription_get_sip_uri for support. When an unsolicited NOTIFY is constructed, the From header is parsed, the voicemail extension from the endpoint is substituted for the user, and the result placed in the Message-Account field in the body. When a subscribed NOTIFY is constructed, the subscription dialog local uri is parsed, the voicemail_extension from the aor (looked up from the subscription resource name) is substituted for the user, and the result placed in the Message-Account field in the body. If no voicemail extension was defined, the Message-Account field is not added to the NOTIFY body. mwi_subscribe_replaces_unsolicited: * Added mwi_subscribe_replaces_unsolicited to endpoint. The previous behavior was to reject a subscribe if a previous internal subscription for unsolicited MWI was found for the mailbox. That remains the default. However, if there are mailboxes also set on the aor and the client subscribes and mwi_subscribe_replaces_unsolicited is set, the existing internal subscription is removed and replaced with the external subscription. This allows an admin to configure mailboxes on both the endpoint and aor and allows the client to select which to use. ASTERISK-25865 #close Reported-by: Ross Beer Change-Id: Ic15a9415091760539c7134a5ba3dc4a6a1217cea
2016-03-27sorcery/res_pjsip: Refactor for realtime performanceGeorge Joseph
There were a number of places in the res_pjsip stack that were getting all endpoints or all aors, and then filtering them locally. A good example is pjsip_options which, on startup, retrieves all endpoints, then the aors for those endpoints, then tests the aors to see if the qualify_frequency is > 0. One issue was that it never did anything with the endpoints other than retrieve the aors so we probably could have skipped a step and just retrieved all aors. But nevermind. This worked reasonably well with local config files but with a realtime backend and thousands of objects, this was a nightmare. The issue really boiled down to the fact that while realtime supports predicates that are passed to the database engine, the non-realtime sorcery backends didn't. They do now. The realtime engines have a scheme for doing simple comparisons. They take in an ast_variable (or list) for matching, and the name of each variable can contain an operator. For instance, a name of "qualify_frequency >" and a value of "0" would create a SQL predicate that looks like "where qualify_frequency > '0'". If there's no operator after the name, the engines add an '=' so a simple name of "qualify_frequency" and a value of "10" would return exact matches. The non-realtime backends decide whether to include an object in a result set by calling ast_sorcery_changeset_create on every object in the internal container. However, ast_sorcery_changeset_create only does exact string matches though so a name of "qualify_frequency >" and a value of "0" returns nothing because the literal "qualify_frequency >" doesn't match any name in the objset set. So, the real task was to create a generic string matcher that can take a left value, operator and a right value and perform the match. To that end, strings.c has a new ast_strings_match(left, operator, right) function. Left and right are the strings to operate on and the operator can be a string containing any of the following: = (or NULL or ""), !=, >, >=, <, <=, like or regex. If the operator is like or regex, the right string should be a %-pattern or a regex expression. If both left and right can be converted to float, then a numeric comparison is performed, otherwise a string comparison is performed. To use this new function on ast_variables, 2 new functions were added to config.c. One that compares 2 ast_variables, and one that compares 2 ast_variable lists. The former is useful when you want to compare 2 ast_variables that happen to be in a list but don't want to traverse the list. The latter will traverse the right list and return true if all the variables in it match the left list. Now, the backends' fields_cmp functions call ast_variable_lists_match instead of ast_sorcery_changeset_create and they can now process the same syntax as the realtime engines. The realtime backend just passes the variable list unaltered to the engine. The only gotcha is that there's no common realtime engine support for regex so that's been noted in the api docs for ast_sorcery_retrieve_by_fields. Only one more change to sorcery was done... A new config flag "allow_unqualified_fetch" was added to reg_sorcery_realtime. "no": ignore fetches if no predicate fields were supplied. "error": same as no but emit an error. (good for testing) "yes": allow (the default); "warn": allow but emit a warning. (good for testing) Now on to res_pjsip... pjsip_options was modified to retrieve aors with qualify_frequency > 0 rather than all endpoints then all aors. Not only was this a big improvement in realtime retrieval but even for config files there's an improvement because we're not going through endpoints anymore. res_pjsip_mwi was modified to retieve only endpoints with something in the mailboxes field instead of all endpoints then testing mailboxes. res_pjsip_registrar_expire was completely refactored. It was retrieving all contacts then setting up scheduler entries to check for expiration. Now, it's a single thread (like keepalive) that periodically retrieves only contacts whose expiration time is < now and deletes them. A new contact_expiration_check_interval was added to global with a default of 30 seconds. Ross Beer reports that with this patch, his Asterisk startup time dropped from around an hour to under 30 seconds. There are still objects that can't be filtered at the database like identifies, transports, and registrations. These are not going to be anywhere near as numerous as endpoints, aors, auths, contacts however. Back to allow_unqualified_fetch. If this is set to yes and you have a very large number of objects in the database, the pjsip CLI commands will attempt to retrive ALL of them if not qualified with a LIKE. Worse, if you type "pjsip show endpoint <tab>" guess what's going to happen? :) Having a cache helps but all the objects will have to be retrieved at least once to fill the cache. Setting allow_unqualified_fetch=no prevents the mass retrieve and should be used on endpoints, auths, aors, and contacts. It should NOT be used for identifies, registrations and transports since these MUST be retrieved in bulk. Example sorcery.conf: [res_pjsip] endpoint=config,pjsip.conf,criteria=type=endpoint endpoint=realtime,ps_endpoints,allow_unqualified_fetch=error ASTERISK-25826 #close Reported-by: Ross Beer Tested-by: Ross Beer Change-Id: Id2691e447db90892890036e663aaf907b2dc1c67
2016-03-07res_pjsip: Strip spaces from items parsed from comma-separated listsGeorge Joseph
Configurations like "aors = a, b, c" were either ignoring everything after "a" or trying to look up " b". Same for mailboxes, ciphers, contacts and a few others. To fix, all the strsep(&copy, ",") calls have been wrapped in ast_strip. To facilitate this, ast_strip, ast_skip_blanks and ast_skip_nonblanks were updated to handle null pointers. In some cases, an ast_strlen_zero() test was added to skip consecutive commas. There was also an attempt to ast_free an ast_strdupa'd string in ast_sip_for_each_aor which was causing a SEGV. I removed it. Although this issue was reported for realtime, the issue was in the res_pjsip modules so all config mechanisms were affected. ASTERISK-25829 #close Reported-by: Mateusz Kowalski Change-Id: I0b22a2cf22a7c1c50d4ecacbfa540155bec0e7a2
2016-02-27res_pjsip_mwi: Turn some NOTICEs and WARNINGs into debug 1s.George Joseph
There are a few cases where we're emitting notices or warnings for things that really need neither, like a client retrying to subscribe to mwi when they're not conifgured for it. They get a 404 so there's no need for non-debug messages. Change-Id: I05e38a7ff6c2f2521146f4be6a79731b9864e61f
2015-10-22res_pjsip_pubsub: Solidify lifetime and ownership of objects.Mark Michelson
There have been crashes and general instability seen in the pubsub code, so this patch introduces three changes to increase the stability. First, the ownership model for subscriptions has been modified. Due to RLS, subscriptions are stored in memory as a tree structure. Prior to my patch, the PJSIP subscription was the owner of the subscription tree. When the PJSIP subscription told us that it was terminating, we started destroying the subscription tree along with all of the individual leaf subscriptions that belong to the tree. The problem with this model is that the two actors in play here, the PJSIP subscription and the individual leaf subscriptions, need to have joint ownership of the subscription tree. So now, the PJSIP subscription and the individual leaf subscriptions each have a reference to the subscription tree. This way, we will not actually free memory until no players are left that care. The PJSIP subscription is a bigger stakeholder, in that if the PJSIP subscription's reference to the subscription tree is removed, the subscription tree instructs the leaf subscriptions to shut down and drop their references to the subscription tree when possible. The individual leaf subscriptions, upon being told to shut down, can drop their stasis subscriptions or whatever they use to learn of new state, and then drop their reference to the subscription tree once they are ready to die. Second, the lifetime of a PJSIP subscription's reference to our subscription tree has been altered. As I learned from doing a deep dive, the PJSIP evsub code can tell Asterisk multiple times that the subscription has been terminated, and not all of these times are especially helpful. I have altered the message flow that we use for SIP subscriptions such that we will always drop the PJSIP subscription's reference to the subscription tree when we send the NOTIFY that terminates a SIP subscription. This also means that we will now queue NOTIFY requests to be sent after responding to incoming SUBSCRIBEs so that we can have predictable state changes from the PJSIP evsub code. Third, the synchronization of operations has been improved. PJSIP can call into our code from a serializer thread (e.g. upon receiving an incoming request) or from the monitor thread (e.g. when a subscription times out). Because of this, there is the possibility of competing threads stepping on each other. PJSIP attempts to do some synchronization on its own by always keeping the dialog lock held when it calls into us. However, since we end up pushing tasks into the serializer, the result was that serialized operations were not grabbing the dialog lock and could, as a result, step on something that was being attempted by a different thread. Now we ensure that serialized operations grab the dialog lock, then check for extenuating circumstances, then proceed with their operation if they can. Change-Id: Iff2990c40178dad9cc5f6a5c7f76932ec644b2e5
2015-07-07Merge "res_pjsip_mwi.c: Use safer loop coding in ↵Matt Jordan
mwi_subscription_mailboxes_str()."
2015-07-07Merge "res_pjsip_mwi.c: Fix MWI subscription memory corruption crash."Matt Jordan
2015-07-06res_pjsip_mwi.c: Fix MWI subscription memory corruption crash.Richard Mudgett
MWI subscriptions can crash or corrupt memory when using the subscription datastore to access the MWI subscription object because the datastore is not holding a reference to the object. * Give the subscription datastore a ref to the MWI subscription object. It is unfortunate that the ref causes a circular ref chain that must be explicitly broken to allow the memory to get released. The loop is broken when the subscription is shutdown and if the subscription setup fails. ASTERISK-25168 #close Reported by: Carl Fortin Change-Id: Ice4fa823f138ff10a6c74d280699c41a82836d4f
2015-07-06res_pjsip_mwi.c: Use safer loop coding in mwi_subscription_mailboxes_str().Richard Mudgett
Change-Id: I6f39d809a6d1b47b35bb32b298f5a12f35d6f907
2015-07-06res_pjsip_mwi.c: Eliminate a simple RAII_VAR.Richard Mudgett
Change-Id: Ib1843f81e826a6c760c424c88eb70c350d9d61da
2015-07-06res_pjsip_mwi.c: Fix mid-line log message line breaks.Richard Mudgett
* Add create_mwi_subscriptions_for_endpoint() doxygen comment. Change-Id: I3c3f921f4ec749fb65b62d2f6fa0d4d1888b94e2
2015-06-23res_pjsip_mwi: Set up unsolicited MWI upon registration.Joshua Colp
The res_pjsip_mwi previously required a reload to set up the proper subscriptions to allow unsolicited MWI to work. This change makes it so the act of registering will also cause this to occur. This is particularly useful if realtime is involved as no reload needs to occur within Asterisk to cause the MWI information to get sent. ASTERISK-25180 #close Change-Id: Id847b47de4b8b3ab8858455ccc2f07b0f915f252
2015-05-22Stasis: Fix unsafe use of stasis_unsubscribe in modules.Corey Farrell
Many uses of stasis_unsubscribe in modules can be reached through unload. These have been switched to stasis_unsubscribe_and_join. Some subscription callbacks do nothing, for these I've created a noop callback function in stasis.c. This is used by some modules that monitor MWI topics in order to enable cache, since the callback does not become invalid after dlclose it is safe to use stasis_unsubscribe on these, even during module unload. ASTERISK-25121 #close Change-Id: Ifc2549fbd8eef7d703c222978e8f452e2972189c
2015-05-13AST_MODULE_INFO: Format corrections to the usages of AST_MODULE_INFO macro.Rodrigo Ramírez Norambuena
Change-Id: Icf88f9f861c6b2a16e5f626ff25795218a6f2723
2015-04-22res_pjsip_mwi: Send unsolicited MWI NOTIFY on startup and when endpoint ↵Joshua Colp
registers. Currently the res_pjsip_mwi module only sends an unsolicited MWI NOTIFY upon a mailbox state change (such as a new message being left, or one being deleted). In practice this is not sufficient to keep clients aware of the current MWI status. This change makes the module send unsolicited MWI NOTIFY on startup so that clients are guaranteed to have the most up to date MWI information. It also makes clients receive an unsolicited MWI NOTIFY upon registration so if they are unaware of the current MWI status they receive it. ASTERISK-24982 #close Reported by: Joshua Colp Change-Id: I043f20230227e91218f18a82c7d5bb2aa62b1d58
2015-01-23Investigate and fix memory leaks in AsteriskKevin Harwell
Fixed memory leaks that were found in Asterisk. ASTERISK-24693 #close Reported by: Kevin Harwell Review: https://reviewboard.asterisk.org/r/4347/ ........ Merged revisions 430999 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@431010 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-01-07res_pjsip_mwi: Change "MWI Subscription failed" message from warning to noticeGeorge Joseph
The "MWI Subscription failed" message means the client is trying to subscribe to a mailbox that doesn't exist. There's no need to clutter up logs with warnings for a client misconfiguration so I changed it to a notice. Tested-by: George Joseph Review: https://reviewboard.asterisk.org/r/4306/ ........ Merged revisions 430317 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@430318 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-01-06res_pjsip_mwi: Change warning to noticeGeorge Joseph
When res_pjsip loads and an endpoint auto-subscribes a mailbox for mwi, if a contact hasn't registered yet, res_pjsip_mwi spits out a warning. This is a perfectly normal situation though and doesn't require something as serious as a warning. It's also self correcting. The device will start getting mwi as soon as it registers. This patch changes the warning to a notice. Tested-by: George Joseph Review: https://reviewboard.asterisk.org/r/4314/ ........ Merged revisions 430227 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@430228 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-12-01main/stasis: Allow subscriptions to use a threadpool for message deliveryMatthew Jordan
Prior to this patch, all Stasis subscriptions would receive a dedicated thread for servicing published messages. In contrast, prior to r400178 (see review https://reviewboard.asterisk.org/r/2881/), the subscriptions shared a thread pool. It was discovered during some initial work on Stasis that, for a low subscription count with high message throughput, the threadpool was not as performant as simply having a dedicated thread per subscriber. For situations where a subscriber receives a substantial number of messages and is always present, the model of having a dedicated thread per subscriber makes sense. While we still have plenty of subscriptions that would follow this model, e.g., AMI, CDRs, CEL, etc., there are plenty that also fall into the following two categories: * Large number of subscriptions, specifically those tied to endpoints/peers. * Low number of messages. Some subscriptions exist specifically to coordinate a single message - the subscription is created, a message is published, the delivery is synchronized, and the subscription is destroyed. In both of the latter two cases, creating a dedicated thread is wasteful (and in the case of a large number of peers/endpoints, harmful). In those cases, having shared delivery threads is far more performant. This patch adds the ability of a subscriber to Stasis to choose whether or not their messages are dispatched on a dedicated thread or on a threadpool. The threadpool is configurable through stasis.conf. Review: https://reviewboard.asterisk.org/r/4193 ASTERISK-24533 #close Reported by: xrobau Tested by: xrobau ........ Merged revisions 428681 from http://svn.asterisk.org/svn/asterisk/branches/12 ........ Merged revisions 428687 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@428688 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-10-16PJSIP: Enforce module load dependenciesKinsey Moore
This enforces that res_pjsip, res_pjsip_session, and res_pjsip_pubsub have loaded properly before attempting to load any modules that depend on them since the module loader system is not currently capable of resolving module dependencies on its own. ASTERISK-24312 #close Reported by: Dafi Ni Review: https://reviewboard.asterisk.org/r/4062/ ........ Merged revisions 425690 from http://svn.asterisk.org/svn/asterisk/branches/12 ........ Merged revisions 425691 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@425700 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-09-18res_pjsip_pubsub: Add some type safety when generating NOTIFY bodies.Mark Michelson
res_pjsip_pubsub has two separate checks that it makes when a SUBSCRIBE arrives. * It checks that there is a subscription handler for the Event * It checks that there are body generators for the types in the Accept header The problem is, there's nothing that ensures that these two things will actually mesh with each other. For instance, Asterisk will accept a subscription to MWI that accepts pidf+xml bodies. That doesn't make sense. With this commit, we add some type information to the mix. Subscription handlers state they generate data of type X, and body generators state that they consume data of type X. This way, Asterisk doesn't end up in some hilariously mismatched situation like the one in the previous paragraph. ASTERISK-24136 #close Reported by Mark Michelson Review: https://reviewboard.asterisk.org/r/3877 Review: https://reviewboard.asterisk.org/r/3878 ........ Merged revisions 423344 from http://svn.asterisk.org/svn/asterisk/branches/12 ........ Merged revisions 423348 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@423350 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-08-07Add support for RFC 4662 resource list subscriptions.Mark Michelson
This commit adds the ability for a user to configure a resource list in pjsip.conf. Subscribing to this list simultaneously subscribes the subscriber to all resources listed. This has the potential to reduce the amount of SIP traffic when loads of subscribers on a system attempt to subscribe to each others' states. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@420384 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-07-25Add module support level to ast_module_info structure. Print it in CLI ↵Mark Michelson
"module show" . ASTERISK-23919 #close Reported by Malcolm Davenport Review: https://reviewboard.asterisk.org/r/3802 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@419592 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-06-25Abstract PJSIP-specific elements from the pubsub API.Mark Michelson
This helps to pave the way for RLS work that is to come. Since this is a self-contained change and subscription tests still pass, this work is being committed directly to trunk instead of a working branch. ASTERISK-23865 #close Review: https://reviewboard.asterisk.org/r/3628 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@417233 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-06-12res_pjsip_pubsub: Persist subscriptions in sorcery so they are recreated on ↵Joshua Colp
startup. This change makes res_pjsip_pubsub persist inbound subscriptions in sorcery. By default this uses the local astdb but it can also be configured to store within an outside database. When Asterisk is started these subscriptions are recreated if they have not expired. Notifications are sent to the devices which have subscribed and they are none the wiser that the system has restarted. Review: https://reviewboard.asterisk.org/r/3598/ ........ Merged revisions 415766 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@415767 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-03-14Prevent conflicts regarding unsolicited and solicited MWI to an endpoint.Mark Michelson
If an endpoint is receiving unsolicited MWI for a mailbox and then attempts to subscribe to an AOR that provides MWI for the same mailbox, then the SUBSCRIBE is rejected with a 500 response. Review: https://reviewboard.asterisk.org/r/3345 ........ Merged revisions 410590 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@410591 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-03-06Don't attempt to link in an aggregate MWI subscription if an endpoint does ↵Mark Michelson
not aggregate MWI. Attempting to link a NULL object into an ao2 container had been benign previously, but since enabling DO_CRASH in the testsuite, this is now causing a crash. It's better to be right here anyway. ........ Merged revisions 410011 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@410012 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-02-13Remove all PJSIP MWI-specific use from our MWI code.Mark Michelson
PJSIP has built-in MWI code that could be useful to some degree, but our utilization of the API actually made our code a bit more cluttered since we had to have special cases peppered throughout. With this change, we move to using the pjsip_evsub API instead, which streamlines the code by removing special cases. Review: https://reviewboard.asterisk.org/r/3205 ........ Merged revisions 408005 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@408006 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-01-31Decouple subscription handling from NOTIFY/PUBLISH body generation.Mark Michelson
When the PJSIP pubsub framework was created, subscription handlers were required to state what event they handled along with what body types they knew how to generate. While this serves well when implementing a base RFC, it has problems when trying to extend the body to support non-standard or proprietary body elements. The code also was NOTIFY-specific, meaning that when the time comes that we start writing code to send out PUBLISH requests with MWI or presence bodies, we would likely find ourselves duplicating code that had previously been written. This changeset introduces the concept of body generators and body supplements. A body generator is responsible for allocating a native structure for a given body type, providing the primary body content, converting the native structure to a string, and deallocating resources. A body supplement takes the primary body content (the native structure, not a string) generated by the body generator and adds nonstandard elements to the body. With these elements living in their own module, it becomes easy to extend our support for body types and to re-use resources when sending a PUBLISH request. Body generators and body supplements register themselves with the pubsub core, similar to how subscription and publish handlers had done. Now, subscription handlers do not need to know what type of body content they generate, but they still need to inform the pubsub core about what the default body type for a given event package is. The pubsub core keeps track of what body generators and body supplements have been registered. When a SUBSCRIBE arrives, the pubsub core will check that there is a subscription handler for the event in the SUBSCRIBE, then it will check that there is a body generator that can provide the content specified in the Accept header(s). Because of the nature of body generators and supplements, it means res_pjsip_exten_state and res_pjsip_mwi have been completely gutted. They no longer worry about body types, instead calling ast_sip_pubsub_generate_body_content() when they need to generate a NOTIFY body. Review: https://reviewboard.asterisk.org/r/3150 ........ Merged revisions 407016 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@407030 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-01-31res_pjsip_mwi: Subscribe fails when missing aor nameKevin Harwell
When subscribing to MWI (res_pjsip_mwi) and the sip uri did not contain a name (ex: sip:<ip address>) then the subscription would fail since it would be unable to locate an associated aor. This patch makes it so that when a subscribe comes with no aor name then it will subscribe to all aors on the located endpoint. (closes issue ASTERISK-23072) Reported by: Bob M Review: https://reviewboard.asterisk.org/r/3164/ ........ Merged revisions 407014 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@407015 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-01-15PJSIP: Add Path header supportKinsey Moore
This adds Path support to chan_pjsip in res_pjsip_path.c with minimal additions in res_pjsip_registrar.c to store the path and additions in res_pjsip_outbound_registration.c to enable advertisement of path support to registrars and intervening proxies. Path information is stored on contacts and is enabled via Address of Record (AoRs) and Registration configuration sections. While adding path support, it became necessary to be able to add SIP supplements that handled messages outside of sessions, so a framework for handling these types of hooks was added in parallel to the already-existing session supplements and several senders of out-of-dialog requests were refactored as a result. (closes issue ASTERISK-21084) Review: https://reviewboard.asterisk.org/r/3050/ ........ Merged revisions 405565 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@405566 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-11-23res_pjsip: AMI commands and events.Kevin Harwell
Created the following AMI commands and corresponding events for res_pjsip: PJSIPShowEndpoints - Provides a listing of all pjsip endpoints and a few select attributes on each. Events: EndpointList - for each endpoint a few attributes. EndpointlistComplete - after all endpoints have been listed. PJSIPShowEndpoint - Provides a detail list of attributes for a specified endpoint. Events: EndpointDetail - attributes on an endpoint. AorDetail - raised for each AOR on an endpoint. AuthDetail - raised for each associated inbound and outbound auth TransportDetail - transport attributes. IdentifyDetail - attributes for the identify object associated with the endpoint. EndpointDetailComplete - last event raised after all detail events. PJSIPShowRegistrationsInbound - Provides a detail listing of all inbound registrations. Events: InboundRegistrationDetail - inbound registration attributes for each registration. InboundRegistrationDetailComplete - raised after all detail records have been listed. PJSIPShowRegistrationsOutbound - Provides a detail listing of all outbound registrations. Events: OutboundRegistrationDetail - outbound registration attributes for each registration. OutboundRegistrationDetailComplete - raised after all detail records have been listed. PJSIPShowSubscriptionsInbound - A detail listing of all inbound subscriptions and their attributes. Events: SubscriptionDetail - on each subscription detailed attributes SubscriptionDetailComplete - raised after all detail records have been listed. PJSIPShowSubscriptionsOutbound - A detail listing of all outboundbound subscriptions and their attributes. Events: SubscriptionDetail - on each subscription detailed attributes SubscriptionDetailComplete - raised after all detail records have been listed. (issue ASTERISK-22609) Reported by: Matt Jordan Review: https://reviewboard.asterisk.org/r/2959/ ........ Merged revisions 403131 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@403133 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-11-21res_pjsip_mwi: Fix memory leak of MWI subscriptions containerMatthew Jordan
This patch fixes a reference counting memory leak on the ao2_container created as part of create_mwi_subscriptions. When we create the container in this routine, the intent is to hand lifetime ownership over to the global container unsolicited_mwi. When ao2_global_obj_replace_unref is called, the reference count on mwi_subscriptions (the container) will be bumped by 1; however, the function does not decrement the reference count on mwi_subscriptions when this occurs. This will prevent the container from being fully disposed of when Asterisk exits (or on any subsequent call to this operation, such as during a reload). ........ Merged revisions 402940 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@402942 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-10-14Remove duplicate module info blockMatthew Jordan
The module info block was repeated twice. Once is sufficient. ........ Merged revisions 400881 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@400882 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-09-30Multiple revisions 399887,400138,400178,400180-400181David M. Lee
........ r399887 | dlee | 2013-09-26 10:41:47 -0500 (Thu, 26 Sep 2013) | 1 line Minor performance bump by not allocate manager variable struct if we don't need it ........ r400138 | dlee | 2013-09-30 10:24:00 -0500 (Mon, 30 Sep 2013) | 23 lines Stasis performance improvements This patch addresses several performance problems that were found in the initial performance testing of Asterisk 12. The Stasis dispatch object was allocated as an AO2 object, even though it has a very confined lifecycle. This was replaced with a straight ast_malloc(). The Stasis message router was spending an inordinate amount of time searching hash tables. In this case, most of our routers had 6 or fewer routes in them to begin with. This was replaced with an array that's searched linearly for the route. We more heavily rely on AO2 objects in Asterisk 12, and the memset() in ao2_ref() actually became noticeable on the profile. This was #ifdef'ed to only run when AO2_DEBUG was enabled. After being misled by an erroneous comment in taskprocessor.c during profiling, the wrong comment was removed. Review: https://reviewboard.asterisk.org/r/2873/ ........ r400178 | dlee | 2013-09-30 13:26:27 -0500 (Mon, 30 Sep 2013) | 24 lines Taskprocessor optimization; switch Stasis to use taskprocessors This patch optimizes taskprocessor to use a semaphore for signaling, which the OS can do a better job at managing contention and waiting that we can with a mutex and condition. The taskprocessor execution was also slightly optimized to reduce the number of locks taken. The only observable difference in the taskprocessor implementation is that when the final reference to the taskprocessor goes away, it will execute all tasks to completion instead of discarding the unexecuted tasks. For systems where unnamed semaphores are not supported, a really simple semaphore implementation is provided. (Which gives identical performance as the original taskprocessor implementation). The way we ended up implementing Stasis caused the threadpool to be a burden instead of a boost to performance. This was switched to just use taskprocessors directly for subscriptions. Review: https://reviewboard.asterisk.org/r/2881/ ........ r400180 | dlee | 2013-09-30 13:39:34 -0500 (Mon, 30 Sep 2013) | 28 lines Optimize how Stasis forwards are dispatched This patch optimizes how forwards are dispatched in Stasis. Originally, forwards were dispatched as subscriptions that are invoked on the publishing thread. This did not account for the vast number of forwards we would end up having in the system, and the amount of work it would take to walk though the forward subscriptions. This patch modifies Stasis so that rather than walking the tree of forwards on every dispatch, when forwards and subscriptions are changed, the subscriber list for every topic in the tree is changed. This has a couple of benefits. First, this reduces the workload of dispatching messages. It also reduces contention when dispatching to different topics that happen to forward to the same aggregation topic (as happens with all of the channel, bridge and endpoint topics). Since forwards are no longer subscriptions, the bulk of this patch is simply changing stasis_subscription objects to stasis_forward objects (which, admittedly, I should have done in the first place.) Since this required me to yet again put in a growing array, I finally abstracted that out into a set of ast_vector macros in asterisk/vector.h. Review: https://reviewboard.asterisk.org/r/2883/ ........ r400181 | dlee | 2013-09-30 13:48:57 -0500 (Mon, 30 Sep 2013) | 28 lines Remove dispatch object allocation from Stasis publishing While looking for areas for performance improvement, I realized that an unused feature in Stasis was negatively impacting performance. When a message is sent to a subscriber, a dispatch object is allocated for the dispatch, containing the topic the message was published to, the subscriber the message is being sent to, and the message itself. The topic is actually unused by any subscriber in Asterisk today. And the subscriber is associated with the taskprocessor the message is being dispatched to. First, this patch removes the unused topic parameter from Stasis subscription callbacks. Second, this patch introduces the concept of taskprocessor local data, data that may be set on a taskprocessor and provided along with the data pointer when a task is pushed using the ast_taskprocessor_push_local() call. This allows the task to have both data specific to that taskprocessor, in addition to data specific to that invocation. With those two changes, the dispatch object can be removed completely, and the message is simply refcounted and sent directly to the taskprocessor. Review: https://reviewboard.asterisk.org/r/2884/ ........ Merged revisions 399887,400138,400178,400180-400181 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@400186 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-22Handle default body types for SIP event packages in res_pjsip_pubsubMark Michelson
Prior to this change, we would reject SUBSCRIBE requests that had no Accept headers. Now event package handlers that handle the default type for the event package indicate that they do so. Therefore, if we have a handler that can handle the default type, we can allow SUBSCRIBEs for the handler's event package that have no Accept headers. (closes issue ASTERISK-22067) reported by Mark Michelson Review: https://reviewboard.asterisk.org/r/2774 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@397441 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-01Fixed compile errors introduced in r395954.David M. Lee
Just a merge error due to a file rename. Grrr... git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@395971 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-07-30The large GULP->PJSIP renaming effort.Mark Michelson
The general gist is to have a clear boundary between old SIP stuff and new SIP stuff by having the word "SIP" for old stuff and "PJSIP" for new stuff. Here's a brief rundown of the changes: * The word "Gulp" in dialstrings, functions, and CLI commands is now "PJSIP" * chan_gulp.c is now chan_pjsip.c * Function names in chan_gulp.c that were "gulp_*" are now "chan_pjsip_*" * All files that were "res_sip*" are now "res_pjsip*" * The "res_sip" directory is now "res_pjsip" * Files in the "res_pjsip" directory that began with "sip_*" are now "pjsip_*" * The configuration file is now "pjsip.conf" instead of "res_sip.conf" * The module info for all PJSIP-related files now uses "PJSIP" instead of "SIP" * CLI and AMI commands created by Asterisk's PJSIP modules now have "pjsip" as the starting word instead of "sip" git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@395764 65c4cc65-6c06-0410-ace0-fbb531ad65f3