Merge branch 'develop' into binlog_server_waitdata_encryption

This commit is contained in:
MassimilianoPinto
2016-11-30 09:38:00 +01:00
63 changed files with 3113 additions and 1639 deletions

View File

@ -92,8 +92,6 @@
#define ARG_TYPE_FILTER 9
#define ARG_TYPE_NUMERIC 10
extern LIST_CONFIG SESSIONlist;
/**
* The subcommand structure
*
@ -1522,6 +1520,8 @@ convert_arg(int mode, char *arg, int arg_type)
return 0;
}
static SPINLOCK debugcmd_lock = SPINLOCK_INIT;
/**
* We have a complete line from the user, lookup the commands and execute them
*
@ -1613,6 +1613,8 @@ execute_cmd(CLI_SESSION *cli)
argc = i - 2; /* The number of extra arguments to commands */
spinlock_acquire(&debugcmd_lock);
if (!strcasecmp(args[0], "help"))
{
if (args[1] == NULL || *args[1] == 0)
@ -1664,11 +1666,7 @@ execute_cmd(CLI_SESSION *cli)
}
found = 1;
}
else if (!strcasecmp(args[0], "quit"))
{
return 0;
}
else if (argc >= 0)
else if (strcasecmp(args[0], "quit") && argc >= 0)
{
for (i = 0; cmds[i].cmd; i++)
{
@ -1712,7 +1710,7 @@ execute_cmd(CLI_SESSION *cli)
if (arg_list[k] == 0)
{
dcb_printf(dcb, "Invalid argument: %s\n", args[k + 2]);
return 0;
break;
}
}
@ -1809,6 +1807,8 @@ execute_cmd(CLI_SESSION *cli)
"Command '%s' not known, type help for a list of available commands\n", args[0]);
}
spinlock_release(&debugcmd_lock);
memset(cli->cmdbuf, 0, CMDBUFLEN);
return 1;
@ -2115,6 +2115,31 @@ static bool get_log_action(const char* name, struct log_action_entry* entryp)
return found;
}
bool seslog_cb(DCB *dcb, void *data)
{
bool rval = true;
struct log_action_entry *entry = ((void**)data)[0];
size_t *id = ((void**)data)[1];
bool enable = (bool)((void**)data)[2];
SESSION *session = dcb->session;
if (session->ses_id == *id)
{
if (enable)
{
session_enable_log_priority(session, entry->priority);
}
else
{
session_disable_log_priority(session, entry->priority);
}
rval = false;
}
return rval;
}
/**
* Enables a log for a single session
* @param session The session in question
@ -2127,21 +2152,10 @@ static void enable_sess_log_action(DCB *dcb, char *arg1, char *arg2)
if (get_log_action(arg1, &entry))
{
size_t id = (size_t) strtol(arg2, 0, 0);
list_entry_t *current = list_start_iteration(&SESSIONlist);
while (current)
{
SESSION *session = (SESSION *)current;
if (session->ses_id == id)
{
session_enable_log_priority(session, entry.priority);
list_terminate_iteration_early(&SESSIONlist, current);
break;
}
current = list_iterate(&SESSIONlist, current);
}
size_t id = (size_t)strtol(arg2, NULL, 10);
void *data[] = {&entry, &id, (void*)true};
if (!current)
if (dcb_foreach(seslog_cb, data))
{
dcb_printf(dcb, "Session not found: %s.\n", arg2);
}
@ -2164,28 +2178,17 @@ static void disable_sess_log_action(DCB *dcb, char *arg1, char *arg2)
if (get_log_action(arg1, &entry))
{
size_t id = (size_t) strtol(arg2, 0, 0);
list_entry_t *current = list_start_iteration(&SESSIONlist);
while (current)
{
SESSION *session = (SESSION *)current;
if (session->ses_id == id)
{
session_disable_log_priority(session, entry.priority);
list_terminate_iteration_early(&SESSIONlist, current);
break;
}
current = list_iterate(&SESSIONlist, current);
}
size_t id = (size_t)strtol(arg2, NULL, 10);
void *data[] = {&entry, &id, (void*)false};
if (!current)
if (dcb_foreach(seslog_cb, data))
{
dcb_printf(dcb, "Session not found: %s.\n", arg2);
}
}
else
{
dcb_printf(dcb, "%s is not supported for disable log.\n", arg1);
dcb_printf(dcb, "%s is not supported for enable log.\n", arg1);
}
}
@ -2226,6 +2229,30 @@ static int string_to_priority(const char* name)
return result ? result->priority : -1;
}
bool sesprio_cb(DCB *dcb, void *data)
{
bool rval = true;
int *priority = ((void**)data)[0];
size_t *id = ((void**)data)[1];
bool enable = (bool)((void**)data)[2];
SESSION *session = dcb->session;
if (session->ses_id == *id)
{
if (enable)
{
session_enable_log_priority(session, *priority);
}
else
{
session_disable_log_priority(session, *priority);
}
rval = false;
}
return rval;
}
/**
* Enables a log priority for a single session
* @param session The session in question
@ -2238,21 +2265,10 @@ static void enable_sess_log_priority(DCB *dcb, char *arg1, char *arg2)
if (priority != -1)
{
size_t id = (size_t) strtol(arg2, 0, 0);
list_entry_t *current = list_start_iteration(&SESSIONlist);
while (current)
{
SESSION *session = (SESSION *)current;
if (session->ses_id == id)
{
session_enable_log_priority(session, priority);
list_terminate_iteration_early(&SESSIONlist, current);
break;
}
current = list_iterate(&SESSIONlist, current);
}
size_t id = (size_t) strtol(arg2, NULL, 10);
void *data[] = {&priority, &id, (void*)true};
if (!current)
if (dcb_foreach(sesprio_cb, data))
{
dcb_printf(dcb, "Session not found: %s.\n", arg2);
}
@ -2275,21 +2291,10 @@ static void disable_sess_log_priority(DCB *dcb, char *arg1, char *arg2)
if (priority != -1)
{
size_t id = (size_t) strtol(arg2, 0, 0);
list_entry_t *current = list_start_iteration(&SESSIONlist);
while (current)
{
SESSION *session = (SESSION *)current;
if (session->ses_id == id)
{
session_disable_log_priority(session, priority);
list_terminate_iteration_early(&SESSIONlist, current);
break;
}
current = list_iterate(&SESSIONlist, current);
}
size_t id = (size_t) strtol(arg2, NULL, 10);
void *data[] = {&priority, &id, (void*)false};
if (!current)
if (dcb_foreach(seslog_cb, data))
{
dcb_printf(dcb, "Session not found: %s.\n", arg2);
}

View File

@ -1044,15 +1044,6 @@ maxinfo_event_queue_length()
return poll_get_stat(POLL_STAT_EVQ_LEN);
}
/**
* Interface to poll stats for event pending queue length
*/
static int
maxinfo_event_pending_queue_length()
{
return poll_get_stat(POLL_STAT_EVQ_PENDING);
}
/**
* Interface to poll stats for max event queue length
*/
@ -1108,7 +1099,6 @@ static struct
{ "Error_events", VT_INT, (STATSFUNC)maxinfo_error_events },
{ "Accept_events", VT_INT, (STATSFUNC)maxinfo_accept_events },
{ "Event_queue_length", VT_INT, (STATSFUNC)maxinfo_event_queue_length },
{ "Pending_events", VT_INT, (STATSFUNC)maxinfo_event_pending_queue_length },
{ "Max_event_queue_length", VT_INT, (STATSFUNC)maxinfo_max_event_queue_length },
{ "Max_event_queue_time", VT_INT, (STATSFUNC)maxinfo_max_event_queue_time },
{ "Max_event_execution_time", VT_INT, (STATSFUNC)maxinfo_max_event_exec_time },

