MXS-2220 Move authenticator instance data to internal class

This commit is contained in:
Esa Korhonen
2019-01-09 14:00:40 +02:00
parent 42215c65fa
commit 6d296f6661
4 changed files with 28 additions and 18 deletions

View File

@ -173,7 +173,6 @@ public:
// Base variables
bool is_active = false; /**< Server is active and has not been "destroyed" */
void* auth_instance = nullptr; /**< Authenticator instance data */
SSL_LISTENER* server_ssl = nullptr; /**< SSL data */
uint8_t charset = DEFAULT_CHARSET;/**< Character set. Read from backend and sent to client. */

View File

@ -440,8 +440,11 @@ DCB* dcb_connect(SERVER* srv, MXS_SESSION* session, const char* protocol)
*/
/** Allocate DCB specific authentication data */
if (dcb->authfunc.create
&& (dcb->authenticator_data = dcb->authfunc.create(dcb->server->auth_instance)) == NULL)
auto auth_create = dcb->authfunc.create;
if (auth_create)
{
Server* server = static_cast<Server*>(dcb->server);
if ((dcb->authenticator_data = auth_create(server->auth_instance())) == NULL)
{
MXS_ERROR("Failed to create authenticator for backend DCB.");
close(dcb->fd);
@ -452,6 +455,7 @@ DCB* dcb_connect(SERVER* srv, MXS_SESSION* session, const char* protocol)
dcb_free_all_memory(dcb);
return NULL;
}
}
/**
* Add the dcb in the poll set

View File

@ -89,17 +89,17 @@ public:
Version version() const override
{
return info.version_num();
return m_info.version_num();
}
Type type() const override
{
return info.type();
return m_info.type();
}
std::string version_string() const override
{
return info.version_string();
return m_info.version_string();
}
const char* name() const override
@ -306,7 +306,12 @@ public:
*/
json_t* to_json(const char* host);
DCB** persistent = nullptr;/**< List of unused persistent connections to the server */
void* auth_instance()
{
return m_auth_instance;
}
DCB** persistent = nullptr; /**< List of unused persistent connections to the server */
private:
struct Settings
@ -364,5 +369,7 @@ private:
const std::string m_name; /**< Server config name */
Settings m_settings; /**< Server settings */
VersionInfo info; /**< Server version and type information */
VersionInfo m_info; /**< Server version and type information */
void* m_auth_instance = nullptr; /**< Authenticator instance data */
};

View File

@ -257,7 +257,7 @@ Server* Server::server_alloc(const char* name, MXS_CONFIG_PARAMETER* params)
server->m_settings.persistmaxtime = config_get_integer(params, CN_PERSISTMAXTIME);
server->proxy_protocol = config_get_bool(params, CN_PROXY_PROTOCOL);
server->is_active = true;
server->auth_instance = auth_instance;
server->m_auth_instance = auth_instance;
server->server_ssl = ssl;
server->persistent = persistent;
server->last_event = SERVER_UP_EVENT;
@ -860,7 +860,7 @@ uint64_t SERVER::status_from_string(const char* str)
void Server::set_version(uint64_t version_num, const std::string& version_str)
{
info.set(version_num, version_str);
m_info.set(version_num, version_str);
}
/**