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:
@ -572,7 +572,7 @@ SESSION *ptr;
|
|||||||
ptr = allSessions;
|
ptr = allSessions;
|
||||||
while (ptr)
|
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, "\tState: %s\n", session_state(ptr->state));
|
||||||
dcb_printf(dcb, "\tService: %s (%p)\n", ptr->service->name, ptr->service);
|
dcb_printf(dcb, "\tService: %s (%p)\n", ptr->service->name, ptr->service);
|
||||||
dcb_printf(dcb, "\tClient DCB: %p\n", ptr->client);
|
dcb_printf(dcb, "\tClient DCB: %p\n", ptr->client);
|
||||||
@ -598,7 +598,7 @@ dprintSession(DCB *dcb, SESSION *ptr)
|
|||||||
{
|
{
|
||||||
int i;
|
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, "\tState: %s\n", session_state(ptr->state));
|
||||||
dcb_printf(dcb, "\tService: %s (%p)\n", ptr->service->name, ptr->service);
|
dcb_printf(dcb, "\tService: %s (%p)\n", ptr->service->name, ptr->service);
|
||||||
dcb_printf(dcb, "\tClient DCB: %p\n", ptr->client);
|
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 (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.clientReply)((sess)->tail.instance, \
|
||||||
(sess)->tail.session, (buf))
|
(sess)->tail.session, (buf))
|
||||||
|
|
||||||
|
SESSION *get_all_sessions();
|
||||||
SESSION *session_alloc(struct service *, struct dcb *);
|
SESSION *session_alloc(struct service *, struct dcb *);
|
||||||
bool session_free(SESSION *);
|
bool session_free(SESSION *);
|
||||||
int session_isvalid(SESSION *);
|
int session_isvalid(SESSION *);
|
||||||
|
@ -699,6 +699,7 @@ char *args[MAXARGS + 1];
|
|||||||
unsigned long arg1, arg2, arg3;
|
unsigned long arg1, arg2, arg3;
|
||||||
int in_quotes = 0, escape_next = 0;
|
int in_quotes = 0, escape_next = 0;
|
||||||
char *ptr, *lptr;
|
char *ptr, *lptr;
|
||||||
|
bool in_space = false;
|
||||||
|
|
||||||
args[0] = cli->cmdbuf;
|
args[0] = cli->cmdbuf;
|
||||||
ptr = args[0];
|
ptr = args[0];
|
||||||
@ -710,7 +711,7 @@ char *ptr, *lptr;
|
|||||||
* the use of double quotes.
|
* the use of double quotes.
|
||||||
* The array args contains the broken down words, one per index.
|
* The array args contains the broken down words, one per index.
|
||||||
*/
|
*/
|
||||||
bool in_space = false;
|
|
||||||
while (*ptr)
|
while (*ptr)
|
||||||
{
|
{
|
||||||
if (escape_next)
|
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)
|
static void enable_sess_log_action(DCB *dcb, char *arg1, char *arg2)
|
||||||
{
|
{
|
||||||
logfile_id_t type;
|
logfile_id_t type;
|
||||||
int id = 0;
|
size_t id = 0;
|
||||||
int max_len = strlen("message");
|
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) {
|
if (strncmp(arg1, "debug", max_len) == 0) {
|
||||||
type = LOGFILE_DEBUG;
|
type = LOGFILE_DEBUG;
|
||||||
@ -1196,21 +1197,20 @@ static void enable_sess_log_action(DCB *dcb, char *arg1, char *arg2)
|
|||||||
} else {
|
} else {
|
||||||
dcb_printf(dcb, "%s is not supported for enable log\n", arg1);
|
dcb_printf(dcb, "%s is not supported for enable log\n", arg1);
|
||||||
return ;
|
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);
|
dcb_printf(dcb, "Session not found: %s\n", arg2);
|
||||||
return ;
|
|
||||||
|
|
||||||
//session_enable_log(session,type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1224,9 +1224,9 @@ static void disable_sess_log_action(DCB *dcb, char *arg1, char *arg2)
|
|||||||
logfile_id_t type;
|
logfile_id_t type;
|
||||||
int id = 0;
|
int id = 0;
|
||||||
int max_len = strlen("message");
|
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) {
|
if (strncmp(arg1, "debug", max_len) == 0) {
|
||||||
type = LOGFILE_DEBUG;
|
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);
|
dcb_printf(dcb, "%s is not supported for disable log\n", arg1);
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
id = strtol(arg2,0,0);
|
id = (size_t)strtol(arg2,0,0);
|
||||||
|
|
||||||
if(id == 0){
|
|
||||||
dcb_printf(dcb, "Session not found: %s\n", arg2);
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user