Simplify handling of "client data" by having a pointer to it only in DCB and not in session structure. Change name of session->client to session->client_dcb for greater clarity. Temporary free of client data in DCB, to be moved to authenticator when it becomes a module. Fix incorrect name of listener_alloc.
This commit is contained in:
parent
ef8a20cceb
commit
395cbdc103
@ -126,6 +126,8 @@ static int gw_write(DCB *dcb, bool *stop_writing);
|
||||
static int gw_write_SSL(DCB *dcb, bool *stop_writing);
|
||||
static void dcb_log_errors_SSL (DCB *dcb, const char *called_by, int ret);
|
||||
|
||||
static void mysql_auth_free_client_data(DCB *dcb);
|
||||
|
||||
size_t dcb_get_session_id(
|
||||
DCB *dcb)
|
||||
{
|
||||
@ -373,10 +375,10 @@ dcb_final_free(DCB *dcb)
|
||||
* won't try to call dcb_close for client DCB
|
||||
* after this call.
|
||||
*/
|
||||
if (local_session->client == dcb)
|
||||
if (local_session->client_dcb == dcb)
|
||||
{
|
||||
spinlock_acquire(&local_session->ses_lock);
|
||||
local_session->client = NULL;
|
||||
local_session->client_dcb = NULL;
|
||||
spinlock_release(&local_session->ses_lock);
|
||||
}
|
||||
if (SESSION_STATE_DUMMY != local_session->state)
|
||||
@ -385,6 +387,8 @@ dcb_final_free(DCB *dcb)
|
||||
}
|
||||
}
|
||||
|
||||
mysql_auth_free_client_data(dcb);
|
||||
|
||||
if (dcb->protocol && (!DCB_IS_CLONE(dcb)))
|
||||
{
|
||||
free(dcb->protocol);
|
||||
@ -779,8 +783,8 @@ dcb_connect(SERVER *server, SESSION *session, const char *protocol)
|
||||
server->name,
|
||||
server->port,
|
||||
dcb,
|
||||
session->client,
|
||||
session->client->fd);
|
||||
session->client_dcb,
|
||||
session->client_dcb->fd);
|
||||
dcb->state = DCB_STATE_DISCONNECTED;
|
||||
dcb_final_free(dcb);
|
||||
return NULL;
|
||||
@ -793,8 +797,8 @@ dcb_connect(SERVER *server, SESSION *session, const char *protocol)
|
||||
server->name,
|
||||
server->port,
|
||||
dcb,
|
||||
session->client,
|
||||
session->client->fd);
|
||||
session->client_dcb,
|
||||
session->client_dcb->fd);
|
||||
}
|
||||
/**
|
||||
* Successfully connected to backend. Assign file descriptor to dcb
|
||||
@ -2132,9 +2136,9 @@ dcb_isclient(DCB *dcb)
|
||||
{
|
||||
if (dcb->state != DCB_STATE_LISTENING && dcb->session)
|
||||
{
|
||||
if (dcb->session->client)
|
||||
if (dcb->session->client_dcb)
|
||||
{
|
||||
return (dcb->session && dcb == dcb->session->client);
|
||||
return (dcb->session && dcb == dcb->session->client_dcb);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3020,3 +3024,21 @@ dcb_role_name(DCB *dcb)
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Free the client data pointed to by the passed DCB.
|
||||
*
|
||||
* Currently all that is required is to free the storage pointed to by
|
||||
* dcb->data. But this is intended to be implemented as part of the
|
||||
* authentication API at which time this code will be moved into the
|
||||
* MySQL authenticator. If the data structure were to become more complex
|
||||
* the mechanism would still work and be the responsibility of the authenticator.
|
||||
* The DCB should not know authenticator implementation details.
|
||||
*
|
||||
* @param dcb Request handler DCB connected to the client
|
||||
*/
|
||||
static void
|
||||
mysql_auth_free_client_data(DCB *dcb)
|
||||
{
|
||||
free(dcb->data);
|
||||
}
|
@ -56,7 +56,7 @@ static RSA *tmp_rsa_callback(SSL *s, int is_export, int keylength);
|
||||
* @return New listener object or NULL if unable to allocate
|
||||
*/
|
||||
SERV_LISTENER *
|
||||
alloc_listener(char *protocol, char *address, unsigned short port, char *authenticator, SSL_LISTENER *ssl)
|
||||
listener_alloc(char *protocol, char *address, unsigned short port, char *authenticator, SSL_LISTENER *ssl)
|
||||
{
|
||||
SERV_LISTENER *proto = NULL;
|
||||
if ((proto = (SERV_LISTENER *)malloc(sizeof(SERV_LISTENER))) != NULL)
|
||||
|
@ -689,7 +689,7 @@ serviceAddProtocol(SERVICE *service, char *protocol, char *address, unsigned sho
|
||||
{
|
||||
SERV_LISTENER *proto;
|
||||
|
||||
if ((proto = alloc_listener(protocol, address, port, authenticator, ssl)) != NULL)
|
||||
if ((proto = listener_alloc(protocol, address, port, authenticator, ssl)) != NULL)
|
||||
{
|
||||
spinlock_acquire(&service->spin);
|
||||
proto->next = service->ports;
|
||||
|
@ -117,7 +117,7 @@ session_alloc(SERVICE *service, DCB *client_dcb)
|
||||
session->ses_is_child = (bool) DCB_IS_CLONE(client_dcb);
|
||||
spinlock_init(&session->ses_lock);
|
||||
session->service = service;
|
||||
session->client = client_dcb;
|
||||
session->client_dcb = client_dcb;
|
||||
session->n_filters = 0;
|
||||
memset(&session->stats, 0, sizeof(SESSION_STATS));
|
||||
session->stats.connect = time(0);
|
||||
@ -129,7 +129,6 @@ session_alloc(SERVICE *service, DCB *client_dcb)
|
||||
* session has not been made available to the other threads at this
|
||||
* point.
|
||||
*/
|
||||
session->data = client_dcb->data;
|
||||
session->refcount = 1;
|
||||
/*<
|
||||
* This indicates that session is ready to be shared with backend
|
||||
@ -194,7 +193,7 @@ session_alloc(SERVICE *service, DCB *client_dcb)
|
||||
{
|
||||
session->state = SESSION_STATE_ROUTER_READY;
|
||||
|
||||
if (session->client->user == NULL)
|
||||
if (session->client_dcb->user == NULL)
|
||||
{
|
||||
MXS_INFO("Started session [%lu] for %s service ",
|
||||
session->ses_id,
|
||||
@ -205,8 +204,8 @@ session_alloc(SERVICE *service, DCB *client_dcb)
|
||||
MXS_INFO("Started %s client session [%lu] for '%s' from %s",
|
||||
service->name,
|
||||
session->ses_id,
|
||||
session->client->user,
|
||||
session->client->remote);
|
||||
session->client_dcb->user,
|
||||
session->client_dcb->remote);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -215,8 +214,8 @@ session_alloc(SERVICE *service, DCB *client_dcb)
|
||||
"closed as soon as all related DCBs have been closed.",
|
||||
service->name,
|
||||
session->ses_id,
|
||||
session->client->user,
|
||||
session->client->remote);
|
||||
session->client_dcb->user,
|
||||
session->client_dcb->remote);
|
||||
}
|
||||
spinlock_acquire(&session_spin);
|
||||
/** Assign a session id and increase, insert session into list */
|
||||
@ -253,12 +252,11 @@ session_set_dummy(DCB *client_dcb)
|
||||
session->ses_is_child = false;
|
||||
spinlock_init(&session->ses_lock);
|
||||
session->service = NULL;
|
||||
session->client = NULL;
|
||||
session->client_dcb = NULL;
|
||||
session->n_filters = 0;
|
||||
memset(&session->stats, 0, sizeof(SESSION_STATS));
|
||||
session->stats.connect = 0;
|
||||
session->state = SESSION_STATE_DUMMY;
|
||||
session->data = NULL;
|
||||
session->refcount = 1;
|
||||
session->ses_id = 0;
|
||||
session->next = NULL;
|
||||
@ -272,12 +270,12 @@ session_set_dummy(DCB *client_dcb)
|
||||
* counter.
|
||||
* Generic logging setting has precedence over session-specific setting.
|
||||
*
|
||||
* @param ses session
|
||||
* @param session session
|
||||
* @param priority syslog priority
|
||||
*/
|
||||
void session_enable_log_priority(SESSION* ses, int priority)
|
||||
void session_enable_log_priority(SESSION* session, int priority)
|
||||
{
|
||||
ses->enabled_log_priorities |= (1 << priority);
|
||||
session->enabled_log_priorities |= (1 << priority);
|
||||
atomic_add((int *)&mxs_log_session_count[priority], 1);
|
||||
}
|
||||
|
||||
@ -286,14 +284,14 @@ void session_enable_log_priority(SESSION* ses, int priority)
|
||||
* counter.
|
||||
* Generic logging setting has precedence over session-specific setting.
|
||||
*
|
||||
* @param ses session
|
||||
* @param session session
|
||||
* @param priority syslog priority
|
||||
*/
|
||||
void session_disable_log_priority(SESSION* ses, int priority)
|
||||
void session_disable_log_priority(SESSION* session, int priority)
|
||||
{
|
||||
if (ses->enabled_log_priorities & (1 << priority))
|
||||
if (session->enabled_log_priorities & (1 << priority))
|
||||
{
|
||||
ses->enabled_log_priorities &= ~(1 << priority);
|
||||
session->enabled_log_priorities &= ~(1 << priority);
|
||||
atomic_add((int *)&mxs_log_session_count[priority], -1);
|
||||
}
|
||||
}
|
||||
@ -345,9 +343,9 @@ int session_unlink_dcb(SESSION* session,
|
||||
|
||||
if (dcb != NULL)
|
||||
{
|
||||
if (session->client == dcb)
|
||||
if (session->client_dcb == dcb)
|
||||
{
|
||||
session->client = NULL;
|
||||
session->client_dcb = NULL;
|
||||
}
|
||||
dcb->session = NULL;
|
||||
}
|
||||
@ -481,11 +479,6 @@ session_free(SESSION *session)
|
||||
if (!session->ses_is_child)
|
||||
{
|
||||
session->state = SESSION_STATE_FREE;
|
||||
|
||||
if (session->data)
|
||||
{
|
||||
free(session->data);
|
||||
}
|
||||
free(session);
|
||||
}
|
||||
return true;
|
||||
@ -500,19 +493,19 @@ session_free(SESSION *session)
|
||||
int
|
||||
session_isvalid(SESSION *session)
|
||||
{
|
||||
SESSION *ptr;
|
||||
SESSION *list_session;
|
||||
int rval = 0;
|
||||
|
||||
spinlock_acquire(&session_spin);
|
||||
ptr = allSessions;
|
||||
while (ptr)
|
||||
list_session = allSessions;
|
||||
while (list_session)
|
||||
{
|
||||
if (ptr == session)
|
||||
if (list_session == session)
|
||||
{
|
||||
rval = 1;
|
||||
break;
|
||||
}
|
||||
ptr = ptr->next;
|
||||
list_session = list_session->next;
|
||||
}
|
||||
spinlock_release(&session_spin);
|
||||
|
||||
@ -533,7 +526,7 @@ printSession(SESSION *session)
|
||||
printf("Session %p\n", session);
|
||||
printf("\tState: %s\n", session_state(session->state));
|
||||
printf("\tService: %s (%p)\n", session->service->name, session->service);
|
||||
printf("\tClient DCB: %p\n", session->client);
|
||||
printf("\tClient DCB: %p\n", session->client_dcb);
|
||||
printf("\tConnected: %s",
|
||||
asctime_r(localtime_r(&session->stats.connect, &result), timebuf));
|
||||
}
|
||||
@ -547,14 +540,14 @@ printSession(SESSION *session)
|
||||
void
|
||||
printAllSessions()
|
||||
{
|
||||
SESSION *ptr;
|
||||
SESSION *list_session;
|
||||
|
||||
spinlock_acquire(&session_spin);
|
||||
ptr = allSessions;
|
||||
while (ptr)
|
||||
list_session = allSessions;
|
||||
while (list_session)
|
||||
{
|
||||
printSession(ptr);
|
||||
ptr = ptr->next;
|
||||
printSession(list_session);
|
||||
list_session = list_session->next;
|
||||
}
|
||||
spinlock_release(&session_spin);
|
||||
}
|
||||
@ -569,29 +562,29 @@ printAllSessions()
|
||||
void
|
||||
CheckSessions()
|
||||
{
|
||||
SESSION *ptr;
|
||||
SESSION *list_session;
|
||||
int noclients = 0;
|
||||
int norouter = 0;
|
||||
|
||||
spinlock_acquire(&session_spin);
|
||||
ptr = allSessions;
|
||||
while (ptr)
|
||||
list_session = allSessions;
|
||||
while (list_session)
|
||||
{
|
||||
if (ptr->state != SESSION_STATE_LISTENER ||
|
||||
ptr->state != SESSION_STATE_LISTENER_STOPPED)
|
||||
if (list_session->state != SESSION_STATE_LISTENER ||
|
||||
list_session->state != SESSION_STATE_LISTENER_STOPPED)
|
||||
{
|
||||
if (ptr->client == NULL && ptr->refcount)
|
||||
if (list_session->client_dcb == NULL && list_session->refcount)
|
||||
{
|
||||
if (noclients == 0)
|
||||
{
|
||||
printf("Sessions without a client DCB.\n");
|
||||
printf("==============================\n");
|
||||
}
|
||||
printSession(ptr);
|
||||
printSession(list_session);
|
||||
noclients++;
|
||||
}
|
||||
}
|
||||
ptr = ptr->next;
|
||||
list_session = list_session->next;
|
||||
}
|
||||
spinlock_release(&session_spin);
|
||||
if (noclients)
|
||||
@ -599,24 +592,24 @@ CheckSessions()
|
||||
printf("%d Sessions have no clients\n", noclients);
|
||||
}
|
||||
spinlock_acquire(&session_spin);
|
||||
ptr = allSessions;
|
||||
while (ptr)
|
||||
list_session = allSessions;
|
||||
while (list_session)
|
||||
{
|
||||
if (ptr->state != SESSION_STATE_LISTENER ||
|
||||
ptr->state != SESSION_STATE_LISTENER_STOPPED)
|
||||
if (list_session->state != SESSION_STATE_LISTENER ||
|
||||
list_session->state != SESSION_STATE_LISTENER_STOPPED)
|
||||
{
|
||||
if (ptr->router_session == NULL && ptr->refcount)
|
||||
if (list_session->router_session == NULL && list_session->refcount)
|
||||
{
|
||||
if (norouter == 0)
|
||||
{
|
||||
printf("Sessions without a router session.\n");
|
||||
printf("==================================\n");
|
||||
}
|
||||
printSession(ptr);
|
||||
printSession(list_session);
|
||||
norouter++;
|
||||
}
|
||||
}
|
||||
ptr = ptr->next;
|
||||
list_session = list_session->next;
|
||||
}
|
||||
spinlock_release(&session_spin);
|
||||
if (norouter)
|
||||
@ -638,36 +631,36 @@ dprintAllSessions(DCB *dcb)
|
||||
{
|
||||
struct tm result;
|
||||
char timebuf[40];
|
||||
SESSION *ptr;
|
||||
SESSION *list_session;
|
||||
|
||||
spinlock_acquire(&session_spin);
|
||||
ptr = allSessions;
|
||||
while (ptr)
|
||||
list_session = allSessions;
|
||||
while (list_session)
|
||||
{
|
||||
dcb_printf(dcb, "Session %d (%p)\n",ptr->ses_id, ptr);
|
||||
dcb_printf(dcb, "\tState: %s\n", session_state(ptr->state));
|
||||
dcb_printf(dcb, "\tService: %s (%p)\n", ptr->service->name, ptr->service);
|
||||
dcb_printf(dcb, "\tClient DCB: %p\n", ptr->client);
|
||||
dcb_printf(dcb, "Session %d (%p)\n",list_session->ses_id, list_session);
|
||||
dcb_printf(dcb, "\tState: %s\n", session_state(list_session->state));
|
||||
dcb_printf(dcb, "\tService: %s (%p)\n", list_session->service->name, list_session->service);
|
||||
dcb_printf(dcb, "\tClient DCB: %p\n", list_session->client_dcb);
|
||||
|
||||
if (ptr->client && ptr->client->remote)
|
||||
if (list_session->client_dcb && list_session->client_dcb->remote)
|
||||
{
|
||||
dcb_printf(dcb, "\tClient Address: %s%s%s\n",
|
||||
ptr->client->user?ptr->client->user:"",
|
||||
ptr->client->user?"@":"",
|
||||
ptr->client->remote);
|
||||
list_session->client_dcb->user?list_session->client_dcb->user:"",
|
||||
list_session->client_dcb->user?"@":"",
|
||||
list_session->client_dcb->remote);
|
||||
}
|
||||
|
||||
dcb_printf(dcb, "\tConnected: %s",
|
||||
asctime_r(localtime_r(&ptr->stats.connect, &result), timebuf));
|
||||
asctime_r(localtime_r(&list_session->stats.connect, &result), timebuf));
|
||||
|
||||
if (ptr->client && ptr->client->state == DCB_STATE_POLLING)
|
||||
if (list_session->client_dcb && list_session->client_dcb->state == DCB_STATE_POLLING)
|
||||
{
|
||||
double idle = (hkheartbeat - ptr->client->last_read);
|
||||
double idle = (hkheartbeat - list_session->client_dcb->last_read);
|
||||
idle = idle > 0 ? idle/10.0:0;
|
||||
dcb_printf(dcb, "\tIdle: %.0f seconds\n",idle);
|
||||
}
|
||||
|
||||
ptr = ptr->next;
|
||||
list_session = list_session->next;
|
||||
}
|
||||
spinlock_release(&session_spin);
|
||||
}
|
||||
@ -679,43 +672,43 @@ dprintAllSessions(DCB *dcb)
|
||||
* to display all active sessions within the gateway
|
||||
*
|
||||
* @param dcb The DCB to print to
|
||||
* @param ptr The session to print
|
||||
* @param print_session The session to print
|
||||
*/
|
||||
void
|
||||
dprintSession(DCB *dcb, SESSION *ptr)
|
||||
dprintSession(DCB *dcb, SESSION *print_session)
|
||||
{
|
||||
struct tm result;
|
||||
char buf[30];
|
||||
int i;
|
||||
|
||||
dcb_printf(dcb, "Session %d (%p)\n",ptr->ses_id, ptr);
|
||||
dcb_printf(dcb, "\tState: %s\n", session_state(ptr->state));
|
||||
dcb_printf(dcb, "\tService: %s (%p)\n", ptr->service->name, ptr->service);
|
||||
dcb_printf(dcb, "\tClient DCB: %p\n", ptr->client);
|
||||
if (ptr->client && ptr->client->remote)
|
||||
dcb_printf(dcb, "Session %d (%p)\n",print_session->ses_id, print_session);
|
||||
dcb_printf(dcb, "\tState: %s\n", session_state(print_session->state));
|
||||
dcb_printf(dcb, "\tService: %s (%p)\n", print_session->service->name, print_session->service);
|
||||
dcb_printf(dcb, "\tClient DCB: %p\n", print_session->client_dcb);
|
||||
if (print_session->client_dcb && print_session->client_dcb->remote)
|
||||
{
|
||||
double idle = (hkheartbeat - ptr->client->last_read);
|
||||
double idle = (hkheartbeat - print_session->client_dcb->last_read);
|
||||
idle = idle > 0 ? idle/10.f : 0;
|
||||
dcb_printf(dcb, "\tClient Address: %s%s%s\n",
|
||||
ptr->client->user?ptr->client->user:"",
|
||||
ptr->client->user?"@":"",
|
||||
ptr->client->remote);
|
||||
print_session->client_dcb->user?print_session->client_dcb->user:"",
|
||||
print_session->client_dcb->user?"@":"",
|
||||
print_session->client_dcb->remote);
|
||||
dcb_printf(dcb, "\tConnected: %s\n",
|
||||
asctime_r(localtime_r(&ptr->stats.connect, &result), buf));
|
||||
if (ptr->client->state == DCB_STATE_POLLING)
|
||||
asctime_r(localtime_r(&print_session->stats.connect, &result), buf));
|
||||
if (print_session->client_dcb->state == DCB_STATE_POLLING)
|
||||
{
|
||||
dcb_printf(dcb, "\tIdle: %.0f seconds\n",idle);
|
||||
}
|
||||
|
||||
}
|
||||
if (ptr->n_filters)
|
||||
if (print_session->n_filters)
|
||||
{
|
||||
for (i = 0; i < ptr->n_filters; i++)
|
||||
for (i = 0; i < print_session->n_filters; i++)
|
||||
{
|
||||
dcb_printf(dcb, "\tFilter: %s\n",
|
||||
ptr->filters[i].filter->name);
|
||||
ptr->filters[i].filter->obj->diagnostics(ptr->filters[i].instance,
|
||||
ptr->filters[i].session,
|
||||
print_session->filters[i].filter->name);
|
||||
print_session->filters[i].filter->obj->diagnostics(print_session->filters[i].instance,
|
||||
print_session->filters[i].session,
|
||||
dcb);
|
||||
}
|
||||
}
|
||||
@ -732,26 +725,26 @@ dprintSession(DCB *dcb, SESSION *ptr)
|
||||
void
|
||||
dListSessions(DCB *dcb)
|
||||
{
|
||||
SESSION *ptr;
|
||||
SESSION *list_session;
|
||||
|
||||
spinlock_acquire(&session_spin);
|
||||
ptr = allSessions;
|
||||
if (ptr)
|
||||
list_session = allSessions;
|
||||
if (list_session)
|
||||
{
|
||||
dcb_printf(dcb, "Sessions.\n");
|
||||
dcb_printf(dcb, "-----------------+-----------------+----------------+--------------------------\n");
|
||||
dcb_printf(dcb, "Session | Client | Service | State\n");
|
||||
dcb_printf(dcb, "-----------------+-----------------+----------------+--------------------------\n");
|
||||
}
|
||||
while (ptr)
|
||||
while (list_session)
|
||||
{
|
||||
dcb_printf(dcb, "%-16p | %-15s | %-14s | %s\n", ptr,
|
||||
((ptr->client && ptr->client->remote)
|
||||
? ptr->client->remote : ""),
|
||||
(ptr->service && ptr->service->name ? ptr->service->name
|
||||
dcb_printf(dcb, "%-16p | %-15s | %-14s | %s\n", list_session,
|
||||
((list_session->client_dcb && list_session->client_dcb->remote)
|
||||
? list_session->client_dcb->remote : ""),
|
||||
(list_session->service && list_session->service->name ? list_session->service->name
|
||||
: ""),
|
||||
session_state(ptr->state));
|
||||
ptr = ptr->next;
|
||||
session_state(list_session->state));
|
||||
list_session = list_session->next;
|
||||
}
|
||||
if (allSessions)
|
||||
{
|
||||
@ -905,7 +898,7 @@ session_reply(void *instance, void *session, GWBUF *data)
|
||||
{
|
||||
SESSION *the_session = (SESSION *)session;
|
||||
|
||||
return the_session->client->func.write(the_session->client, data);
|
||||
return the_session->client_dcb->func.write(the_session->client_dcb, data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -916,9 +909,9 @@ session_reply(void *instance, void *session, GWBUF *data)
|
||||
char *
|
||||
session_get_remote(SESSION *session)
|
||||
{
|
||||
if (session && session->client)
|
||||
if (session && session->client_dcb)
|
||||
{
|
||||
return session->client->remote;
|
||||
return session->client_dcb->remote;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@ -958,7 +951,7 @@ return_succp:
|
||||
char *
|
||||
session_getUser(SESSION *session)
|
||||
{
|
||||
return (session && session->client) ? session->client->user : NULL;
|
||||
return (session && session->client_dcb) ? session->client_dcb->user : NULL;
|
||||
}
|
||||
/**
|
||||
* Return the pointer to the list of all sessions.
|
||||
@ -996,17 +989,17 @@ void process_idle_sessions()
|
||||
* check for it once per second. One heartbeat is 100 milliseconds. */
|
||||
next_timeout_check = hkheartbeat + 10;
|
||||
spinlock_acquire(&session_spin);
|
||||
SESSION *ses = get_all_sessions();
|
||||
SESSION *all_session = get_all_sessions();
|
||||
|
||||
while (ses)
|
||||
while (all_session)
|
||||
{
|
||||
if (ses->service && ses->client && ses->client->state == DCB_STATE_POLLING &&
|
||||
hkheartbeat - ses->client->last_read > ses->service->conn_idle_timeout * 10)
|
||||
if (all_session->service && all_session->client_dcb && all_session->client_dcb->state == DCB_STATE_POLLING &&
|
||||
hkheartbeat - all_session->client_dcb->last_read > all_session->service->conn_idle_timeout * 10)
|
||||
{
|
||||
dcb_close(ses->client);
|
||||
dcb_close(all_session->client_dcb);
|
||||
}
|
||||
|
||||
ses = ses->next;
|
||||
all_session = all_session->next;
|
||||
}
|
||||
spinlock_release(&session_spin);
|
||||
}
|
||||
@ -1037,20 +1030,20 @@ sessionRowCallback(RESULTSET *set, void *data)
|
||||
int i = 0;
|
||||
char buf[20];
|
||||
RESULT_ROW *row;
|
||||
SESSION *ptr;
|
||||
SESSION *list_session;
|
||||
|
||||
spinlock_acquire(&session_spin);
|
||||
ptr = allSessions;
|
||||
list_session = allSessions;
|
||||
/* Skip to the first non-listener if not showing listeners */
|
||||
while (ptr && cbdata->filter == SESSION_LIST_CONNECTION &&
|
||||
ptr->state == SESSION_STATE_LISTENER)
|
||||
while (list_session && cbdata->filter == SESSION_LIST_CONNECTION &&
|
||||
list_session->state == SESSION_STATE_LISTENER)
|
||||
{
|
||||
ptr = ptr->next;
|
||||
list_session = list_session->next;
|
||||
}
|
||||
while (i < cbdata->index && ptr)
|
||||
while (i < cbdata->index && list_session)
|
||||
{
|
||||
if (cbdata->filter == SESSION_LIST_CONNECTION &&
|
||||
ptr->state != SESSION_STATE_LISTENER)
|
||||
list_session->state != SESSION_STATE_LISTENER)
|
||||
{
|
||||
i++;
|
||||
}
|
||||
@ -1058,15 +1051,15 @@ sessionRowCallback(RESULTSET *set, void *data)
|
||||
{
|
||||
i++;
|
||||
}
|
||||
ptr = ptr->next;
|
||||
list_session = list_session->next;
|
||||
}
|
||||
/* Skip to the next non-listener if not showing listeners */
|
||||
while (ptr && cbdata->filter == SESSION_LIST_CONNECTION &&
|
||||
ptr->state == SESSION_STATE_LISTENER)
|
||||
while (list_session && cbdata->filter == SESSION_LIST_CONNECTION &&
|
||||
list_session->state == SESSION_STATE_LISTENER)
|
||||
{
|
||||
ptr = ptr->next;
|
||||
list_session = list_session->next;
|
||||
}
|
||||
if (ptr == NULL)
|
||||
if (list_session == NULL)
|
||||
{
|
||||
spinlock_release(&session_spin);
|
||||
free(data);
|
||||
@ -1074,14 +1067,14 @@ sessionRowCallback(RESULTSET *set, void *data)
|
||||
}
|
||||
cbdata->index++;
|
||||
row = resultset_make_row(set);
|
||||
snprintf(buf,19, "%p", ptr);
|
||||
snprintf(buf,19, "%p", list_session);
|
||||
buf[19] = '\0';
|
||||
resultset_row_set(row, 0, buf);
|
||||
resultset_row_set(row, 1, ((ptr->client && ptr->client->remote)
|
||||
? ptr->client->remote : ""));
|
||||
resultset_row_set(row, 2, (ptr->service && ptr->service->name
|
||||
? ptr->service->name : ""));
|
||||
resultset_row_set(row, 3, session_state(ptr->state));
|
||||
resultset_row_set(row, 1, ((list_session->client_dcb && list_session->client_dcb->remote)
|
||||
? list_session->client_dcb->remote : ""));
|
||||
resultset_row_set(row, 2, (list_session->service && list_session->service->name
|
||||
? list_session->service->name : ""));
|
||||
resultset_row_set(row, 3, session_state(list_session->state));
|
||||
spinlock_release(&session_spin);
|
||||
return row;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ typedef struct servlistener
|
||||
struct servlistener *next; /**< Next service protocol */
|
||||
} SERV_LISTENER;
|
||||
|
||||
SERV_LISTENER *alloc_listener(char *protocol, char *address, unsigned short port, char *authenticator, SSL_LISTENER *ssl);
|
||||
SERV_LISTENER *listener_alloc(char *protocol, char *address, unsigned short port, char *authenticator, SSL_LISTENER *ssl);
|
||||
int listener_set_ssl_version(SSL_LISTENER *ssl_listener, char* version);
|
||||
void listener_set_certificates(SSL_LISTENER *ssl_listener, char* cert, char* key, char* ca_cert);
|
||||
int listener_init_SSL(SSL_LISTENER *ssl_listener);
|
||||
|
@ -129,8 +129,7 @@ typedef struct session
|
||||
session_state_t state; /*< Current descriptor state */
|
||||
size_t ses_id; /*< Unique session identifier */
|
||||
int enabled_log_priorities; /*< Bitfield of enabled syslog priorities */
|
||||
struct dcb *client; /*< The client connection */
|
||||
void *data; /*< The session data */
|
||||
struct dcb *client_dcb; /*< The client connection */
|
||||
void *router_session; /*< The router instance data */
|
||||
SESSION_STATS stats; /*< Session statistics */
|
||||
struct service *service; /*< The service this session is using */
|
||||
@ -153,7 +152,7 @@ extern bool check_timeouts;
|
||||
* hk_heartbeat.h */
|
||||
extern long next_timeout_check;
|
||||
|
||||
#define SESSION_PROTOCOL(x, type) DCB_PROTOCOL((x)->client, type)
|
||||
#define SESSION_PROTOCOL(x, type) DCB_PROTOCOL((x)->client_dcb, type)
|
||||
|
||||
/**
|
||||
* A convenience macro that can be used by the protocol modules to route
|
||||
|
@ -1429,15 +1429,15 @@ GWBUF* gen_dummy_error(FW_SESSION* session, char* msg)
|
||||
unsigned int errlen;
|
||||
|
||||
if (session == NULL || session->session == NULL ||
|
||||
session->session->data == NULL ||
|
||||
session->session->client == NULL)
|
||||
session->session->client_dcb == NULL ||
|
||||
session->session->client_dcb->data == NULL)
|
||||
{
|
||||
MXS_ERROR("Firewall filter session missing data.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dcb = session->session->client;
|
||||
mysql_session = (MYSQL_session*) session->session->data;
|
||||
dcb = session->session->client_dcb;
|
||||
mysql_session = (MYSQL_session*) dcb->data;
|
||||
errlen = msg != NULL ? strlen(msg) : 0;
|
||||
errmsg = (char*) malloc((512 + errlen) * sizeof(char));
|
||||
|
||||
@ -1955,7 +1955,7 @@ routeQuery(FILTER *instance, void *session, GWBUF *queue)
|
||||
bool accept = my_instance->def_op;
|
||||
char *msg = NULL, *fullquery = NULL, *ipaddr;
|
||||
char uname_addr[128];
|
||||
DCB* dcb = my_session->session->client;
|
||||
DCB* dcb = my_session->session->client_dcb;
|
||||
USER* user = NULL;
|
||||
GWBUF* forward;
|
||||
ipaddr = strdup(dcb->remote);
|
||||
|
@ -992,7 +992,7 @@ newSession(FILTER *instance, SESSION *session)
|
||||
my_session->was_query = false;
|
||||
my_session->uid = NULL;
|
||||
my_session->session = session;
|
||||
sessauth = my_session->session->data;
|
||||
sessauth = my_session->session->client_dcb->data;
|
||||
if (sessauth->db && strnlen(sessauth->db, 128) > 0)
|
||||
{
|
||||
my_session->db = strdup(sessauth->db);
|
||||
|
@ -251,7 +251,7 @@ orphan_free(void* data)
|
||||
*/
|
||||
|
||||
if (ptr->session->state == SESSION_STATE_STOPPING &&
|
||||
ptr->session->refcount == 0 && ptr->session->client == NULL)
|
||||
ptr->session->refcount == 0 && ptr->session->client_dcb == NULL)
|
||||
{
|
||||
ptr->session->state = SESSION_STATE_TO_BE_FREED;
|
||||
}
|
||||
@ -485,7 +485,7 @@ newSession(FILTER *instance, SESSION *session)
|
||||
my_session->active = 1;
|
||||
my_session->residual = 0;
|
||||
my_session->tee_replybuf = NULL;
|
||||
my_session->client_dcb = session->client;
|
||||
my_session->client_dcb = session->client_dcb;
|
||||
my_session->instance = my_instance;
|
||||
my_session->client_multistatement = false;
|
||||
my_session->queue = NULL;
|
||||
@ -518,7 +518,7 @@ newSession(FILTER *instance, SESSION *session)
|
||||
FILTER_DEF* dummy;
|
||||
UPSTREAM* dummy_upstream;
|
||||
|
||||
if ((dcb = dcb_clone(session->client)) == NULL)
|
||||
if ((dcb = dcb_clone(session->client_dcb)) == NULL)
|
||||
{
|
||||
freeSession(instance, (void *) my_session);
|
||||
my_session = NULL;
|
||||
@ -578,7 +578,7 @@ newSession(FILTER *instance, SESSION *session)
|
||||
}
|
||||
|
||||
ses->tail = *dummy_upstream;
|
||||
MySQLProtocol* protocol = (MySQLProtocol*) session->client->protocol;
|
||||
MySQLProtocol* protocol = (MySQLProtocol*) session->client_dcb->protocol;
|
||||
my_session->use_ok = protocol->client_capabilities & (1 << 6);
|
||||
free(dummy_upstream);
|
||||
}
|
||||
|
@ -45,8 +45,8 @@ int harness_init(int argc, char** argv, HARNESS_INSTANCE** inst){
|
||||
dcb->func.write = dcbfun;
|
||||
dcb->remote = strdup("0.0.0.0");
|
||||
dcb->user = strdup("user");
|
||||
instance.session->client = (void*)dcb;
|
||||
instance.session->data = (void*)mysqlsess;
|
||||
instance.session->client_dcb = (void*)dcb;
|
||||
instance.session->client_dcb->data = (void*)mysqlsess;
|
||||
|
||||
getcwd(cwd,sizeof(cwd));
|
||||
sprintf(tmp,"%s",cwd);
|
||||
|
@ -549,3 +549,4 @@ static int combined_auth_check(
|
||||
auth_ret = check_db_name_after_auth(dcb, database, auth_ret);
|
||||
return auth_ret;
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ static MYSQL_session* gw_get_shared_session_auth_info(DCB* dcb)
|
||||
|
||||
if (dcb->session->state != SESSION_STATE_ALLOC && dcb->session->state != SESSION_STATE_DUMMY)
|
||||
{
|
||||
auth_info = dcb->session->data;
|
||||
auth_info = dcb->session->client_dcb->data;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -549,8 +549,8 @@ static int gw_read_backend_event(DCB *dcb)
|
||||
* still listening the socket for replies.
|
||||
*/
|
||||
if (dcb->session->state == SESSION_STATE_ROUTER_READY &&
|
||||
dcb->session->client != NULL &&
|
||||
dcb->session->client->state == DCB_STATE_POLLING &&
|
||||
dcb->session->client_dcb != NULL &&
|
||||
dcb->session->client_dcb->state == DCB_STATE_POLLING &&
|
||||
(session->router_session || router->getCapabilities() & RCAP_TYPE_NO_RSESSION))
|
||||
{
|
||||
client_protocol = SESSION_PROTOCOL(dcb->session,
|
||||
@ -571,7 +571,7 @@ static int gw_read_backend_event(DCB *dcb)
|
||||
}
|
||||
goto return_rc;
|
||||
}
|
||||
else if (dcb->session->client->dcb_role == DCB_ROLE_INTERNAL)
|
||||
else if (dcb->session->client_dcb->dcb_role == DCB_ROLE_INTERNAL)
|
||||
{
|
||||
gwbuf_set_type(read_buffer, GWBUF_TYPE_MYSQL);
|
||||
router->clientReply(router_instance, session->router_session, read_buffer, dcb);
|
||||
@ -614,14 +614,14 @@ static int gw_write_backend_event(DCB *dcb)
|
||||
{
|
||||
data = (uint8_t *)GWBUF_DATA(dcb->writeq);
|
||||
|
||||
if (dcb->session->client == NULL)
|
||||
if (dcb->session->client_dcb == NULL)
|
||||
{
|
||||
rc = 0;
|
||||
}
|
||||
else if (!(MYSQL_IS_COM_QUIT(data)))
|
||||
{
|
||||
/*< vraa : errorHandle */
|
||||
mysql_send_custom_error(dcb->session->client,
|
||||
mysql_send_custom_error(dcb->session->client_dcb,
|
||||
1,
|
||||
0,
|
||||
"Writing to backend failed due invalid Maxscale "
|
||||
@ -937,14 +937,14 @@ static int gw_create_backend_connection(DCB *backend_dcb,
|
||||
}
|
||||
|
||||
/** Copy client flags to backend protocol */
|
||||
if (backend_dcb->session->client->protocol)
|
||||
if (backend_dcb->session->client_dcb->protocol)
|
||||
{
|
||||
/** Copy client flags to backend protocol */
|
||||
protocol->client_capabilities =
|
||||
((MySQLProtocol *)(backend_dcb->session->client->protocol))->client_capabilities;
|
||||
((MySQLProtocol *)(backend_dcb->session->client_dcb->protocol))->client_capabilities;
|
||||
/** Copy client charset to backend protocol */
|
||||
protocol->charset =
|
||||
((MySQLProtocol *)(backend_dcb->session->client->protocol))->charset;
|
||||
((MySQLProtocol *)(backend_dcb->session->client_dcb->protocol))->charset;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -971,7 +971,7 @@ static int gw_create_backend_connection(DCB *backend_dcb,
|
||||
server->name,
|
||||
server->port,
|
||||
protocol->fd,
|
||||
session->client->fd);
|
||||
session->client_dcb->fd);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
@ -984,7 +984,7 @@ static int gw_create_backend_connection(DCB *backend_dcb,
|
||||
server->name,
|
||||
server->port,
|
||||
protocol->fd,
|
||||
session->client->fd);
|
||||
session->client_dcb->fd);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -996,7 +996,7 @@ static int gw_create_backend_connection(DCB *backend_dcb,
|
||||
server->name,
|
||||
server->port,
|
||||
protocol->fd,
|
||||
session->client->fd);
|
||||
session->client_dcb->fd);
|
||||
break;
|
||||
} /*< switch */
|
||||
|
||||
@ -1148,7 +1148,7 @@ static int gw_backend_close(DCB *dcb)
|
||||
CHK_SESSION(session);
|
||||
/**
|
||||
* The lock is needed only to protect the read of session->state and
|
||||
* session->client values. Client's state may change by other thread
|
||||
* session->client_dcb values. Client's state may change by other thread
|
||||
* but client's close and adding client's DCB to zombies list is executed
|
||||
* only if client's DCB's state does _not_ change in parallel.
|
||||
*/
|
||||
@ -1158,16 +1158,16 @@ static int gw_backend_close(DCB *dcb)
|
||||
* Otherwise only this backend connection is closed.
|
||||
*/
|
||||
if (session->state == SESSION_STATE_STOPPING &&
|
||||
session->client != NULL)
|
||||
session->client_dcb != NULL)
|
||||
{
|
||||
if (session->client->state == DCB_STATE_POLLING)
|
||||
if (session->client_dcb->state == DCB_STATE_POLLING)
|
||||
{
|
||||
DCB *temp;
|
||||
spinlock_release(&session->ses_lock);
|
||||
|
||||
/** Close client DCB */
|
||||
temp = session->client;
|
||||
session->client = NULL;
|
||||
temp = session->client_dcb;
|
||||
session->client_dcb = NULL;
|
||||
dcb_close(temp);
|
||||
}
|
||||
else
|
||||
@ -1243,7 +1243,7 @@ static int backend_write_delayqueue(DCB *dcb)
|
||||
MYSQL_session* mses;
|
||||
GWBUF* new_packet;
|
||||
|
||||
mses = (MYSQL_session *)dcb->session->client->data;
|
||||
mses = (MYSQL_session *)dcb->session->client_dcb->data;
|
||||
new_packet = gw_create_change_user_packet(mses,
|
||||
(MySQLProtocol *)dcb->protocol);
|
||||
/**
|
||||
@ -1327,9 +1327,9 @@ static int gw_change_user(DCB *backend,
|
||||
int rv = -1;
|
||||
int auth_ret = 1;
|
||||
|
||||
current_session = (MYSQL_session *)in_session->client->data;
|
||||
current_session = (MYSQL_session *)in_session->client_dcb->data;
|
||||
backend_protocol = backend->protocol;
|
||||
client_protocol = in_session->client->protocol;
|
||||
client_protocol = in_session->client_dcb->protocol;
|
||||
|
||||
/* now get the user, after 4 bytes header and 1 byte command */
|
||||
client_auth_packet += 5;
|
||||
@ -1386,7 +1386,7 @@ static int gw_change_user(DCB *backend,
|
||||
* decode the token and check the password.
|
||||
* Note: if auth_token_len == 0 && auth_token == NULL, user is without password
|
||||
*/
|
||||
auth_ret = gw_check_mysql_scramble_data(backend->session->client,
|
||||
auth_ret = gw_check_mysql_scramble_data(backend->session->client_dcb,
|
||||
auth_token,
|
||||
auth_token_len,
|
||||
client_protocol->scramble,
|
||||
@ -1396,11 +1396,11 @@ static int gw_change_user(DCB *backend,
|
||||
|
||||
if (auth_ret != 0)
|
||||
{
|
||||
if (!service_refresh_users(backend->session->client->service))
|
||||
if (!service_refresh_users(backend->session->client_dcb->service))
|
||||
{
|
||||
/* Try authentication again with new repository data */
|
||||
/* Note: if no auth client authentication will fail */
|
||||
auth_ret = gw_check_mysql_scramble_data(backend->session->client,
|
||||
auth_ret = gw_check_mysql_scramble_data(backend->session->client_dcb,
|
||||
auth_token, auth_token_len,
|
||||
client_protocol->scramble,
|
||||
sizeof(client_protocol->scramble),
|
||||
@ -1441,7 +1441,7 @@ static int gw_change_user(DCB *backend,
|
||||
* reply to the client.
|
||||
*/
|
||||
message = create_auth_fail_str(username,
|
||||
backend->session->client->remote,
|
||||
backend->session->client_dcb->remote,
|
||||
password_set,
|
||||
"",
|
||||
auth_ret);
|
||||
|
@ -542,14 +542,8 @@ int gw_read_client_event(DCB* dcb)
|
||||
protocol->protocol_auth_state = MYSQL_AUTH_FAILED;
|
||||
mysql_client_auth_error_handling(dcb, auth_val);
|
||||
/**
|
||||
* Release MYSQL_session since it is not used anymore.
|
||||
* Close DCB and which will release MYSQL_session
|
||||
*/
|
||||
if (!DCB_IS_CLONE(dcb))
|
||||
{
|
||||
free(dcb->data);
|
||||
}
|
||||
dcb->data = NULL;
|
||||
|
||||
dcb_close(dcb);
|
||||
}
|
||||
/* One way or another, the buffer is now fully processed */
|
||||
|
@ -1282,7 +1282,7 @@ int gw_send_change_user_to_backend(char *dbname,
|
||||
int rc;
|
||||
MYSQL_session* mses;
|
||||
|
||||
mses = (MYSQL_session*)conn->owner_dcb->session->client->data;
|
||||
mses = (MYSQL_session*)conn->owner_dcb->session->client_dcb->data;
|
||||
buffer = gw_create_change_user_packet(mses, conn);
|
||||
rc = conn->owner_dcb->func.write(conn->owner_dcb, buffer);
|
||||
|
||||
|
@ -754,7 +754,7 @@ ROUTER_SLAVE *slave;
|
||||
slave->uuid = NULL;
|
||||
slave->hostname = NULL;
|
||||
spinlock_init(&slave->catch_lock);
|
||||
slave->dcb = session->client;
|
||||
slave->dcb = session->client_dcb;
|
||||
slave->router = inst;
|
||||
#ifdef BLFILE_IN_SLAVE
|
||||
slave->file = NULL;
|
||||
|
@ -202,14 +202,14 @@ CLI_SESSION *client;
|
||||
session->state = SESSION_STATE_READY;
|
||||
client->mode = inst->mode;
|
||||
|
||||
dcb_printf(session->client, "Welcome the MariaDB Corporation MaxScale Debug Interface (%s).\n",
|
||||
dcb_printf(session->client_dcb, "Welcome the MariaDB Corporation MaxScale Debug Interface (%s).\n",
|
||||
version_str);
|
||||
if (client->mode == CLIM_DEVELOPER)
|
||||
{
|
||||
dcb_printf(session->client, "WARNING: This interface is meant for developer usage,\n");
|
||||
dcb_printf(session->client, "passing incorrect addresses to commands can endanger your MaxScale server.\n\n");
|
||||
dcb_printf(session->client_dcb, "WARNING: This interface is meant for developer usage,\n");
|
||||
dcb_printf(session->client_dcb, "passing incorrect addresses to commands can endanger your MaxScale server.\n\n");
|
||||
}
|
||||
dcb_printf(session->client, "Type help for a list of available commands.\n\n");
|
||||
dcb_printf(session->client_dcb, "Type help for a list of available commands.\n\n");
|
||||
|
||||
return (void *)client;
|
||||
}
|
||||
@ -285,9 +285,9 @@ CLI_SESSION *session = (CLI_SESSION *)router_session;
|
||||
if (strrchr(session->cmdbuf, '\n'))
|
||||
{
|
||||
if (execute_cmd(session))
|
||||
dcb_printf(session->session->client, "MaxScale> ");
|
||||
dcb_printf(session->session->client_dcb, "MaxScale> ");
|
||||
else
|
||||
dcb_close(session->session->client);
|
||||
dcb_close(session->session->client_dcb);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -927,7 +927,7 @@ convert_arg(int mode, char *arg, int arg_type)
|
||||
int
|
||||
execute_cmd(CLI_SESSION *cli)
|
||||
{
|
||||
DCB *dcb = cli->session->client;
|
||||
DCB *dcb = cli->session->client_dcb;
|
||||
int argc, i, j, found = 0;
|
||||
char *args[MAXARGS + 1];
|
||||
unsigned long arg1, arg2, arg3;
|
||||
|
@ -211,7 +211,7 @@ INFO_SESSION *client;
|
||||
return NULL;
|
||||
}
|
||||
client->session = session;
|
||||
client->dcb = session->client;
|
||||
client->dcb = session->client_dcb;
|
||||
client->queue = NULL;
|
||||
|
||||
spinlock_acquire(&inst->lock);
|
||||
@ -309,7 +309,7 @@ static void handleError(
|
||||
}
|
||||
spinlock_acquire(&session->ses_lock);
|
||||
sesstate = session->state;
|
||||
client_dcb = session->client;
|
||||
client_dcb = session->client_dcb;
|
||||
|
||||
if (sesstate == SESSION_STATE_ROUTER_READY)
|
||||
{
|
||||
|
@ -847,7 +847,7 @@ diagnostics(ROUTER *router, DCB *dcb)
|
||||
static void
|
||||
clientReply(ROUTER *instance, void *router_session, GWBUF *queue, DCB *backend_dcb)
|
||||
{
|
||||
ss_dassert(backend_dcb->session->client != NULL);
|
||||
ss_dassert(backend_dcb->session->client_dcb != NULL);
|
||||
SESSION_ROUTE_REPLY(backend_dcb->session, queue);
|
||||
}
|
||||
|
||||
@ -886,7 +886,7 @@ static void handleError(ROUTER *instance, void *router_session, GWBUF *errbuf,
|
||||
}
|
||||
spinlock_acquire(&session->ses_lock);
|
||||
sesstate = session->state;
|
||||
client_dcb = session->client;
|
||||
client_dcb = session->client_dcb;
|
||||
|
||||
if (sesstate == SESSION_STATE_ROUTER_READY)
|
||||
{
|
||||
|
@ -808,7 +808,7 @@ static void* newSession(
|
||||
#endif
|
||||
|
||||
client_rses->router = router;
|
||||
client_rses->client_dcb = session->client;
|
||||
client_rses->client_dcb = session->client_dcb;
|
||||
/**
|
||||
* If service config has been changed, reload config from service to
|
||||
* router instance first.
|
||||
@ -1597,7 +1597,7 @@ void check_drop_tmp_table(
|
||||
|
||||
CHK_DCB(master_dcb);
|
||||
|
||||
data = (MYSQL_session*)master_dcb->session->data;
|
||||
data = (MYSQL_session*)master_dcb->session->client_dcb->data;
|
||||
|
||||
if(data == NULL)
|
||||
{
|
||||
@ -1689,7 +1689,7 @@ static qc_query_type_t is_read_tmp_table(
|
||||
}
|
||||
CHK_DCB(master_dcb);
|
||||
|
||||
data = (MYSQL_session*)master_dcb->session->data;
|
||||
data = (MYSQL_session*)master_dcb->session->client_dcb->data;
|
||||
|
||||
if(data == NULL)
|
||||
{
|
||||
@ -1797,7 +1797,7 @@ static void check_create_tmp_table(
|
||||
|
||||
CHK_DCB(master_dcb);
|
||||
|
||||
data = (MYSQL_session*)master_dcb->session->data;
|
||||
data = (MYSQL_session*)master_dcb->session->client_dcb->data;
|
||||
|
||||
if(data == NULL)
|
||||
{
|
||||
@ -1904,9 +1904,9 @@ static DCB* rses_get_client_dcb(
|
||||
if ((dcb = rses->rses_backend_ref[i].bref_dcb) != NULL &&
|
||||
BREF_IS_IN_USE(&rses->rses_backend_ref[i]) &&
|
||||
dcb->session != NULL &&
|
||||
dcb->session->client != NULL)
|
||||
dcb->session->client_dcb != NULL)
|
||||
{
|
||||
return dcb->session->client;
|
||||
return dcb->session->client_dcb;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
@ -2792,7 +2792,7 @@ static void clientReply (
|
||||
}
|
||||
/** Holding lock ensures that router session remains open */
|
||||
ss_dassert(backend_dcb->session != NULL);
|
||||
client_dcb = backend_dcb->session->client;
|
||||
client_dcb = backend_dcb->session->client_dcb;
|
||||
|
||||
/** Unlock */
|
||||
rses_end_locked_router_action(router_cli_ses);
|
||||
@ -4120,7 +4120,7 @@ static bool execute_sescmd_in_backend(
|
||||
MYSQL_session* data;
|
||||
unsigned int qlen;
|
||||
|
||||
data = dcb->session->data;
|
||||
data = dcb->session->client_dcb->data;
|
||||
tmpbuf = scur->scmd_cur_cmd->my_sescmd_buf;
|
||||
qlen = MYSQL_GET_PACKET_LEN((unsigned char*)tmpbuf->start);
|
||||
memset(data->db,0,MYSQL_DATABASE_MAXLEN+1);
|
||||
@ -4815,7 +4815,7 @@ static void handle_error_reply_client(
|
||||
|
||||
spinlock_acquire(&ses->ses_lock);
|
||||
sesstate = ses->state;
|
||||
client_dcb = ses->client;
|
||||
client_dcb = ses->client_dcb;
|
||||
spinlock_release(&ses->ses_lock);
|
||||
|
||||
/**
|
||||
@ -4887,7 +4887,7 @@ static bool handle_error_new_connection(
|
||||
if (BREF_IS_WAITING_RESULT(bref))
|
||||
{
|
||||
DCB* client_dcb;
|
||||
client_dcb = ses->client;
|
||||
client_dcb = ses->client_dcb;
|
||||
client_dcb->func.write(client_dcb, gwbuf_clone(errmsg));
|
||||
bref_clear_state(bref, BREF_WAITING_RESULT);
|
||||
}
|
||||
|
@ -985,8 +985,8 @@ static void* newSession(ROUTER* router_inst, SESSION* session)
|
||||
int router_nservers = 0; /*< # of servers in total */
|
||||
int i;
|
||||
char db[MYSQL_DATABASE_MAXLEN+1];
|
||||
MySQLProtocol* protocol = session->client->protocol;
|
||||
MYSQL_session* data = session->data;
|
||||
MySQLProtocol* protocol = session->client_dcb->protocol;
|
||||
MYSQL_session* data = session->client_dcb->data;
|
||||
bool using_db = false;
|
||||
bool have_db = false;
|
||||
|
||||
@ -1027,12 +1027,12 @@ static void* newSession(ROUTER* router_inst, SESSION* session)
|
||||
#endif
|
||||
|
||||
client_rses->router = router;
|
||||
client_rses->rses_mysql_session = (MYSQL_session*)session->data;
|
||||
client_rses->rses_client_dcb = (DCB*)session->client;
|
||||
client_rses->rses_mysql_session = (MYSQL_session*)session->client_dcb->data;
|
||||
client_rses->rses_client_dcb = (DCB*)session->client_dcb;
|
||||
|
||||
spinlock_acquire(&router->lock);
|
||||
|
||||
shard_map_t *map = hashtable_fetch(router->shard_maps, session->client->user);
|
||||
shard_map_t *map = hashtable_fetch(router->shard_maps, session->client_dcb->user);
|
||||
enum shard_map_state state;
|
||||
|
||||
if (map)
|
||||
@ -2496,7 +2496,7 @@ static void clientReply(ROUTER* instance,
|
||||
}
|
||||
/** Holding lock ensures that router session remains open */
|
||||
ss_dassert(backend_dcb->session != NULL);
|
||||
client_dcb = backend_dcb->session->client;
|
||||
client_dcb = backend_dcb->session->client_dcb;
|
||||
|
||||
/** Unlock */
|
||||
rses_end_locked_router_action(router_cli_ses);
|
||||
@ -3978,7 +3978,7 @@ static void handle_error_reply_client(SESSION* ses,
|
||||
|
||||
spinlock_acquire(&ses->ses_lock);
|
||||
sesstate = ses->state;
|
||||
client_dcb = ses->client;
|
||||
client_dcb = ses->client_dcb;
|
||||
spinlock_release(&ses->ses_lock);
|
||||
|
||||
/**
|
||||
@ -4069,7 +4069,7 @@ static bool handle_error_new_connection(ROUTER_INSTANCE* inst,
|
||||
if (BREF_IS_WAITING_RESULT(bref))
|
||||
{
|
||||
DCB* client_dcb;
|
||||
client_dcb = ses->client;
|
||||
client_dcb = ses->client_dcb;
|
||||
client_dcb->func.write(client_dcb, gwbuf_clone(errmsg));
|
||||
bref_clear_state(bref, BREF_WAITING_RESULT);
|
||||
}
|
||||
|
@ -1018,8 +1018,8 @@ newSession(
|
||||
#endif
|
||||
|
||||
client_rses->router = router;
|
||||
client_rses->rses_mysql_session = (MYSQL_session*) session->data;
|
||||
client_rses->rses_client_dcb = (DCB*) session->client;
|
||||
client_rses->rses_mysql_session = (MYSQL_session*) session->client_dcb->data;
|
||||
client_rses->rses_client_dcb = (DCB*) session->client_dcb;
|
||||
client_rses->rses_autocommit_enabled = true;
|
||||
client_rses->rses_transaction_active = false;
|
||||
client_rses->session = session;
|
||||
@ -1191,17 +1191,17 @@ closeSession(
|
||||
ROUTER_OBJECT* rtr;
|
||||
ROUTER* rinst;
|
||||
void *rses;
|
||||
SESSION *ses;
|
||||
SESSION *one_session;
|
||||
|
||||
for(i = 0;i<router_cli_ses->n_subservice;i++)
|
||||
{
|
||||
rtr = router_cli_ses->subservice[i]->service->router;
|
||||
rinst = router_cli_ses->subservice[i]->service->router_instance;
|
||||
ses = router_cli_ses->subservice[i]->session;
|
||||
if(ses != NULL)
|
||||
one_session = router_cli_ses->subservice[i]->session;
|
||||
if(one_session != NULL)
|
||||
{
|
||||
rses = ses->router_session;
|
||||
ses->state = SESSION_STATE_STOPPING;
|
||||
rses = one_session->router_session;
|
||||
one_session->state = SESSION_STATE_STOPPING;
|
||||
rtr->closeSession(rinst,rses);
|
||||
}
|
||||
router_cli_ses->subservice[i]->state = SUBSVC_CLOSED;
|
||||
|
@ -367,7 +367,7 @@ send_static_html(DCB *dcb, char *html)
|
||||
static void
|
||||
send_index(WEB_SESSION *session)
|
||||
{
|
||||
DCB *dcb = session->session->client;
|
||||
DCB *dcb = session->session->client_dcb;
|
||||
|
||||
send_html_header(dcb);
|
||||
send_static_html(dcb, index_page);
|
||||
@ -382,7 +382,7 @@ DCB *dcb = session->session->client;
|
||||
static void
|
||||
send_css(WEB_SESSION *session)
|
||||
{
|
||||
DCB *dcb = session->session->client;
|
||||
DCB *dcb = session->session->client_dcb;
|
||||
|
||||
send_html_header(dcb);
|
||||
send_static_html(dcb, css);
|
||||
@ -397,7 +397,7 @@ DCB *dcb = session->session->client;
|
||||
static void
|
||||
send_title(WEB_SESSION *session)
|
||||
{
|
||||
DCB *dcb = session->session->client;
|
||||
DCB *dcb = session->session->client_dcb;
|
||||
|
||||
send_html_header(dcb);
|
||||
send_static_html(dcb, title_page);
|
||||
@ -412,7 +412,7 @@ DCB *dcb = session->session->client;
|
||||
static void
|
||||
send_frame1(WEB_SESSION *session)
|
||||
{
|
||||
DCB *dcb = session->session->client;
|
||||
DCB *dcb = session->session->client_dcb;
|
||||
|
||||
send_html_header(dcb);
|
||||
send_static_html(dcb, frame1_page);
|
||||
@ -427,7 +427,7 @@ DCB *dcb = session->session->client;
|
||||
static void
|
||||
send_menu(WEB_SESSION *session)
|
||||
{
|
||||
DCB *dcb = session->session->client;
|
||||
DCB *dcb = session->session->client_dcb;
|
||||
|
||||
send_html_header(dcb);
|
||||
send_static_html(dcb, menu_page);
|
||||
@ -442,7 +442,7 @@ DCB *dcb = session->session->client;
|
||||
static void
|
||||
send_blank(WEB_SESSION *session)
|
||||
{
|
||||
DCB *dcb = session->session->client;
|
||||
DCB *dcb = session->session->client_dcb;
|
||||
|
||||
send_html_header(dcb);
|
||||
send_static_html(dcb, blank_page);
|
||||
@ -473,7 +473,7 @@ service_row(SERVICE *service, DCB *dcb)
|
||||
static void
|
||||
send_services(WEB_SESSION *session)
|
||||
{
|
||||
DCB *dcb = session->session->client;
|
||||
DCB *dcb = session->session->client_dcb;
|
||||
|
||||
send_html_header(dcb);
|
||||
dcb_printf(dcb, "<HTML><HEAD>");
|
||||
@ -497,8 +497,8 @@ static void
|
||||
session_row(SESSION *session, DCB *dcb)
|
||||
{
|
||||
dcb_printf(dcb, "<TR><TD>%-16p</TD><TD>%s</TD><TD>%s</TD><TD>%s</TD></TR>\n",
|
||||
session, ((session->client && session->client->remote)
|
||||
? session->client->remote : ""),
|
||||
session, ((session->client_dcb && session->client_dcb->remote)
|
||||
? session->client_dcb->remote : ""),
|
||||
(session->service && session->service->name
|
||||
? session->service->name : ""),
|
||||
session_state(session->state));
|
||||
@ -514,7 +514,7 @@ session_row(SESSION *session, DCB *dcb)
|
||||
static void
|
||||
send_sessions(WEB_SESSION *session)
|
||||
{
|
||||
DCB *dcb = session->session->client;
|
||||
DCB *dcb = session->session->client_dcb;
|
||||
|
||||
send_html_header(dcb);
|
||||
dcb_printf(dcb, "<HTML><HEAD>");
|
||||
@ -550,7 +550,7 @@ server_row(SERVER *server, DCB *dcb)
|
||||
static void
|
||||
send_servers(WEB_SESSION *session)
|
||||
{
|
||||
DCB *dcb = session->session->client;
|
||||
DCB *dcb = session->session->client_dcb;
|
||||
|
||||
send_html_header(dcb);
|
||||
dcb_printf(dcb, "<HTML><HEAD>");
|
||||
@ -586,7 +586,7 @@ monitor_row(MONITOR *monitor, DCB *dcb)
|
||||
static void
|
||||
send_monitors(WEB_SESSION *session)
|
||||
{
|
||||
DCB *dcb = session->session->client;
|
||||
DCB *dcb = session->session->client_dcb;
|
||||
|
||||
send_html_header(dcb);
|
||||
dcb_printf(dcb, "<HTML><HEAD>");
|
||||
@ -608,7 +608,7 @@ DCB *dcb = session->session->client;
|
||||
static void
|
||||
respond_error(WEB_SESSION *session, int err, char *msg)
|
||||
{
|
||||
DCB *dcb = session->session->client;
|
||||
DCB *dcb = session->session->client_dcb;
|
||||
|
||||
dcb_printf(dcb, "HTTP/1.1 %d %s\n", err, msg);
|
||||
dcb_printf(dcb, "Content-Type: text/html\n");
|
||||
|
Loading…
x
Reference in New Issue
Block a user