summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorGeorge Joseph <gjoseph@digium.com>2018-01-28 09:10:00 -0700
committerGeorge Joseph <gjoseph@digium.com>2018-01-30 09:29:51 -0600
commit2b9aa6b5bbe8d3ada6e4a9b0bc614f2f77470cd0 (patch)
treea9dff42e45491c719a4a08fc402472b9a82885cc /include
parent81db0aca0fb8d288a780ca664817ef231a9a4ac0 (diff)
res_pjsip_pubsub: Prune subs with reliable transports at startup
In an earlier release, inbound registrations on a reliable transport were pruned on Asterisk restart since the TCP connection would have been torn down and become unusable when Asterisk stopped. This same process is now also applied to inbound subscriptions. Also fixed issues in res_pjsip_registrar where it wasn't handling the monitoring correctly when multiple registrations came in over the same transport. To accomplish this, the pjsip_transport_event feature needed to be refactored to allow multiple monitors (multiple subcriptions or registrations from the same endpoint) to exist on the same transport. Since this changed the API, any external modules that may have used the transport monitor feature (highly unlikey) will need to be changed. ASTERISK-27612 Reported by: Ross Beer Change-Id: Iee87cf4eb9b7b2b93d5739a72af52d6ca8fbbe36
Diffstat (limited to 'include')
-rw-r--r--include/asterisk/res_pjsip.h52
1 files changed, 43 insertions, 9 deletions
diff --git a/include/asterisk/res_pjsip.h b/include/asterisk/res_pjsip.h
index a3bd78222..c017e62db 100644
--- a/include/asterisk/res_pjsip.h
+++ b/include/asterisk/res_pjsip.h
@@ -2985,6 +2985,18 @@ int ast_sip_str_to_dtmf(const char *dtmf_mode);
*/
typedef void (*ast_transport_monitor_shutdown_cb)(void *data);
+/*!
+ * \brief Transport shutdown monitor data matcher
+ * \since 13.20.0
+ *
+ * \param a User data to compare.
+ * \param b User data to compare.
+ *
+ * \retval 1 The data objects match
+ * \retval 0 The data objects don't match
+ */
+typedef int (*ast_transport_monitor_data_matcher)(void *a, void *b);
+
enum ast_transport_monitor_reg {
/*! \brief Successfully registered the transport monitor */
AST_TRANSPORT_MONITOR_REG_SUCCESS,
@@ -3001,37 +3013,59 @@ enum ast_transport_monitor_reg {
/*!
* \brief Register a reliable transport shutdown monitor callback.
- * \since 13.18.0
+ * \since 13.20.0
*
* \param transport Transport to monitor for shutdown.
* \param cb Who to call when transport is shutdown.
* \param ao2_data Data to pass with the callback.
*
+ * \note The data object passed will have its reference count automatically
+ * incremented by this call and automatically decremented after the callback
+ * runs or when the callback is unregistered.
+ *
+ * There is no checking for duplicate registrations.
+ *
* \return enum ast_transport_monitor_reg
*/
enum ast_transport_monitor_reg ast_sip_transport_monitor_register(pjsip_transport *transport,
ast_transport_monitor_shutdown_cb cb, void *ao2_data);
/*!
- * \brief Unregister a reliable transport shutdown monitor callback.
- * \since 13.18.0
+ * \brief Unregister a reliable transport shutdown monitor
+ * \since 13.20.0
*
* \param transport Transport to monitor for shutdown.
- * \param cb Who to call when transport is shutdown.
+ * \param cb The callback that was used for the original register.
+ * \param data Data to pass to the matcher. May be NULL and does NOT need to be an ao2 object.
+ * If NULL, all monitors with the provided callbck are unregistered.
+ * \param matches Matcher function that returns true if data matches the previously
+ * registered data object. If NULL, a simple pointer comparison is done.
+ *
+ * \note The data object passed into the original register will have its reference count
+ * automatically decremeneted.
*
* \return Nothing
*/
-void ast_sip_transport_monitor_unregister(pjsip_transport *transport, ast_transport_monitor_shutdown_cb cb);
+void ast_sip_transport_monitor_unregister(pjsip_transport *transport,
+ ast_transport_monitor_shutdown_cb cb, void *data, ast_transport_monitor_data_matcher matches);
/*!
- * \brief Unregister monitor callback from all reliable transports.
- * \since 13.18.0
+ * \brief Unregister a transport shutdown monitor from all reliable transports
+ * \since 13.20.0
+ *
+ * \param cb The callback that was used for the original register.
+ * \param data Data to pass to the matcher. May be NULL and does NOT need to be an ao2 object.
+ * If NULL, all monitors with the provided callbck are unregistered.
+ * \param matches Matcher function that returns true if ao2_data matches the previously
+ * registered data object. If NULL, a simple pointer comparison is done.
*
- * \param cb Who to call when a transport is shutdown.
+ * \note The data object passed into the original register will have its reference count
+ * automatically decremeneted.
*
* \return Nothing
*/
-void ast_sip_transport_monitor_unregister_all(ast_transport_monitor_shutdown_cb cb);
+void ast_sip_transport_monitor_unregister_all(ast_transport_monitor_shutdown_cb cb,
+ void *data, ast_transport_monitor_data_matcher matches);
/*! Transport state notification registration element. */
struct ast_sip_tpmgr_state_callback {