Added commands to debugcmd.c that enable and disable logs for a single session.
Added the session id to dprintAllSessions and dprintSession output.
This commit is contained in:
parent
a65d8cd525
commit
2556097a98
@ -572,7 +572,7 @@ SESSION *ptr;
|
||||
ptr = allSessions;
|
||||
while (ptr)
|
||||
{
|
||||
dcb_printf(dcb, "Session %p\n", ptr);
|
||||
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);
|
||||
@ -598,7 +598,7 @@ dprintSession(DCB *dcb, SESSION *ptr)
|
||||
{
|
||||
int i;
|
||||
|
||||
dcb_printf(dcb, "Session %p\n", ptr);
|
||||
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);
|
||||
@ -853,3 +853,11 @@ session_getUser(SESSION *session)
|
||||
{
|
||||
return (session && session->client) ? session->client->user : NULL;
|
||||
}
|
||||
/**
|
||||
* Return the pointer to the list of all sessions.
|
||||
* @return Pointer to the list of all sessions.
|
||||
*/
|
||||
SESSION *get_all_sessions()
|
||||
{
|
||||
return allSessions;
|
||||
}
|
||||
|
@ -148,6 +148,7 @@ typedef struct session {
|
||||
((sess)->tail.clientReply)((sess)->tail.instance, \
|
||||
(sess)->tail.session, (buf))
|
||||
|
||||
SESSION *get_all_sessions();
|
||||
SESSION *session_alloc(struct service *, struct dcb *);
|
||||
bool session_free(SESSION *);
|
||||
int session_isvalid(SESSION *);
|
||||
|
@ -699,6 +699,7 @@ char *args[MAXARGS + 1];
|
||||
unsigned long arg1, arg2, arg3;
|
||||
int in_quotes = 0, escape_next = 0;
|
||||
char *ptr, *lptr;
|
||||
bool in_space = false;
|
||||
|
||||
args[0] = cli->cmdbuf;
|
||||
ptr = args[0];
|
||||
@ -710,7 +711,7 @@ char *ptr, *lptr;
|
||||
* the use of double quotes.
|
||||
* The array args contains the broken down words, one per index.
|
||||
*/
|
||||
bool in_space = false;
|
||||
|
||||
while (*ptr)
|
||||
{
|
||||
if (escape_next)
|
||||
@ -1179,11 +1180,11 @@ disable_service_root(DCB *dcb, SERVICE *service)
|
||||
static void enable_sess_log_action(DCB *dcb, char *arg1, char *arg2)
|
||||
{
|
||||
logfile_id_t type;
|
||||
int id = 0;
|
||||
size_t id = 0;
|
||||
int max_len = strlen("message");
|
||||
SESSION* session;
|
||||
SESSION* session = get_all_sessions();
|
||||
|
||||
ss_dassert(arg1 != NULL && arg2 != NULL);
|
||||
ss_dassert(arg1 != NULL && arg2 != NULL && session != NULL);
|
||||
|
||||
if (strncmp(arg1, "debug", max_len) == 0) {
|
||||
type = LOGFILE_DEBUG;
|
||||
@ -1196,21 +1197,20 @@ static void enable_sess_log_action(DCB *dcb, char *arg1, char *arg2)
|
||||
} else {
|
||||
dcb_printf(dcb, "%s is not supported for enable log\n", arg1);
|
||||
return ;
|
||||
}
|
||||
|
||||
id = strtol(arg2,0,0);
|
||||
|
||||
if(id == 0){
|
||||
dcb_printf(dcb, "Session not found: %s\n", arg2);
|
||||
return ;
|
||||
}
|
||||
|
||||
id = (size_t)strtol(arg2,0,0);
|
||||
|
||||
/**Find the session and enable log*/
|
||||
while(session)
|
||||
{
|
||||
if(session->ses_id == id)
|
||||
{
|
||||
session_enable_log(session,type);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
dcb_printf(dcb, "Would enable log %s for session %d\n", arg1, id);
|
||||
return ;
|
||||
|
||||
//session_enable_log(session,type);
|
||||
dcb_printf(dcb, "Session not found: %s\n", arg2);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1224,9 +1224,9 @@ static void disable_sess_log_action(DCB *dcb, char *arg1, char *arg2)
|
||||
logfile_id_t type;
|
||||
int id = 0;
|
||||
int max_len = strlen("message");
|
||||
SESSION* session;
|
||||
SESSION* session = get_all_sessions();
|
||||
|
||||
ss_dassert(arg1 != NULL && arg2 != NULL);
|
||||
ss_dassert(arg1 != NULL && arg2 != NULL && session != NULL);
|
||||
|
||||
if (strncmp(arg1, "debug", max_len) == 0) {
|
||||
type = LOGFILE_DEBUG;
|
||||
@ -1240,17 +1240,19 @@ static void disable_sess_log_action(DCB *dcb, char *arg1, char *arg2)
|
||||
dcb_printf(dcb, "%s is not supported for disable log\n", arg1);
|
||||
return ;
|
||||
}
|
||||
|
||||
id = strtol(arg2,0,0);
|
||||
|
||||
if(id == 0){
|
||||
dcb_printf(dcb, "Session not found: %s\n", arg2);
|
||||
return ;
|
||||
}
|
||||
|
||||
id = (size_t)strtol(arg2,0,0);
|
||||
|
||||
dcb_printf(dcb, "Would disable log %s for session %d\n", arg1, id);
|
||||
while(session)
|
||||
{
|
||||
if(session->ses_id == id)
|
||||
{
|
||||
session_disable_log(session,type);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//session_enable_log(session,type);
|
||||
dcb_printf(dcb, "Session not found: %s\n", arg2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user