MXS-2196: Take Listener into use

This commit is contained in:
Markus Mäkelä
2018-11-30 11:43:33 +02:00
parent 330719c8f9
commit a10b6c2e89
16 changed files with 93 additions and 137 deletions

View File

@ -3863,13 +3863,13 @@ int create_new_listener(CONFIG_CONTEXT* obj)
address = ""; address = "";
} }
if (auto l = service_find_listener(service, socket, address, socket ? 0 : atoi(port))) if (auto l = service_find_listener(service, socket ? socket : "", address, socket ? 0 : atoi(port)))
{ {
MXS_ERROR("Creation of listener '%s' for service '%s' failed, because " MXS_ERROR("Creation of listener '%s' for service '%s' failed, because "
"listener '%s' already listens on the %s %s.", "listener '%s' already listens on the %s %s.",
obj->object, obj->object,
service->name, service->name,
l->name.c_str(), l->name(),
socket ? "socket" : "port", socket ? "socket" : "port",
socket ? socket : port); socket ? socket : port);
return 1; return 1;

View File

@ -978,16 +978,16 @@ bool runtime_create_listener(Service* service,
proto = "mariadbclient"; proto = "mariadbclient";
} }
if (auth && strcasecmp(auth, CN_DEFAULT) == 0) if (!auth || strcasecmp(auth, CN_DEFAULT) == 0)
{ {
/** Set auth to NULL so the protocol default authenticator is used */ /** Use protocol default authenticator*/
auth = NULL; auth = "";
} }
if (auth_opt && strcasecmp(auth_opt, CN_DEFAULT) == 0) if (!auth_opt || strcasecmp(auth_opt, CN_DEFAULT) == 0)
{ {
/** Don't pass options to the authenticator */ /** Don't pass options to the authenticator */
auth_opt = NULL; auth_opt = "";
} }
unsigned short u_port = atoi(port); unsigned short u_port = atoi(port);
@ -995,7 +995,7 @@ bool runtime_create_listener(Service* service,
std::lock_guard<std::mutex> guard(crt_lock); std::lock_guard<std::mutex> guard(crt_lock);
if (!serviceHasListener(service, name, proto, addr, u_port)) if (!listener_find(name) && !service_find_listener(service, "", addr, u_port))
{ {
SSL_LISTENER* ssl = NULL; SSL_LISTENER* ssl = NULL;

View File

@ -2230,8 +2230,8 @@ static int dcb_create_SSL(DCB* dcb, SSL_LISTENER* ssl)
*/ */
int dcb_accept_SSL(DCB* dcb) int dcb_accept_SSL(DCB* dcb)
{ {
if ((NULL == dcb->listener || NULL == dcb->listener->ssl) if ((NULL == dcb->listener || NULL == dcb->listener->ssl())
|| (NULL == dcb->ssl && dcb_create_SSL(dcb, dcb->listener->ssl) != 0)) || (NULL == dcb->ssl && dcb_create_SSL(dcb, dcb->listener->ssl()) != 0))
{ {
return -1; return -1;
} }
@ -2451,10 +2451,11 @@ DCB* dcb_accept(DCB* dcb)
INET6_ADDRSTRLEN); INET6_ADDRSTRLEN);
} }
} }
memcpy(&client_dcb->func, protocol_funcs, sizeof(MXS_PROTOCOL)); memcpy(&client_dcb->func, protocol_funcs, sizeof(MXS_PROTOCOL));
if (!dcb->listener->authenticator.empty()) if (*dcb->listener->authenticator())
{ {
authenticator_name = dcb->listener->authenticator.c_str(); authenticator_name = dcb->listener->authenticator();
} }
else if (client_dcb->func.auth_default != NULL) else if (client_dcb->func.auth_default != NULL)
{ {
@ -2476,7 +2477,7 @@ DCB* dcb_accept(DCB* dcb)
/** Allocate DCB specific authentication data */ /** Allocate DCB specific authentication data */
if (client_dcb->authfunc.create if (client_dcb->authfunc.create
&& (client_dcb->authenticator_data = && (client_dcb->authenticator_data =
client_dcb->authfunc.create(client_dcb->listener->auth_instance)) == NULL) client_dcb->authfunc.create(client_dcb->listener->auth_instance())) == NULL)
{ {
MXS_ERROR("Failed to create authenticator for client DCB"); MXS_ERROR("Failed to create authenticator for client DCB");
dcb_close(client_dcb); dcb_close(client_dcb);
@ -2908,7 +2909,7 @@ void dcb_process_idle_sessions(int thr)
if (dcb->dcb_role == DCB_ROLE_CLIENT_HANDLER) if (dcb->dcb_role == DCB_ROLE_CLIENT_HANDLER)
{ {
mxb_assert(dcb->listener); mxb_assert(dcb->listener);
SERVICE* service = dcb->listener->service; SERVICE* service = dcb->listener->service();
if (service->conn_idle_timeout && dcb->state == DCB_STATE_POLLING) if (service->conn_idle_timeout && dcb->state == DCB_STATE_POLLING)
{ {

View File

@ -347,25 +347,10 @@ bool serviceLaunchListener(Service* service, const SListener& port);
* @return True if service has the listener * @return True if service has the listener
*/ */
SListener service_find_listener(Service* service, SListener service_find_listener(Service* service,
const char* socket, const std::string& socket,
const char* address, const std::string& address,
unsigned short port); unsigned short port);
/**
* @brief Check if a service has a listener
*
* @param service Service to check
* @param protocol Listener protocol
* @param address Listener address
* @param port Listener port
* @return True if service has the listener
*/
bool serviceHasListener(Service* service,
const char* name,
const char* protocol,
const char* address,
unsigned short port);
/** /**
* @brief Check if a MaxScale service listens on a port * @brief Check if a MaxScale service listens on a port
* *

View File

@ -238,8 +238,8 @@ Service::~Service()
for (const auto& tmp : listener_find_by_service(this)) for (const auto& tmp : listener_find_by_service(this))
{ {
mxb_assert(!tmp->active || maxscale_teardown_in_progress()); mxb_assert(!tmp->is_active() || maxscale_teardown_in_progress());
listener_free(listener_find(tmp->name)); listener_free(listener_find(tmp->name()));
} }
if (router && router_instance && router->destroyInstance) if (router && router_instance && router->destroyInstance)
@ -546,58 +546,28 @@ bool service_remove_listener(Service* service, const char* target)
} }
SListener service_find_listener(Service* service, SListener service_find_listener(Service* service,
const char* socket, const std::string& socket,
const char* address, const std::string& address,
unsigned short port) unsigned short port)
{ {
SListener rval;
for (const auto& listener : listener_find_by_service(service)) for (const auto& listener : listener_find_by_service(service))
{ {
if (port == listener->port) if (port == listener->port() && (listener->address() == address || listener->address() == socket))
{ {
if ((!address && listener->address.empty()) || listener->address == address rval = listener;
|| (!socket && listener->address.empty()) || listener->address == socket) break;
{
return listener;
}
} }
} }
return NULL; return rval;
}
/**
* Check if a protocol/port pair is part of the service
*
* @param service The service
* @param protocol The name of the protocol module
* @param address The address to listen on
* @param port The port to listen on
* @return True if the protocol/port is already part of the service
*/
bool serviceHasListener(Service* service,
const char* name,
const char* protocol,
const char* address,
unsigned short port)
{
for (const auto& listener : listener_find_by_service(service))
{
if (listener->port == port)
{
if ((!address && listener->address.empty()) || listener->address == address)
{
return true;
}
}
}
return false;
} }
bool service_has_named_listener(Service* service, const char* name) bool service_has_named_listener(Service* service, const char* name)
{ {
auto listener = listener_find(name); auto listener = listener_find(name);
return listener && listener->service == service; return listener && listener->service() == service;
} }
bool service_can_be_destroyed(Service* service) bool service_can_be_destroyed(Service* service)
@ -1094,12 +1064,12 @@ void dListListeners(DCB* dcb)
{ {
dcb_printf(dcb, dcb_printf(dcb,
"%-20s | %-19s | %-18s | %-15s | %5d | %s\n", "%-20s | %-19s | %-18s | %-15s | %5d | %s\n",
listener->name.c_str(), listener->name(),
service->name, service->name,
listener->protocol.c_str(), listener->protocol(),
(listener && !listener->address.empty()) ? listener->address.c_str() : "*", (listener && *listener->address()) ? listener->address() : "*",
listener->port, listener->port(),
listener_state_to_string(listener)); listener->state());
} }
} }
if (!this_unit.services.empty()) if (!this_unit.services.empty())
@ -1316,8 +1286,8 @@ std::unique_ptr<ResultSet> serviceGetListenerList()
{ {
for (const auto& listener : listener_find_by_service(service)) for (const auto& listener : listener_find_by_service(service))
{ {
set->add_row({service->name, listener->protocol, listener->address, set->add_row({service->name, listener->protocol(), listener->address(),
std::to_string(listener->port), listener_state_to_string(listener)}); std::to_string(listener->port()), listener->state()});
} }
} }
@ -1623,7 +1593,7 @@ bool service_port_is_used(unsigned short port)
{ {
for (const auto& listener : listener_find_by_service(service)) for (const auto& listener : listener_find_by_service(service))
{ {
if (listener->port == port) if (listener->port() == port)
{ {
rval = true; rval = true;
break; break;
@ -1694,7 +1664,7 @@ static json_t* service_all_listeners_json_data(const SERVICE* service)
for (const auto& listener : listener_find_by_service(service)) for (const auto& listener : listener_find_by_service(service))
{ {
json_array_append_new(arr, listener_to_json(listener)); json_array_append_new(arr, listener->to_json());
} }
return arr; return arr;
@ -1704,9 +1674,9 @@ static json_t* service_listener_json_data(const SERVICE* service, const char* na
{ {
auto listener = listener_find(name); auto listener = listener_find(name);
if (listener && listener->service == service) if (listener && listener->service() == service)
{ {
return listener_to_json(listener); return listener->to_json();
} }
return NULL; return NULL;

View File

@ -54,7 +54,7 @@ int ssl_authenticate_client(DCB* dcb, bool is_capable)
const char* remote = dcb->remote ? dcb->remote : ""; const char* remote = dcb->remote ? dcb->remote : "";
const char* service = (dcb->service && dcb->service->name) ? dcb->service->name : ""; const char* service = (dcb->service && dcb->service->name) ? dcb->service->name : "";
if (NULL == dcb->listener || NULL == dcb->listener->ssl) if (NULL == dcb->listener || NULL == dcb->listener->ssl())
{ {
/* Not an SSL connection on account of listener configuration */ /* Not an SSL connection on account of listener configuration */
return SSL_AUTH_CHECKS_OK; return SSL_AUTH_CHECKS_OK;
@ -134,7 +134,7 @@ bool ssl_is_connection_healthy(DCB* dcb)
* more to be done. * more to be done.
*/ */
return NULL == dcb->listener return NULL == dcb->listener
|| NULL == dcb->listener->ssl || NULL == dcb->listener->ssl()
|| dcb->ssl_state == SSL_ESTABLISHED; || dcb->ssl_state == SSL_ESTABLISHED;
} }
@ -171,7 +171,7 @@ bool ssl_check_data_to_process(DCB* dcb)
*/ */
bool ssl_required_by_dcb(DCB* dcb) bool ssl_required_by_dcb(DCB* dcb)
{ {
return NULL != dcb->listener && NULL != dcb->listener->ssl; return NULL != dcb->listener && NULL != dcb->listener->ssl();
} }
/** /**
@ -187,7 +187,7 @@ bool ssl_required_by_dcb(DCB* dcb)
bool ssl_required_but_not_negotiated(DCB* dcb) bool ssl_required_but_not_negotiated(DCB* dcb)
{ {
return NULL != dcb->listener return NULL != dcb->listener
&& NULL != dcb->listener->ssl && NULL != dcb->listener->ssl()
&& SSL_HANDSHAKE_UNKNOWN == dcb->ssl_state; && SSL_HANDSHAKE_UNKNOWN == dcb->ssl_state;
} }

View File

@ -83,7 +83,7 @@ static int test1()
NULL, NULL,
NULL), NULL),
"Add Protocol should succeed"); "Add Protocol should succeed");
mxb_assert_message(0 != serviceHasListener(service, "TestProtocol", "mariadbclient", "localhost", 9876), mxb_assert_message(service_find_listener(service, "", "localhost", 9876),
"Service should have new protocol as requested"); "Service should have new protocol as requested");
return 0; return 0;

View File

@ -328,21 +328,21 @@ json_t* users_diagnostic_json(USERS* users)
void users_default_diagnostic(DCB* dcb, Listener* port) void users_default_diagnostic(DCB* dcb, Listener* port)
{ {
if (port->users) if (port->users())
{ {
users_diagnostic(dcb, port->users); users_diagnostic(dcb, port->users());
} }
} }
json_t* users_default_diagnostic_json(const Listener* port) json_t* users_default_diagnostic_json(const Listener* port)
{ {
return port->users ? users_diagnostic_json(port->users) : json_array(); return port->users() ? users_diagnostic_json(port->users()) : json_array();
} }
int users_default_loadusers(Listener* port) int users_default_loadusers(Listener* port)
{ {
users_free(port->users); users_free(port->users());
port->users = users_alloc(); port->set_users(users_alloc());
return MXS_AUTH_LOADUSERS_OK; return MXS_AUTH_LOADUSERS_OK;
} }

View File

@ -219,7 +219,7 @@ static int cdc_auth_check(DCB* dcb,
{ {
int rval = CDC_STATE_AUTH_FAILED; int rval = CDC_STATE_AUTH_FAILED;
if (dcb->listener->users) if (dcb->listener->users())
{ {
/* compute SHA1 of auth_data */ /* compute SHA1 of auth_data */
uint8_t sha1_step1[SHA_DIGEST_LENGTH] = ""; uint8_t sha1_step1[SHA_DIGEST_LENGTH] = "";
@ -228,7 +228,7 @@ static int cdc_auth_check(DCB* dcb,
gw_sha1_str(auth_data, SHA_DIGEST_LENGTH, sha1_step1); gw_sha1_str(auth_data, SHA_DIGEST_LENGTH, sha1_step1);
gw_bin2hex(hex_step1, sha1_step1, SHA_DIGEST_LENGTH); gw_bin2hex(hex_step1, sha1_step1, SHA_DIGEST_LENGTH);
if (users_auth(dcb->listener->users, username, hex_step1)) if (users_auth(dcb->listener->users(), username, hex_step1))
{ {
rval = CDC_STATE_AUTH_OK; rval = CDC_STATE_AUTH_OK;
} }
@ -439,7 +439,7 @@ static void cdc_auth_free_client_data(DCB* dcb)
*/ */
static int cdc_set_service_user(Listener* listener) static int cdc_set_service_user(Listener* listener)
{ {
SERVICE* service = listener->service; SERVICE* service = listener->service();
char* dpwd = NULL; char* dpwd = NULL;
char* newpasswd = NULL; char* newpasswd = NULL;
const char* service_user = NULL; const char* service_user = NULL;
@ -472,7 +472,7 @@ static int cdc_set_service_user(Listener* listener)
const char* user; const char* user;
const char* password; const char* password;
serviceGetUser(service, &user, &password); serviceGetUser(service, &user, &password);
users_add(listener->users, user, newpasswd, USER_ACCOUNT_ADMIN); users_add(listener->users(), user, newpasswd, USER_ACCOUNT_ADMIN);
MXS_FREE(newpasswd); MXS_FREE(newpasswd);
MXS_FREE(dpwd); MXS_FREE(dpwd);
@ -550,7 +550,7 @@ int cdc_replace_users(Listener* listener)
PATH_MAX, PATH_MAX,
"%s/%s/%s", "%s/%s/%s",
get_datadir(), get_datadir(),
listener->service->name, listener->service()->name,
CDC_USERS_FILENAME); CDC_USERS_FILENAME);
int i = cdc_read_users(newusers, path); int i = cdc_read_users(newusers, path);
@ -559,11 +559,11 @@ int cdc_replace_users(Listener* listener)
if (i > 0) if (i > 0)
{ {
/** Successfully loaded at least one user */ /** Successfully loaded at least one user */
oldusers = listener->users; oldusers = listener->users();
listener->users = newusers; listener->set_users(newusers);
rc = MXS_AUTH_LOADUSERS_OK; rc = MXS_AUTH_LOADUSERS_OK;
} }
else if (listener->users) else if (listener->users())
{ {
/** Failed to load users, use the old users table */ /** Failed to load users, use the old users table */
users_free(newusers); users_free(newusers);
@ -571,7 +571,7 @@ int cdc_replace_users(Listener* listener)
else else
{ {
/** No existing users, use the new empty users table */ /** No existing users, use the new empty users table */
listener->users = newusers; listener->set_users(newusers);
} }
cdc_set_service_user(listener); cdc_set_service_user(listener);

View File

@ -491,7 +491,7 @@ int gssapi_auth_authenticate(DCB* dcb)
{ {
int rval = MXS_AUTH_FAILED; int rval = MXS_AUTH_FAILED;
gssapi_auth_t* auth = (gssapi_auth_t*)dcb->authenticator_data; gssapi_auth_t* auth = (gssapi_auth_t*)dcb->authenticator_data;
GSSAPI_INSTANCE* instance = (GSSAPI_INSTANCE*)dcb->listener->auth_instance; GSSAPI_INSTANCE* instance = (GSSAPI_INSTANCE*)dcb->listener->auth_instance();
if (auth->state == GSSAPI_AUTH_INIT) if (auth->state == GSSAPI_AUTH_INIT)
{ {
@ -627,15 +627,15 @@ int gssapi_auth_load_users(Listener* listener)
const char* user; const char* user;
const char* password; const char* password;
int rval = MXS_AUTH_LOADUSERS_ERROR; int rval = MXS_AUTH_LOADUSERS_ERROR;
GSSAPI_INSTANCE* inst = (GSSAPI_INSTANCE*)listener->auth_instance; GSSAPI_INSTANCE* inst = (GSSAPI_INSTANCE*)listener->auth_instance();
serviceGetUser(listener->service, &user, &password); serviceGetUser(listener->service(), &user, &password);
char* pw; char* pw;
if ((pw = decrypt_password(password))) if ((pw = decrypt_password(password)))
{ {
bool no_active_servers = true; bool no_active_servers = true;
for (SERVER_REF* servers = listener->service->dbref; servers; servers = servers->next) for (SERVER_REF* servers = listener->service()->dbref; servers; servers = servers->next)
{ {
if (!SERVER_REF_IS_ACTIVE(servers) || !server_is_active(servers->server)) if (!SERVER_REF_IS_ACTIVE(servers) || !server_is_active(servers->server))
{ {

View File

@ -1123,7 +1123,7 @@ int get_users_from_server(MYSQL* con, SERVER_REF* server_ref, SERVICE* service,
service->enable_root, service->enable_root,
category); category);
MYSQL_AUTH* instance = (MYSQL_AUTH*)listener->auth_instance; MYSQL_AUTH* instance = (MYSQL_AUTH*)listener->auth_instance();
sqlite3* handle = get_handle(instance); sqlite3* handle = get_handle(instance);
int users = 0; int users = 0;
@ -1182,7 +1182,7 @@ static int get_users(Listener* listener, bool skip_local)
{ {
const char* service_user = NULL; const char* service_user = NULL;
const char* service_passwd = NULL; const char* service_passwd = NULL;
SERVICE* service = listener->service; SERVICE* service = listener->service();
serviceGetUser(service, &service_user, &service_passwd); serviceGetUser(service, &service_user, &service_passwd);
@ -1194,7 +1194,7 @@ static int get_users(Listener* listener, bool skip_local)
} }
/** Delete the old users */ /** Delete the old users */
MYSQL_AUTH* instance = (MYSQL_AUTH*)listener->auth_instance; MYSQL_AUTH* instance = (MYSQL_AUTH*)listener->auth_instance();
sqlite3* handle = get_handle(instance); sqlite3* handle = get_handle(instance);
delete_mysql_users(handle); delete_mysql_users(handle);

View File

@ -293,7 +293,7 @@ static int mysql_auth_authenticate(DCB* dcb)
client_data->user, client_data->user,
client_data->db); client_data->db);
MYSQL_AUTH* instance = (MYSQL_AUTH*)dcb->listener->auth_instance; MYSQL_AUTH* instance = (MYSQL_AUTH*)dcb->listener->auth_instance();
MySQLProtocol* protocol = DCB_PROTOCOL(dcb, MySQLProtocol); MySQLProtocol* protocol = DCB_PROTOCOL(dcb, MySQLProtocol);
auth_ret = validate_mysql_user(instance, auth_ret = validate_mysql_user(instance,
dcb, dcb,
@ -558,7 +558,7 @@ static bool add_service_user(Listener* port)
const char* password = NULL; const char* password = NULL;
bool rval = false; bool rval = false;
serviceGetUser(port->service, &user, &password); serviceGetUser(port->service(), &user, &password);
char* pw; char* pw;
@ -568,7 +568,7 @@ static bool add_service_user(Listener* port)
if (newpw) if (newpw)
{ {
MYSQL_AUTH* inst = (MYSQL_AUTH*)port->auth_instance; MYSQL_AUTH* inst = (MYSQL_AUTH*)port->auth_instance();
sqlite3* handle = get_handle(inst); sqlite3* handle = get_handle(inst);
add_mysql_user(handle, user, "%", "", "Y", newpw); add_mysql_user(handle, user, "%", "", "Y", newpw);
add_mysql_user(handle, user, "localhost", "", "Y", newpw); add_mysql_user(handle, user, "localhost", "", "Y", newpw);
@ -579,7 +579,7 @@ static bool add_service_user(Listener* port)
} }
else else
{ {
MXS_ERROR("[%s] Failed to decrypt service user password.", port->service->name); MXS_ERROR("[%s] Failed to decrypt service user password.", port->service()->name);
} }
return rval; return rval;
@ -610,13 +610,13 @@ static bool service_has_servers(SERVICE* service)
static int mysql_auth_load_users(Listener* port) static int mysql_auth_load_users(Listener* port)
{ {
int rc = MXS_AUTH_LOADUSERS_OK; int rc = MXS_AUTH_LOADUSERS_OK;
SERVICE* service = port->listener->service; SERVICE* service = port->service();
MYSQL_AUTH* instance = (MYSQL_AUTH*)port->auth_instance; MYSQL_AUTH* instance = (MYSQL_AUTH*)port->auth_instance();
bool first_load = false; bool first_load = false;
if (should_check_permissions(instance)) if (should_check_permissions(instance))
{ {
if (!check_service_permissions(port->service)) if (!check_service_permissions(port->service()))
{ {
return MXS_AUTH_LOADUSERS_FATAL; return MXS_AUTH_LOADUSERS_FATAL;
} }
@ -635,9 +635,9 @@ static int mysql_auth_load_users(Listener* port)
{ {
MXS_ERROR("[%s] Unable to load users for listener %s listening at [%s]:%d.", MXS_ERROR("[%s] Unable to load users for listener %s listening at [%s]:%d.",
service->name, service->name,
port->name.c_str(), port->name(),
!port->address.empty() ? port->address.c_str() : "::", *port->address() ? port->address() : "::",
port->port); port->port());
} }
if (instance->inject_service_user) if (instance->inject_service_user)
@ -646,7 +646,7 @@ static int mysql_auth_load_users(Listener* port)
* if loading of the users fails */ * if loading of the users fails */
if (!add_service_user(port)) if (!add_service_user(port))
{ {
MXS_ERROR("[%s] Failed to inject service user.", port->service->name); MXS_ERROR("[%s] Failed to inject service user.", port->service()->name);
} }
else else
{ {
@ -673,7 +673,7 @@ static int mysql_auth_load_users(Listener* port)
} }
else if (loaded > 0 && first_load) else if (loaded > 0 && first_load)
{ {
MXS_NOTICE("[%s] Loaded %d MySQL users for listener %s.", service->name, loaded, port->name.c_str()); MXS_NOTICE("[%s] Loaded %d MySQL users for listener %s.", service->name, loaded, port->name());
} }
return rc; return rc;
@ -697,7 +697,7 @@ int mysql_auth_reauthenticate(DCB* dcb,
temp.auth_token = token; temp.auth_token = token;
temp.auth_token_len = token_len; temp.auth_token_len = token_len;
MYSQL_AUTH* instance = (MYSQL_AUTH*)dcb->listener->auth_instance; MYSQL_AUTH* instance = (MYSQL_AUTH*)dcb->listener->auth_instance();
int rc = validate_mysql_user(instance, dcb, &temp, scramble, scramble_len); int rc = validate_mysql_user(instance, dcb, &temp, scramble, scramble_len);
if (rc != MXS_AUTH_SUCCEEDED && service_refresh_users(dcb->service) == 0) if (rc != MXS_AUTH_SUCCEEDED && service_refresh_users(dcb->service) == 0)
@ -723,7 +723,7 @@ int diag_cb(void* data, int columns, char** row, char** field_names)
void mysql_auth_diagnostic(DCB* dcb, Listener* port) void mysql_auth_diagnostic(DCB* dcb, Listener* port)
{ {
MYSQL_AUTH* instance = (MYSQL_AUTH*)port->auth_instance; MYSQL_AUTH* instance = (MYSQL_AUTH*)port->auth_instance();
sqlite3* handle = get_handle(instance); sqlite3* handle = get_handle(instance);
char* err; char* err;
@ -754,7 +754,7 @@ json_t* mysql_auth_diagnostic_json(const Listener* port)
{ {
json_t* rval = json_array(); json_t* rval = json_array();
MYSQL_AUTH* instance = (MYSQL_AUTH*)port->auth_instance; MYSQL_AUTH* instance = (MYSQL_AUTH*)port->auth_instance();
char* err; char* err;
sqlite3* handle = get_handle(instance); sqlite3* handle = get_handle(instance);

View File

@ -136,19 +136,19 @@ static void pam_auth_free_data(DCB* dcb)
*/ */
static int pam_auth_load_users(Listener* listener) static int pam_auth_load_users(Listener* listener)
{ {
PamInstance* inst = static_cast<PamInstance*>(listener->auth_instance); PamInstance* inst = static_cast<PamInstance*>(listener->auth_instance());
return inst->load_users(listener->service); return inst->load_users(listener->service());
} }
static void pam_auth_diagnostic(DCB* dcb, Listener* listener) static void pam_auth_diagnostic(DCB* dcb, Listener* listener)
{ {
PamInstance* inst = static_cast<PamInstance*>(listener->auth_instance); PamInstance* inst = static_cast<PamInstance*>(listener->auth_instance());
inst->diagnostic(dcb); inst->diagnostic(dcb);
} }
static json_t* pam_auth_diagnostic_json(const Listener* listener) static json_t* pam_auth_diagnostic_json(const Listener* listener)
{ {
PamInstance* inst = static_cast<PamInstance*>(listener->auth_instance); PamInstance* inst = static_cast<PamInstance*>(listener->auth_instance());
return inst->diagnostic_json(); return inst->diagnostic_json();
} }

View File

@ -204,7 +204,7 @@ static int httpd_read_event(DCB* dcb)
/** If listener->authenticator is the default authenticator, it means that /** If listener->authenticator is the default authenticator, it means that
* we don't need to check the user credentials. All other authenticators * we don't need to check the user credentials. All other authenticators
* cause a 401 Unauthorized to be returned on the first try. */ * cause a 401 Unauthorized to be returned on the first try. */
bool auth_ok = httpd_default_auth() == dcb->listener->authenticator; bool auth_ok = httpd_default_auth() == std::string(dcb->listener->authenticator());
/** /**
* Get the request headers * Get the request headers

View File

@ -269,10 +269,10 @@ LocalClient* LocalClient::create(MYSQL_session* session, MySQLProtocol* proto, S
for (const auto& listener : listener_find_by_service(service)) for (const auto& listener : listener_find_by_service(service))
{ {
if (listener->port > 0) if (listener->port() > 0)
{ {
/** Pick the first network listener */ /** Pick the first network listener */
rval = create(session, proto, "127.0.0.1", listener->port); rval = create(session, proto, "127.0.0.1", listener->port());
break; break;
} }
} }

View File

@ -673,7 +673,7 @@ static void check_packet(DCB* dcb, GWBUF* buf, int bytes)
if (bytes == MYSQL_AUTH_PACKET_BASE_SIZE) if (bytes == MYSQL_AUTH_PACKET_BASE_SIZE)
{ {
/** This is an SSL request packet */ /** This is an SSL request packet */
mxb_assert(dcb->listener->ssl); mxb_assert(dcb->listener->ssl());
mxb_assert(buflen == bytes && pktlen >= buflen); mxb_assert(buflen == bytes && pktlen >= buflen);
} }
else else
@ -1436,11 +1436,11 @@ static void gw_process_one_new_client(DCB* client_dcb)
// Move the rest of the initialization process to the owning worker // Move the rest of the initialization process to the owning worker
mxs::RoutingWorker* worker = static_cast<mxs::RoutingWorker*>(client_dcb->poll.owner); mxs::RoutingWorker* worker = static_cast<mxs::RoutingWorker*>(client_dcb->poll.owner);
worker->execute([=](){ worker->execute([=]() {
client_dcb->protocol = mysql_protocol_init(client_dcb, client_dcb->fd); client_dcb->protocol = mysql_protocol_init(client_dcb, client_dcb->fd);
MXS_ABORT_IF_NULL(client_dcb->protocol); MXS_ABORT_IF_NULL(client_dcb->protocol);
MySQLSendHandshake(client_dcb); MySQLSendHandshake(client_dcb);
}, mxs::RoutingWorker::EXECUTE_AUTO); }, mxs::RoutingWorker::EXECUTE_AUTO);
MXS_DEBUG("Added dcb %p for fd %d to epoll set.", MXS_DEBUG("Added dcb %p for fd %d to epoll set.",
client_dcb, client_dcb,