Added check routine for gw_buffer. Only effective in debug build.
This commit is contained in:
@ -37,7 +37,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <buffer.h>
|
#include <buffer.h>
|
||||||
#include <atomic.h>
|
#include <atomic.h>
|
||||||
|
#include <skygw_debug.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allocate a new gateway buffer structure of size bytes.
|
* Allocate a new gateway buffer structure of size bytes.
|
||||||
@ -82,7 +82,7 @@ SHARED_BUF *sbuf;
|
|||||||
rval->sbuf = sbuf;
|
rval->sbuf = sbuf;
|
||||||
rval->next = NULL;
|
rval->next = NULL;
|
||||||
rval->command = 0;
|
rval->command = 0;
|
||||||
|
CHK_GWBUF(rval);
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,9 +95,10 @@ void
|
|||||||
gwbuf_free(GWBUF *buf)
|
gwbuf_free(GWBUF *buf)
|
||||||
{
|
{
|
||||||
atomic_add(&buf->sbuf->refcount, -1);
|
atomic_add(&buf->sbuf->refcount, -1);
|
||||||
|
CHK_GWBUF(buf);
|
||||||
if (buf->sbuf->refcount == 0)
|
if (buf->sbuf->refcount == 0)
|
||||||
{
|
{
|
||||||
free(buf->sbuf->data);
|
free(buf->sbuf->data);
|
||||||
free(buf->sbuf);
|
free(buf->sbuf);
|
||||||
}
|
}
|
||||||
free(buf);
|
free(buf);
|
||||||
@ -129,7 +130,7 @@ GWBUF *rval;
|
|||||||
rval->end = buf->end;
|
rval->end = buf->end;
|
||||||
rval->next = NULL;
|
rval->next = NULL;
|
||||||
rval->command = buf->command;
|
rval->command = buf->command;
|
||||||
|
CHK_GWBUF(rval);
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -146,9 +147,10 @@ GWBUF *
|
|||||||
gwbuf_append(GWBUF *head, GWBUF *tail)
|
gwbuf_append(GWBUF *head, GWBUF *tail)
|
||||||
{
|
{
|
||||||
GWBUF *ptr = head;
|
GWBUF *ptr = head;
|
||||||
|
|
||||||
if (!head)
|
if (!head)
|
||||||
return tail;
|
return tail;
|
||||||
|
CHK_GWBUF(head);
|
||||||
while (ptr->next)
|
while (ptr->next)
|
||||||
{
|
{
|
||||||
ptr = ptr->next;
|
ptr = ptr->next;
|
||||||
@ -177,7 +179,7 @@ GWBUF *
|
|||||||
gwbuf_consume(GWBUF *head, unsigned int length)
|
gwbuf_consume(GWBUF *head, unsigned int length)
|
||||||
{
|
{
|
||||||
GWBUF *rval = head;
|
GWBUF *rval = head;
|
||||||
|
CHK_GWBUF(head);
|
||||||
GWBUF_CONSUME(head, length);
|
GWBUF_CONSUME(head, length);
|
||||||
if (GWBUF_EMPTY(head))
|
if (GWBUF_EMPTY(head))
|
||||||
{
|
{
|
||||||
@ -197,7 +199,7 @@ unsigned int
|
|||||||
gwbuf_length(GWBUF *head)
|
gwbuf_length(GWBUF *head)
|
||||||
{
|
{
|
||||||
int rval = 0;
|
int rval = 0;
|
||||||
|
CHK_GWBUF(head);
|
||||||
while (head)
|
while (head)
|
||||||
{
|
{
|
||||||
rval += GWBUF_LENGTH(head);
|
rval += GWBUF_LENGTH(head);
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* Copyright SkySQL Ab 2013
|
* Copyright SkySQL Ab 2013
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#define __USE_UNIX98 1
|
#define __USE_UNIX98 1
|
||||||
@ -360,6 +360,11 @@ typedef enum skygw_chk_t {
|
|||||||
"Session under- or overflow"); \
|
"Session under- or overflow"); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define CHK_GWBUF(b) { \
|
||||||
|
ss_info_dassert(((b)->start <= (b)->end), \
|
||||||
|
"gwbuf start has passed the endpoint"); \
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(SS_DEBUG)
|
#if defined(SS_DEBUG)
|
||||||
bool conn_open[1024];
|
bool conn_open[1024];
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user