Reindent server/core/session.c

This commit is contained in:
Johan Wikman
2015-11-30 19:59:34 +02:00
parent 8601068dc2
commit 15df33a93f
2 changed files with 638 additions and 630 deletions

View File

@ -152,7 +152,6 @@ session_alloc(SERVICE *service, DCB *client_dcb)
pthread_self(),
__func__,
service->name);
}
/*
* Pending filter chain being setup set the head of the chain to
@ -316,8 +315,7 @@ session_link_dcb(SESSION *session, DCB *dcb)
return true;
}
int session_unlink_dcb(
SESSION* session,
int session_unlink_dcb(SESSION* session,
DCB* dcb)
{
int nlink;
@ -386,7 +384,6 @@ session_simple_free(SESSION *session, DCB *dcb)
free(session);
}
/**
* Deallocate the specified session
*
@ -440,8 +437,7 @@ session_free(SESSION *session)
*/
if (!session->ses_is_child && session->router_session)
{
session->service->router->freeSession(
session->service->router_instance,
session->service->router->freeSession(session->service->router_instance,
session->router_session);
}
if (session->n_filters)
@ -450,17 +446,19 @@ session_free(SESSION *session)
for (i = 0; i < session->n_filters; i++)
{
if (session->filters[i].filter)
session->filters[i].filter->obj->closeSession(
session->filters[i].instance,
{
session->filters[i].filter->obj->closeSession(session->filters[i].instance,
session->filters[i].session);
}
}
for (i = 0; i < session->n_filters; i++)
{
if (session->filters[i].filter)
session->filters[i].filter->obj->freeSession(
session->filters[i].instance,
{
session->filters[i].filter->obj->freeSession(session->filters[i].instance,
session->filters[i].session);
}
}
free(session->filters);
}
@ -589,7 +587,9 @@ int norouter = 0;
}
spinlock_release(&session_spin);
if (noclients)
{
printf("%d Sessions have no clients\n", noclients);
}
spinlock_acquire(&session_spin);
ptr = allSessions;
while (ptr)
@ -612,8 +612,10 @@ int norouter = 0;
}
spinlock_release(&session_spin);
if (norouter)
{
printf("%d Sessions have no router session\n", norouter);
}
}
/**
* Print all sessions to a DCB
@ -634,7 +636,6 @@ SESSION *ptr;
ptr = allSessions;
while (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);
@ -679,7 +680,6 @@ 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);
@ -706,8 +706,7 @@ int 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].filter->obj->diagnostics(ptr->filters[i].instance,
ptr->filters[i].session,
dcb);
}
@ -747,7 +746,10 @@ SESSION *ptr;
ptr = ptr->next;
}
if (allSessions)
dcb_printf(dcb, "-----------------+-----------------+----------------+--------------------------\n\n");
{
dcb_printf(dcb,
"-----------------+-----------------+----------------+--------------------------\n\n");
}
spinlock_release(&session_spin);
}
@ -781,20 +783,20 @@ session_state(int state)
return "Session to be freed";
case SESSION_STATE_FREE:
return "Freed session";
#endif
default:
return "Invalid State";
}
}
SESSION* get_session_by_router_ses(
void* rses)
SESSION* get_session_by_router_ses(void* rses)
{
SESSION* ses = allSessions;
while (ses->router_session != rses && ses->next != NULL)
{
ses = ses->next;
}
if (ses->router_session != rses)
{
@ -907,13 +909,13 @@ char *
session_get_remote(SESSION *session)
{
if (session && session->client)
{
return session->client->remote;
}
return NULL;
}
bool session_route_query (
SESSION* ses,
GWBUF* buf)
bool session_route_query(SESSION* ses, GWBUF* buf)
{
bool succp;
@ -987,14 +989,14 @@ void session_close_timeouts(void* data)
spinlock_acquire(&session_spin);
ses = ses->next;
spinlock_release(&session_spin);
}
}
/**
* Callback structure for the session list extraction
*/
typedef struct {
typedef struct
{
int index;
SESSIONLISTFILTER filter;
} SESSIONFILTER;
@ -1074,7 +1076,9 @@ RESULTSET *set;
SESSIONFILTER *data;
if ((data = (SESSIONFILTER *)malloc(sizeof(SESSIONFILTER))) == NULL)
{
return NULL;
}
data->index = 0;
data->filter = filter;
if ((set = resultset_create(sessionRowCallback, data)) == NULL)

View File

@ -52,11 +52,13 @@ struct filter_def;
/**
* The session statistics structure
*/
typedef struct {
typedef struct
{
time_t connect; /**< Time when the session was started */
} SESSION_STATS;
typedef enum {
typedef enum
{
SESSION_STATE_ALLOC, /*< for all sessions */
SESSION_STATE_READY, /*< for router session */
SESSION_STATE_ROUTER_READY, /*< for router session */
@ -72,22 +74,22 @@ typedef enum {
* The downstream element in the filter chain. This may refer to
* another filter or to a router.
*/
typedef struct {
typedef struct
{
void *instance;
void *session;
int (*routeQuery)(void *instance, void *session,
GWBUF *request);
int (*routeQuery)(void *instance, void *session, GWBUF *request);
} DOWNSTREAM;
/**
* The upstream element in the filter chain. This may refer to
* another filter or to the protocol implementation.
*/
typedef struct {
typedef struct
{
void *instance;
void *session;
int (*clientReply)(void *instance,
void *session, GWBUF *response);
int (*clientReply)(void *instance, void *session, GWBUF *response);
int (*error)(void *instance, void *session, void *);
} UPSTREAM;
@ -95,9 +97,9 @@ typedef struct {
* Structure used to track the filter instances and sessions of the filters
* that are in use within a session.
*/
typedef struct {
struct filter_def
*filter;
typedef struct
{
struct filter_def *filter;
void *instance;
void *session;
} SESSION_FILTER;
@ -105,7 +107,8 @@ typedef struct {
/**
* Filter type for the sessionGetList call
*/
typedef enum {
typedef enum
{
SESSION_LIST_ALL,
SESSION_LIST_CONNECTION
} SESSIONLISTFILTER;
@ -117,7 +120,8 @@ typedef enum {
* to the database, it links the descriptors, routing implementation
* and originating service together for the client session.
*/
typedef struct session {
typedef struct session
{
#if defined(SS_DEBUG)
skygw_chk_t ses_chk_top;
#endif