View File

@ -607,41 +607,6 @@ bool check_shard_status(ROUTER_INSTANCE* router, char* shard)
return false;
}
/**
* A fake DCB read function used to forward queued queries.
* @param dcb Internal DCB used by the router session
* @return Always 1
*/
int internalRoute(DCB* dcb)
{
if (dcb->dcb_readqueue && dcb->session)
{
GWBUF* tmp = dcb->dcb_readqueue;
void* rinst = dcb->session->service->router_instance;
void *rses = dcb->session->router_session;
dcb->dcb_readqueue = NULL;
return dcb->session->service->router->routeQuery(rinst, rses, tmp);
}
return 1;
}
/**
* A fake DCB read function used to forward replies to the client.
* @param dcb Internal DCB used by the router session
* @return Always 1
*/
int internalReply(DCB* dcb)
{
if (dcb->dcb_readqueue && dcb->session)
{
GWBUF* tmp = dcb->dcb_readqueue;
dcb->dcb_readqueue = NULL;
return SESSION_ROUTE_REPLY(dcb->session, tmp);
}
return 1;
}
/**
* Implementation of the mandatory version entry point
*
@ -955,16 +920,8 @@ static void* newSession(ROUTER* router_inst, SESSION* session)
}
client_rses->shardmap = map;
client_rses->dcb_reply = dcb_alloc(DCB_ROLE_INTERNAL, NULL);
client_rses->dcb_reply->func.read = internalReply;
client_rses->dcb_reply->state = DCB_STATE_POLLING;
client_rses->dcb_reply->session = session;
memcpy(&client_rses->rses_config, &router->schemarouter_config, sizeof(schemarouter_config_t));
client_rses->n_sescmd = 0;
client_rses->dcb_route = dcb_alloc(DCB_ROLE_INTERNAL, NULL);
client_rses->dcb_route->func.read = internalRoute;
client_rses->dcb_route->state = DCB_STATE_POLLING;
client_rses->dcb_route->session = session;
client_rses->rses_config.last_refresh = time(NULL);
if (using_db)
@ -1147,18 +1104,7 @@ static void closeSession(ROUTER* instance, void* router_session)
}
}
/* Close internal DCBs */
router_cli_ses->dcb_reply->session = NULL;
router_cli_ses->dcb_route->session = NULL;
dcb_close(router_cli_ses->dcb_reply);
dcb_close(router_cli_ses->dcb_route);
while (router_cli_ses->queue &&
(router_cli_ses->queue = gwbuf_consume(
router_cli_ses->queue, gwbuf_length(router_cli_ses->queue))))
{
;
}
gwbuf_free(router_cli_ses->queue);
/** Unlock */
rses_end_locked_router_action(router_cli_ses);
@ -4153,7 +4099,7 @@ void route_queued_query(ROUTER_CLIENT_SES *router_cli_ses)
querystr);
MXS_FREE(querystr);
#endif
poll_add_epollin_event_to_dcb(router_cli_ses->dcb_route, tmp);
poll_add_epollin_event_to_dcb(router_cli_ses->rses_client_dcb, tmp);
}
/**