Addition of CheckSessions debug entry point

This commit is contained in:
Mark Riddoch 2013-09-18 19:06:32 +02:00
parent ace4252832
commit c7b052aab3
2 changed files with 61 additions and 1 deletions

View File

@ -266,6 +266,67 @@ SESSION *ptr;
spinlock_release(&session_spin);
}
/**
* Check sessions
*
* Designed to be called within a debugger session in order
* to display information regarding "interesting" sessions
*/
void
CheckSessions()
{
SESSION *ptr;
int noclients = 0;
int norouter = 0;
spinlock_acquire(&session_spin);
ptr = allSessions;
while (ptr)
{
if (ptr->state != SESSION_STATE_LISTENER ||
ptr->state != SESSION_STATE_LISTENER_STOPPED)
{
if (ptr->client == NULL && ptr->refcount)
{
if (noclients == 0)
{
printf("Sessions without a client DCB.\n");
printf("==============================\n");
}
printSession(ptr);
noclients++;
}
}
ptr = ptr->next;
}
spinlock_release(&session_spin);
if (noclients)
printf("%d Sessions have no clients\n", noclients);
spinlock_acquire(&session_spin);
ptr = allSessions;
while (ptr)
{
if (ptr->state != SESSION_STATE_LISTENER ||
ptr->state != SESSION_STATE_LISTENER_STOPPED)
{
if (ptr->router_session == NULL && ptr->refcount)
{
if (norouter == 0)
{
printf("Sessions without a router session.\n");
printf("==================================\n");
}
printSession(ptr);
norouter++;
}
}
ptr = ptr->next;
}
spinlock_release(&session_spin);
if (norouter)
printf("%d Sessions have no router session\n", norouter);
}
/**
* Print all sessions to a DCB
*

View File

@ -71,7 +71,6 @@ typedef struct session {
SPINLOCK ses_lock;
session_state_t state; /**< Current descriptor state */
struct dcb *client; /**< The client connection */
struct dcb *backends; /**< The set of backend servers */
void *data; /**< The session data */
void *router_session;/**< The router instance data */
SESSION_STATS stats; /**< Session statistics */