MXS-2196: Store listener references in Service

By storing a shared pointer to the listeners in the services, they will be
available as long as the service using them exists. This enables clean
destruction of listeners that still have open sessions.

The listener creation code now separately creates the listener and links
it to the service. Also replaced relevant parts of the related code with
the listener implemented versions of it.
This commit is contained in:
Markus Mäkelä
2018-11-30 11:35:09 +02:00
parent a6063b5e85
commit 330719c8f9
5 changed files with 90 additions and 206 deletions

View File

@ -81,6 +81,20 @@ public:
*/
const FilterList& get_filters() const;
/**
* Add a listener to a service
*
* @param listener Listener to add
*/
void add_listener(const SListener& listener);
/**
* Remove a listener from a service
*
* @param listener Listener to remove
*/
void remove_listener(const SListener& listener);
/**
* Reload users for all listeners
*
@ -104,15 +118,16 @@ public:
mutable std::mutex lock;
private:
FilterList m_filters; /**< Ordered list of filters */
std::string m_name; /**< Name of the service */
std::string m_router_name; /**< Router module */
std::string m_user; /**< Username */
std::string m_password; /**< Password */
std::string m_weightby; /**< Weighting parameter name */
std::string m_version_string; /**< Version string sent to clients */
RateLimits m_rate_limits; /**< The refresh rate limits for users of each thread */
uint64_t m_wkey; /**< Key for worker local data */
FilterList m_filters; /**< Ordered list of filters */
std::vector<SListener> m_listeners; /**< Listeners pointing to this service */
std::string m_name; /**< Name of the service */
std::string m_router_name; /**< Router module */
std::string m_user; /**< Username */
std::string m_password; /**< Password */
std::string m_weightby; /**< Weighting parameter name */
std::string m_version_string;/**< Version string sent to clients */
RateLimits m_rate_limits; /**< The refresh rate limits for users of each thread */
uint64_t m_wkey; /**< Key for worker local data */
// Get the worker local filter list
FilterList* get_local_filters() const;