From e1d7a5640dcb9c02ecc197180971e8450acbd388 Mon Sep 17 00:00:00 2001 From: vraatikka Date: Mon, 9 Sep 2013 10:05:46 +0300 Subject: [PATCH] Put structure check fields behind SS_DEBUG macros. Thus, they are only included in debug builds. --- server/core/hashtable.c | 3 ++- server/core/session.c | 4 ++-- server/include/hashtable.h | 4 ++++ server/include/session.h | 4 ++++ server/modules/include/mysql_client_server_protocol.h | 4 ++++ server/modules/protocol/mysql_common.c | 2 ++ 6 files changed, 18 insertions(+), 3 deletions(-) diff --git a/server/core/hashtable.c b/server/core/hashtable.c index 2f39c9852..b9e7bf68a 100644 --- a/server/core/hashtable.c +++ b/server/core/hashtable.c @@ -91,9 +91,10 @@ HASHTABLE *rval; if ((rval = malloc(sizeof(HASHTABLE))) == NULL) return NULL; +#if defined(SS_DEBUG) rval->ht_chk_top = CHK_NUM_HASHTABLE; rval->ht_chk_tail = CHK_NUM_HASHTABLE; - +#endif rval->hashsize = size; rval->hashfn = hashfn; rval->cmpfn = cmpfn; diff --git a/server/core/session.c b/server/core/session.c index 0c150ba9b..96ae728f1 100644 --- a/server/core/session.c +++ b/server/core/session.c @@ -77,10 +77,10 @@ session_alloc(SERVICE *service, DCB *client) strerror(eno)); return NULL; } - - +#if defined(SS_DEBUG) session->ses_chk_top = CHK_NUM_SESSION; session->ses_chk_tail = CHK_NUM_SESSION; +#endif spinlock_init(&session->ses_lock); /** * Prevent backend threads from accessing before session is completely diff --git a/server/include/hashtable.h b/server/include/hashtable.h index 71df1f681..ab95b205a 100644 --- a/server/include/hashtable.h +++ b/server/include/hashtable.h @@ -68,7 +68,9 @@ typedef void *(*HASHMEMORYFN)(void *); * The general purpose hashtable struct. */ typedef struct hashtable { +#if defined(SS_DEBUG) skygw_chk_t ht_chk_top; +#endif int hashsize; /**< The number of HASHENTRIES */ HASHENTRIES **entries; /**< The entries themselves */ int (*hashfn)(void *); /**< The hash function */ @@ -78,7 +80,9 @@ typedef struct hashtable { SPINLOCK spin; /**< Internal spinlock for the hashtable */ int n_readers; /**< Number of clients reading the table */ int writelock; /**< The table is locked by a writer */ +#if defined(SS_DEBUG) skygw_chk_t ht_chk_tail; +#endif } HASHTABLE; extern HASHTABLE *hashtable_alloc(int, int (*hashfn)(), int (*cmpfn)()); diff --git a/server/include/session.h b/server/include/session.h index a4633c4ec..37d1b52a2 100644 --- a/server/include/session.h +++ b/server/include/session.h @@ -65,7 +65,9 @@ typedef enum { * and originating service together for the client session. */ typedef struct session { +#if defined(SS_DEBUG) skygw_chk_t ses_chk_top; +#endif SPINLOCK ses_lock; session_state_t state; /**< Current descriptor state */ struct dcb *client; /**< The client connection */ @@ -76,7 +78,9 @@ typedef struct session { struct service *service; /**< The service this session is using */ struct session *next; /**< Linked list of all sessions */ int refcount; /**< Reference count on the session */ +#if defined(SS_DEBUG) skygw_chk_t ses_chk_tail; +#endif } SESSION; #define SESSION_PROTOCOL(x, type) DCB_PROTOCOL((x)->client, type) diff --git a/server/modules/include/mysql_client_server_protocol.h b/server/modules/include/mysql_client_server_protocol.h index d23ca29f5..f9119b0e0 100644 --- a/server/modules/include/mysql_client_server_protocol.h +++ b/server/modules/include/mysql_client_server_protocol.h @@ -100,7 +100,9 @@ typedef enum { * MySQL Protocol specific state data */ typedef struct { +#if defined(SS_DEBUG) skygw_chk_t protocol_chk_top; +#endif int fd; /* The socket descriptor */ struct dcb *owner_dcb; /** The DCB of the socket * we are running on */ @@ -113,7 +115,9 @@ typedef struct { * created or received */ unsigned long tid; /** MySQL Thread ID, in * handshake */ +#if defined(SS_DEBUG) skygw_chk_t protocol_chk_tail; +#endif } MySQLProtocol; /* diff --git a/server/modules/protocol/mysql_common.c b/server/modules/protocol/mysql_common.c index a1804fd9f..c222276ae 100644 --- a/server/modules/protocol/mysql_common.c +++ b/server/modules/protocol/mysql_common.c @@ -62,8 +62,10 @@ MySQLProtocol* mysql_protocol_init( goto return_p; } p->state = MYSQL_ALLOC; +#if defined(SS_DEBUG) p->protocol_chk_top = CHK_NUM_PROTOCOL; p->protocol_chk_tail = CHK_NUM_PROTOCOL; +#endif p->fd = dcb->fd; p->owner_dcb = dcb; dcb->protocol = p;