1. Changed the prefix 'DBS' to 'TPM' for session and instance structs.

2. Added every optional parameters in diagnostics function.
This commit is contained in:
Dong Young Yoon
2015-12-18 16:11:39 -05:00
parent 74c0ab2c57
commit b5171cf7ee

View File

@ -110,10 +110,10 @@ typedef struct {
int query_delimiter_size; /* the length of the query delimiter */ int query_delimiter_size; /* the length of the query delimiter */
FILE* fp; FILE* fp;
} DBS_INSTANCE; } TPM_INSTANCE;
/** /**
* The session structure for this DBS filter. * The session structure for this TPM filter.
* This stores the downstream filter information, such that the * This stores the downstream filter information, such that the
* filter is able to pass the query on to the next filter (or router) * filter is able to pass the query on to the next filter (or router)
* in the chain. * in the chain.
@ -136,7 +136,7 @@ typedef struct {
char *buf; char *buf;
int sql_index; int sql_index;
size_t max_sql_size; size_t max_sql_size;
} DBS_SESSION; } TPM_SESSION;
/** /**
* Implementation of the mandatory version entry point * Implementation of the mandatory version entry point
@ -185,9 +185,9 @@ static FILTER *
createInstance(char **options, FILTER_PARAMETER **params) createInstance(char **options, FILTER_PARAMETER **params)
{ {
int i; int i;
DBS_INSTANCE *my_instance; TPM_INSTANCE *my_instance;
if ((my_instance = calloc(1, sizeof(DBS_INSTANCE))) != NULL) if ((my_instance = calloc(1, sizeof(TPM_INSTANCE))) != NULL)
{ {
my_instance->source = NULL; my_instance->source = NULL;
my_instance->user = NULL; my_instance->user = NULL;
@ -246,12 +246,12 @@ DBS_INSTANCE *my_instance;
static void * static void *
newSession(FILTER *instance, SESSION *session) newSession(FILTER *instance, SESSION *session)
{ {
DBS_INSTANCE *my_instance = (DBS_INSTANCE *)instance; TPM_INSTANCE *my_instance = (TPM_INSTANCE *)instance;
DBS_SESSION *my_session; TPM_SESSION *my_session;
int i; int i;
char *remote, *user; char *remote, *user;
if ((my_session = calloc(1, sizeof(DBS_SESSION))) != NULL) if ((my_session = calloc(1, sizeof(TPM_SESSION))) != NULL)
{ {
atomic_add(&my_instance->sessions,1); atomic_add(&my_instance->sessions,1);
@ -294,8 +294,8 @@ char *remote, *user;
static void static void
closeSession(FILTER *instance, void *session) closeSession(FILTER *instance, void *session)
{ {
DBS_SESSION *my_session = (DBS_SESSION *)session; TPM_SESSION *my_session = (TPM_SESSION *)session;
DBS_INSTANCE *my_instance = (DBS_INSTANCE *)instance; TPM_INSTANCE *my_instance = (TPM_INSTANCE *)instance;
if (my_instance->fp != NULL) if (my_instance->fp != NULL)
{ {
// flush FP when a session is closed. // flush FP when a session is closed.
@ -313,7 +313,7 @@ closeSession(FILTER *instance, void *session)
static void static void
freeSession(FILTER *instance, void *session) freeSession(FILTER *instance, void *session)
{ {
DBS_SESSION *my_session = (DBS_SESSION *)session; TPM_SESSION *my_session = (TPM_SESSION *)session;
free(my_session->clientHost); free(my_session->clientHost);
free(my_session->userName); free(my_session->userName);
@ -334,7 +334,7 @@ DBS_SESSION *my_session = (DBS_SESSION *)session;
static void static void
setDownstream(FILTER *instance, void *session, DOWNSTREAM *downstream) setDownstream(FILTER *instance, void *session, DOWNSTREAM *downstream)
{ {
DBS_SESSION *my_session = (DBS_SESSION *)session; TPM_SESSION *my_session = (TPM_SESSION *)session;
my_session->down = *downstream; my_session->down = *downstream;
} }
@ -350,7 +350,7 @@ DBS_SESSION *my_session = (DBS_SESSION *)session;
static void static void
setUpstream(FILTER *instance, void *session, UPSTREAM *upstream) setUpstream(FILTER *instance, void *session, UPSTREAM *upstream)
{ {
DBS_SESSION *my_session = (DBS_SESSION *)session; TPM_SESSION *my_session = (TPM_SESSION *)session;
my_session->up = *upstream; my_session->up = *upstream;
} }
@ -368,8 +368,8 @@ DBS_SESSION *my_session = (DBS_SESSION *)session;
static int static int
routeQuery(FILTER *instance, void *session, GWBUF *queue) routeQuery(FILTER *instance, void *session, GWBUF *queue)
{ {
DBS_INSTANCE *my_instance = (DBS_INSTANCE *)instance; TPM_INSTANCE *my_instance = (TPM_INSTANCE *)instance;
DBS_SESSION *my_session = (DBS_SESSION *)session; TPM_SESSION *my_session = (TPM_SESSION *)session;
char *ptr = NULL; char *ptr = NULL;
size_t i; size_t i;
@ -467,8 +467,8 @@ retblock:
static int static int
clientReply(FILTER *instance, void *session, GWBUF *reply) clientReply(FILTER *instance, void *session, GWBUF *reply)
{ {
DBS_INSTANCE *my_instance = (DBS_INSTANCE *)instance; TPM_INSTANCE *my_instance = (TPM_INSTANCE *)instance;
DBS_SESSION *my_session = (DBS_SESSION *)session; TPM_SESSION *my_session = (TPM_SESSION *)session;
struct timeval tv, diff; struct timeval tv, diff;
int i, inserted; int i, inserted;
@ -519,8 +519,8 @@ int i, inserted;
static void static void
diagnostic(FILTER *instance, void *fsession, DCB *dcb) diagnostic(FILTER *instance, void *fsession, DCB *dcb)
{ {
DBS_INSTANCE *my_instance = (DBS_INSTANCE *)instance; TPM_INSTANCE *my_instance = (TPM_INSTANCE *)instance;
DBS_SESSION *my_session = (DBS_SESSION *)fsession; TPM_SESSION *my_session = (TPM_SESSION *)fsession;
int i; int i;
if (my_instance->source) if (my_instance->source)
@ -529,9 +529,13 @@ int i;
if (my_instance->user) if (my_instance->user)
dcb_printf(dcb, "\t\tLimit logging to user %s\n", dcb_printf(dcb, "\t\tLimit logging to user %s\n",
my_instance->user); my_instance->user);
if (my_session) if (my_instance->filename)
{
dcb_printf(dcb, "\t\tLogging to file %s.\n", dcb_printf(dcb, "\t\tLogging to file %s.\n",
my_instance->filename); my_instance->filename);
} if (my_instance->delimiter)
dcb_printf(dcb, "\t\tLogging with delimiter %s.\n",
my_instance->delimiter);
if (my_instance->query_delimiter)
dcb_printf(dcb, "\t\tLogging with query delimiter %s.\n",
my_instance->query_delimiter);
} }